mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
MICROQR: some debug output, test case for ticket #241
This commit is contained in:
parent
b7adbf4e5b
commit
b568201574
26
backend/qr.c
26
backend/qr.c
@ -1807,6 +1807,10 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
strcat(binary_data, "000");
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M1 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Manage last (4-bit) block */
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
@ -1859,8 +1863,6 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -1902,6 +1904,10 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 5, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M2 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Complete current byte */
|
||||
int remainder = 8 - (strlen(binary_data) % 8);
|
||||
@ -1942,8 +1948,6 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -1987,6 +1991,10 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 7, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M3 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Manage last (4-bit) block */
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
@ -2059,8 +2067,6 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -2107,6 +2113,10 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 9, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M4 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Complete current byte */
|
||||
int remainder = 8 - (strlen(binary_data) % 8);
|
||||
@ -2151,8 +2161,6 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -2562,6 +2570,8 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
qr_binary((unsigned char *) full_stream, MICROQR_VERSION + version, 0 /*target_codewords*/, mode, jisdata, length,
|
||||
0 /*gs1*/, 0 /*eci*/, binary_count[version], debug_print);
|
||||
|
||||
if (debug_print) printf("Binary (%d): %s\n", (int) strlen(full_stream), full_stream);
|
||||
|
||||
switch (version) {
|
||||
case 0: micro_qr_m1(symbol, full_stream);
|
||||
break;
|
||||
|
@ -2179,6 +2179,25 @@ static void test_microqr_encode(int index, int generate, int debug) {
|
||||
"01011000000010111"
|
||||
"11001111011101001"
|
||||
},
|
||||
/* 16*/ { UNICODE_MODE | ESCAPE_MODE, 1, -1, -1, "P-5-B223G846\015", 0, 17, 17, 1, "Ticket #241, 2.6.7 dropping off last character if mode different (MR #21)",
|
||||
"11111110101010101"
|
||||
"10000010100001100"
|
||||
"10111010011110010"
|
||||
"10111010100000101"
|
||||
"10111010011011111"
|
||||
"10000010111110100"
|
||||
"11111110110111101"
|
||||
"00000000011001000"
|
||||
"10010111011010100"
|
||||
"01110111000001110"
|
||||
"10100011001110111"
|
||||
"00011111000101010"
|
||||
"10011111101100110"
|
||||
"01110000111010100"
|
||||
"11001010110000000"
|
||||
"00011110011010001"
|
||||
"11101010111111111"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
Loading…
Reference in New Issue
Block a user