Comments (7)
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.
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.
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.
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.
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.
Yay, all tests now pass! Thanks so much. Very handy to know about for the future.
from byteseek.
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)
- SequenceMatcherCompiler fails to compile case insensitive strings.
- Regular expression syntax definition HOT 1
- Performance Issue with small alphabets and long texts HOT 47
- StringReader broken HOT 2
- Bounds checking does not look right HOT 2
- Typo: "first" should be "last" in syntax.md page HOT 7
- Design: should use Java charset names directly in regular expression language? HOT 5
- Prefix syntax for binary HOT 3
- Silent replacement of algorithms or throw an error? HOT 4
- Parse search strings as byteseek regexes, or just convert to byte arrays? HOT 8
- Support mark / reset in InputStreamReader HOT 2
- Support matching integer values or ranges > 8 bits HOT 5
- Returning the match including thr wildcards HOT 7
- Feature - return data matched. HOT 1
- Better documentation
- High level interface needed HOT 1
- Search and match variable length wildcards HOT 1
- Implement SBNDM search
- Implement HashChain search HOT 1
- MutableState has non-mutable initializations resulting in errors on deepCopy calls HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from byteseek.