X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=core%2Ftest%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fqrcode%2Fdecoder%2FFormatInformationTestCase.java;h=6bf1ef7a34452f59a4b1f936df07a39212e4457c;hp=e737993e1e9130a841546802cfb69ddacdd54421;hb=feb768bba4b752ffe9ae48f6460675280517ec16;hpb=dfd8c1e623514366161858e9fc22c9a85009a298 diff --git a/core/test/src/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java b/core/test/src/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java index e737993e..6bf1ef7a 100644 --- a/core/test/src/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java +++ b/core/test/src/com/google/zxing/qrcode/decoder/FormatInformationTestCase.java @@ -35,17 +35,34 @@ public final class FormatInformationTestCase extends TestCase { public void testDecode() { // Normal case - FormatInformation expected = FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO); + FormatInformation expected = + FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); assertEquals((byte) 0x07, expected.getDataMask()); - assertEquals(ErrorCorrectionLevel.Q, expected.getErrorCorrectionLevel()); + assertSame(ErrorCorrectionLevel.Q, expected.getErrorCorrectionLevel()); // where the code forgot the mask! - assertEquals(expected, FormatInformation.decodeFormatInformation(UNMASKED_TEST_FORMAT_INFO)); + assertEquals(expected, + FormatInformation.decodeFormatInformation(UNMASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO)); + } + public void testDecodeWithBitDifference() { + FormatInformation expected = + FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); // 1,2,3,4 bits difference - assertEquals(expected, FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO ^ 0x01)); - assertEquals(expected, FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO ^ 0x03)); - assertEquals(expected, FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO ^ 0x07)); - assertNull(FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO ^ 0x0F)); + assertEquals(expected, FormatInformation.decodeFormatInformation( + MASKED_TEST_FORMAT_INFO ^ 0x01, MASKED_TEST_FORMAT_INFO ^ 0x01)); + assertEquals(expected, FormatInformation.decodeFormatInformation( + MASKED_TEST_FORMAT_INFO ^ 0x03, MASKED_TEST_FORMAT_INFO ^ 0x03)); + assertEquals(expected, FormatInformation.decodeFormatInformation( + MASKED_TEST_FORMAT_INFO ^ 0x07, MASKED_TEST_FORMAT_INFO ^ 0x07)); + assertNull(FormatInformation.decodeFormatInformation( + MASKED_TEST_FORMAT_INFO ^ 0x0F, MASKED_TEST_FORMAT_INFO ^ 0x0F)); + } + + public void testDecodeWithMisread() { + FormatInformation expected = + FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO); + assertEquals(expected, FormatInformation.decodeFormatInformation( + MASKED_TEST_FORMAT_INFO ^ 0x03, MASKED_TEST_FORMAT_INFO ^ 0x0F)); } } \ No newline at end of file