Add test for FileChannels.contentEquals.#509
Conversation
garydgregory
left a comment
There was a problem hiding this comment.
Hello @smarkwal
Thank you for the test.
Would you please add the Apache license header to the new file?
|
I have added the license header and also applied a code style that seems to be used in this project. I was not able to find an |
- Fix FileChannels.contentEquals()
|
Hello @smarkwal, Thank you for your update. Please test git master or a build from the Apache Maven snapshot repository. I did not merge this PR since it would fail the build; instead, I expanded the test, and committed a fix at the same time. You are credited in |
|
Hi @garydgregory, Thank you very much for the quick fix and improving the test. I have been able to use 2.15.1-SNAPSHOT without problems in my project. I also did some more extensive testing and the new implementation has worked perfectly. I will close this PR. Best, |
|
👍 |
The test in this PR uses
FileChannels.contentEqualsto compare the content of two files. Both files have the same size of 1027 bytes. While the content of file 1 starts with "ABC", the content of file 2 starts with "XYZ". Both files then contain additional identical 1024 bytes (1024 x character "x"). The two files should be considered having different content.If
FileChannels.contentEqualsis invoked with a buffer size of 1024 bytes, it will returntrue(content is equal) instead of the expectedfalse(content is different).If calling the method with a buffer size of 1023 bytes (just 1 byte less), then the method will return the correct result
false.