We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello.
I've found an example of data, when encode-decode round trip does not give the identical result. It consists of four bytes: 0x00, 0x00, 0x80, 0x40.
0x00, 0x00, 0x80, 0x40
The patch to add this test case is:
diff --git a/tests/test.cpp b/tests/test.cpp index 078a6d4..bc35c4f 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -52,6 +52,7 @@ static void encode_decode_uint8() const uint8_t literalszeros[] = { 0x55, 0x00 }; const uint8_t literalsones[] = { 0xAA, 0xFF }; const uint8_t mixed[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x FF, 0xAA, 0x00 }; + const uint8_t weird[] = { 0x00, 0x00, 0x80, 0x40 }; assert_true( roundtrip( zeros, 0xFFu ) ); assert_true( roundtrip( ones ) ); @@ -63,6 +64,7 @@ static void encode_decode_uint8() assert_true( roundtrip( literalszeros ) ); assert_true( roundtrip( literalsones ) ); assert_true( roundtrip( mixed ) ); + assert_true( roundtrip( weird ) ); } static void encode_decode_uint16()
The test program then produces this result:
> ./obj/test check failed! (file tests/test.cpp, line 67): roundtrip( weird ) Total tests: 45, Tests failed: 1
It was possible to fix this with the following change:
diff --git a/src/brle.h b/src/brle.h index 70f7b83..e4391ba 100644 --- a/src/brle.h +++ b/src/brle.h @@ -409,6 +409,10 @@ constexpr auto decode( InputIt input, InputIt last, OutputIt output ) -> OutputI bit_count = bit_count - data_bits; bits = in >> ( detail::literal_size - bit_count ); } + + if( bit_count == 0) { + bits = 0; + } } return output;
But I am not completely sure if this is a correct approach.
The text was updated successfully, but these errors were encountered:
PG1003
No branches or pull requests
Hello.
I've found an example of data, when encode-decode round trip does not give the identical result. It consists of four bytes:
0x00, 0x00, 0x80, 0x40
.The patch to add this test case is:
The test program then produces this result:
It was possible to fix this with the following change:
But I am not completely sure if this is a correct approach.
The text was updated successfully, but these errors were encountered: