diff options
| author | Michael Jahn <mikej06@hotmail.com> | 2017-09-20 09:44:23 +0300 |
|---|---|---|
| committer | Sean Owen <srowen@gmail.com> | 2017-09-20 09:44:23 +0300 |
| commit | 24f170efb3974f1e9e2b68591a85218f706f2fd8 (patch) | |
| tree | 5e3a6b3256ca1bad7982dffeea78de5c255166f6 /core/src/test/java/com | |
| parent | 437db89b45baabf79292d741506c6e6acf2cf0c9 (diff) | |
| download | zxing-24f170efb3974f1e9e2b68591a85218f706f2fd8.tar.xz | |
Add codeset A support to Code 128 (#877)
* add support of Codeset A for Code 128
* simplification, everything from 0 to 127 is supported by Codeset A and B
Diffstat (limited to 'core/src/test/java/com')
| -rw-r--r-- | core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java index 312128fd7..7a667ae4e 100644 --- a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java @@ -34,8 +34,10 @@ public class Code128WriterTestCase extends Assert { private static final String FNC2 = "11110101000"; private static final String FNC3 = "10111100010"; private static final String FNC4 = "10111101110"; + private static final String START_CODE_A = "11010000100"; private static final String START_CODE_B = "11010010000"; private static final String START_CODE_C = "11010011100"; + private static final String SWITCH_CODE_A = "11101011110"; private static final String SWITCH_CODE_B = "10111101110"; private static final String QUIET_SPACE = "00000"; private static final String STOP = "1100011101011"; @@ -108,6 +110,27 @@ public class Code128WriterTestCase extends Assert { String actual = BitMatrixTestCase.matrixToString(result); assertEquals(expected, actual); } + + @Test + public void testEncodeSwitchBetweenCodesetsAAndB() throws Exception { + // start with A switch to B and back to A + // "\0" "A" "B" Switch to B "a" "b" Switch to A "\u0010" check digit + testEncode("\0ABab\u0010", QUIET_SPACE + START_CODE_A + "10100001100" + "10100011000" + "10001011000" + SWITCH_CODE_B + "10010110000" + "10010000110" + SWITCH_CODE_A + "10100111100" + "11001110100" + STOP + QUIET_SPACE); + + // start with B switch to A and back to B + // "a" "b" Switch to A "\0 "Switch to B" "a" "b" check digit + testEncode("ab\0ab", QUIET_SPACE + START_CODE_B + "10010110000" + "10010000110" + SWITCH_CODE_A + "10100001100" + SWITCH_CODE_B + "10010110000" + "10010000110" + "11010001110" + STOP + QUIET_SPACE); + } + + private void testEncode(String toEncode, String expected) throws Exception { + BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - + String actual = BitMatrixTestCase.matrixToString(result); + assertEquals(toEncode, expected, actual); + + BitArray row = result.getRow(0, null); + Result rtResult = reader.decodeRow(0, row, null); + String actualRoundtripResultText = rtResult.getText(); + assertEquals(toEncode, actualRoundtripResultText); + } } |
