Git Product home page Git Product logo

Comments (7)

nishihatapalmer avatar nishihatapalmer commented on May 20, 2024

Interesting... will investigate. Seems like the length of the file is only 109161, but is attempting to read at position 112122 - which is past the end of the file, so -1 is the expected result. But I don't know why the test thinks it can read a valid value at that position in the first place.

Note that the readByte interface explicitly returns negative numbers when there is no byte value available, in common with similar standard Java interfaces. This means we avoid having to throw an exception if you read past the end of a file, for example.

from byteseek.

nishihatapalmer avatar nishihatapalmer commented on May 20, 2024

The code itself seems to be doing exactly the right thing - returning -1 when trying to read beyond the end of the file. The FileReader sets the length of the file in the constructor, using File.length(). The length field is final.

However - this test file IS long enough. The length of the file reported above is incorrect. This seems to indicate that your test files are corrupt, or have been overwritten with different files.

Can you check that your test file TestASCII.txt has a length of 112280 bytes?

from byteseek.

 avatar commented on May 20, 2024

The file is 109161 bytes long. The last line is: FINIS. A MIDSOMMER Nights Dreame.
I've pulled it down again, and it's still 109161 bytes. The github inline viewer says its 3120 lines, where I only have 3119, but it seems to be off by one - and I don't think the one line would make a 3119 byte difference. A visual check doesn't show anything obvious wrong with the file, though there could easily be a chunk missing in the middle..

The full set of test fails follows. The second fail is in fact on the length of this file..

Failed tests: testReadByte(net.byteseek.io.reader.FileReaderTest): Reader FileReader[file:/home/dev/github/byteseek2/byteseek/target/test-classes/TestASCII.txt length: 109161 cache:MostRecentlyUsedCache[size: 0 capacity: 33]] reading at position 112122 should have value 80 expected:<80> but was:<-1>
testLength(net.byteseek.io.reader.FileReaderTest): length ASCII expected:<112280> but was:<109161>
testMatchesOverBoundary_ByteReader_long(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): 'be' at pos 4095
testReverseMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatches_byteArr_int(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): '' '' '' at pos 1017
testMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatchesNoBoundsCheck_byteArr_int(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): '
' '' '' at pos 1017
testMatches_ByteReader_long(net.byteseek.matcher.sequence.SequenceSequenceMatcherTest): '' '' '' at pos 1017
testMatchesOverBoundary_ByteReader_long(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): 'be' at pos 4095
testReverseMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatches_byteArr_int(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): '
' at pos 1017
testMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatchesNoBoundsCheck_byteArr_int(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): '
' at pos 1017
testMatches_ByteReader_long(net.byteseek.matcher.sequence.ByteMatcherSequenceMatcherTest): '
' at pos 1017
testMatches_ByteReader_long(net.byteseek.matcher.sequence.FixedGapMatcherTest): ... at pos 112276
testMatchesOverBoundary_ByteReader_long(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): 'be' at pos 4095
testReverseMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatches_byteArr_int(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): '
' at pos 1017
testMatchesNoBoundsCheck_outOfBoundsCrossingEnd(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): Expected exception: java.lang.ArrayIndexOutOfBoundsException
testMatchesNoBoundsCheck_byteArr_int(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): '
' at pos 1017
testMatches_ByteReader_long(net.byteseek.matcher.sequence.ByteSequenceMatcherTest): '
*' at pos 1017

Tests run: 506, Failures: 21, Errors: 0, Skipped: 0

from byteseek.

nishihatapalmer avatar nishihatapalmer commented on May 20, 2024

HI Graham,

thanks for checking. I've compared versions, and my local version is longer than the one in GitHub, even though it insists they are the same!

This is the old Windows / UNIX line ending thing. My version has CRLF line endings. Seems that you have to configure git to handle line endings appropriately. Will investigate to fix this - but it is an issue with how git handles the test file, not with the code.

I'll let you know when I have a solution to this.

from byteseek.

nishihatapalmer avatar nishihatapalmer commented on May 20, 2024

Hi,

I have added a .gitattributes file, which apparently will configure how .txt files are handled - always with CRLF. This is supposed to override whatever global settings you may have in git, for this repository.

Can you check out the latest version and see what happens? It should now treat text files as always requiring CRLF line endings, and convert them if necessary on checkout...

See this article for more info: https://help.github.com/articles/dealing-with-line-endings/

from byteseek.

 avatar commented on May 20, 2024

Yay, all tests now pass! Thanks so much. Very handy to know about for the future.

from byteseek.

nishihatapalmer avatar nishihatapalmer commented on May 20, 2024

Great!

I had a head scratching moment when the file sizes didn't match, but git
insisted they were identical!

Thanks for reporting the issue and testing on your end.

cheers,

Matt

On 12 November 2015 at 13:52, Graham Seaman [email protected]
wrote:

Yay, all tests now pass! Thanks so much. Very handy to know about for the
future.


Reply to this email directly or view it on GitHub
#1 (comment)
.

from byteseek.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.