From 0617a5fec078d96241db9e93fedcd15209ef0dc2 Mon Sep 17 00:00:00 2001 From: gitlost Date: Sun, 4 Oct 2020 14:27:28 +0100 Subject: [PATCH] GUI: tooltip tables too spaced; tests: Ultracode READER_INIT, more signedness fixes --- backend/tests/test_common.c | 9 +++--- backend/tests/test_dmatrix.c | 16 +++++----- backend/tests/test_ultra.c | 58 ++++++++++++++++++++++++++++++++++++ frontend_qt/extData.ui | 26 ++++++++-------- frontend_qt/extSequence.ui | 4 +-- frontend_qt/grpPDF417.ui | 2 +- frontend_qt/mainWindow.ui | 36 +++++++++++----------- 7 files changed, 104 insertions(+), 47 deletions(-) diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index 5381063b..090cd86d 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -37,12 +37,12 @@ static void test_utf8_to_unicode(int index, int debug) { int ret; struct item { - unsigned char *data; + char *data; int length; int disallow_4byte; int ret; size_t ret_length; - int expected_vals[20]; + unsigned int expected_vals[20]; char *comment; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) @@ -55,7 +55,7 @@ static void test_utf8_to_unicode(int index, int debug) { }; int data_size = sizeof(data) / sizeof(struct item); - int vals[20]; + unsigned int vals[20]; struct zint_symbol symbol; symbol.debug |= debug; @@ -66,7 +66,7 @@ static void test_utf8_to_unicode(int index, int debug) { int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; size_t ret_length = length; - ret = utf8_to_unicode(&symbol, data[i].data, vals, &ret_length, data[i].disallow_4byte); + ret = utf8_to_unicode(&symbol, (unsigned char *) data[i].data, vals, &ret_length, data[i].disallow_4byte); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); if (ret == 0) { assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %ld != %ld\n", i, ret_length, data[i].ret_length); @@ -83,7 +83,6 @@ static void test_debug_test_codeword_dump_int(int index, int debug) { testStart(""); - int ret; struct item { int codewords[50]; int length; diff --git a/backend/tests/test_dmatrix.c b/backend/tests/test_dmatrix.c index c1926fdb..a0d87a2e 100644 --- a/backend/tests/test_dmatrix.c +++ b/backend/tests/test_dmatrix.c @@ -38,7 +38,7 @@ static void test_large(int index, int debug) { int ret; struct item { int symbology; - unsigned char *pattern; + char *pattern; int length; int ret; int expected_rows; @@ -71,7 +71,7 @@ static void test_large(int index, int debug) { int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug); - ret = ZBarcode_Encode(symbol, data_buf, length); + ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (ret < 5) { @@ -92,7 +92,7 @@ static void test_buffer(int index, int debug) { int ret; struct item { - unsigned char *data; + char *data; int eci; int input_mode; int output_options; @@ -121,7 +121,7 @@ static void test_buffer(int index, int debug) { int length = strlen(data[i].data); - ret = ZBarcode_Encode(symbol, data[i].data, length); + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); ZBarcode_Delete(symbol); @@ -141,7 +141,7 @@ static void test_input(int index, int generate, int debug) { int option_1; int option_2; int option_3; - unsigned char *data; + char *data; int ret; int expected_eci; @@ -177,7 +177,7 @@ static void test_input(int index, int generate, int debug) { int length = testUtilSetSymbol(symbol, BARCODE_DATAMATRIX, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug); - ret = ZBarcode_Encode(symbol, data[i].data, length); + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); if (generate) { @@ -207,7 +207,7 @@ static void test_encode(int index, int generate, int debug) { struct item { int symbology; int input_mode; - unsigned char *data; + char *data; int ret; int expected_rows; @@ -448,7 +448,7 @@ static void test_encode(int index, int generate, int debug) { int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); - ret = ZBarcode_Encode(symbol, data[i].data, length); + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); if (generate) { diff --git a/backend/tests/test_ultra.c b/backend/tests/test_ultra.c index 83f7b035..19e56295 100644 --- a/backend/tests/test_ultra.c +++ b/backend/tests/test_ultra.c @@ -31,6 +31,63 @@ #include "testcommon.h" +static void test_reader_init(int index, int generate, int debug) { + + testStart(""); + + int ret; + struct item { + int input_mode; + int output_options; + int option_3; + char *data; + int ret; + int expected_rows; + int expected_width; + char *expected; + char *comment; + }; + struct item data[] = { + /* 0*/ { UNICODE_MODE, READER_INIT, 0, "A", 0, 13, 14, "(3) 257 269 65", "8-bit FNC3 A" }, + /* 1*/ { UNICODE_MODE, READER_INIT, ULTRA_COMPRESSION, "A", 0, 13, 14, "(3) 272 271 65", "ASCII FNC3 A Note: draft spec inconsistent and FNC3 may be 272 in ASCII mode (and FNC1 271)" }, + }; + int data_size = ARRAY_SIZE(data); + + char escaped[1024]; + + for (int i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + struct zint_symbol *symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt + + int length = testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, data[i].option_3, data[i].output_options, data[i].data, -1, debug); + + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + + if (generate) { + printf(" /*%3d*/ { %s, %s, %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n", + i, testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), testUtilOption3Name(data[i].option_3), + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); + } else { + if (ret < 5) { + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + } + } + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + static void test_input(int index, int generate, int debug) { testStart(""); @@ -464,6 +521,7 @@ static void test_encode(int index, int generate, int debug) { int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ + { "test_reader_init", test_reader_init, 1, 1, 1 }, { "test_input", test_input, 1, 1, 1 }, { "test_encode", test_encode, 1, 1, 1 }, }; diff --git a/frontend_qt/extData.ui b/frontend_qt/extData.ui index 933a114d..49b363dc 100644 --- a/frontend_qt/extData.ui +++ b/frontend_qt/extData.ui @@ -57,20 +57,20 @@ will be converted to spaces Get input data from a file. Certain characters <br/>will be converted to escape sequences -<table cellpadding="3"> -<tr><td>End of Transmission (0x04)</td><td>\E</td></tr> -<tr><td>Bell (0x07)</td><td>\a</td></tr> -<tr><td>Backspace (0x08)</td><td>\b</td></tr> -<tr><td>Horizontal Tab (0x09)</td><td>\t</td></tr> -<tr><td>Vertical Tab (0x0B)</td><td>\v</td></tr> -<tr><td>Form Feed (0x0C)</td><td>\f</td></tr> -<tr><td>Carriage Return (0x0D)</td><td>\r</td></tr> -<tr><td>Escape (0x1B)</td><td>\e</td></tr> -<tr><td>Group Selector (0x1D)</td><td>\G</td></tr> -<tr><td>Record Selector (0x1E)</td><td>\R</td></tr> -<tr><td>Backslash (0x5C)</td><td>\\</td></tr> +<table cellspacing="3"> +<tr><td>End of Transmission (0x04)</td><td>&nbsp;\E</td></tr> +<tr><td>Bell (0x07)</td><td>&nbsp;\a</td></tr> +<tr><td>Backspace (0x08)</td><td>&nbsp;\b</td></tr> +<tr><td>Horizontal Tab (0x09)</td><td>&nbsp;\t</td></tr> +<tr><td>Vertical Tab (0x0B)</td><td>&nbsp;\v</td></tr> +<tr><td>Form Feed (0x0C)</td><td>&nbsp;\f</td></tr> +<tr><td>Carriage Return (0x0D)</td><td>&nbsp;\r</td></tr> +<tr><td>Escape (0x1B)</td><td>&nbsp;\e</td></tr> +<tr><td>Group Selector (0x1D)</td><td>&nbsp;\G</td></tr> +<tr><td>Record Selector (0x1E)</td><td>&nbsp;\R</td></tr> +<tr><td>Backslash (0x5C)</td><td>&nbsp;\\</td></tr> </table> -Note that newlines (Line Feed (0x0A)) are <br/>not included +Note that newlines (Line Feeds (0x0A)) are <br/>not included diff --git a/frontend_qt/extSequence.ui b/frontend_qt/extSequence.ui index 8bcadfbf..43deb3a5 100644 --- a/frontend_qt/extSequence.ui +++ b/frontend_qt/extSequence.ui @@ -87,7 +87,7 @@ linFormat - Format sequence using special characters<table cellpadding="3"> + Format sequence using special characters<table cellspacing="3"> <tr><td>#</td><td>Number or space</td></tr> <tr><td>$</td><td>Number or '0'</td></tr> <tr><td>*</td><td>Number or '*'</td></tr> @@ -172,7 +172,7 @@ $$$$$$ - Format sequence using special characters<table cellpadding="3"> + Format sequence using special characters<table cellspacing="3"> <tr><td>#</td><td>Number or space</td></tr> <tr><td>$</td><td>Number or '0'</td></tr> <tr><td>*</td><td>Number or '*'</td></tr> diff --git a/frontend_qt/grpPDF417.ui b/frontend_qt/grpPDF417.ui index 501b4e22..f61e429a 100644 --- a/frontend_qt/grpPDF417.ui +++ b/frontend_qt/grpPDF417.ui @@ -241,7 +241,7 @@ - Compact PDF417 + &Compact PDF417 diff --git a/frontend_qt/mainWindow.ui b/frontend_qt/mainWindow.ui index 42f3ab1a..22d5f767 100644 --- a/frontend_qt/mainWindow.ui +++ b/frontend_qt/mainWindow.ui @@ -301,7 +301,7 @@ or import from file false - 2D &Component Data: + 2D C&omponent Data: txtComposite @@ -540,26 +540,26 @@ p, li { white-space: pre-wrap; } - Process escape sequences in input data<table cellpadding="3"> -<tr><td>\0</td><td>NUL character (0x00)</td></tr> -<tr><td>\E</td><td>End of Transmission (0x04)</td></tr> -<tr><td>\a</td><td>Bell (0x07)</td></tr> -<tr><td>\b</td><td>Backspace (0x08)</td></tr> -<tr><td>\t</td><td>Horizontal Tab (0x09)</td></tr> -<tr><td>\n</td><td>Line Feed (0x0A)</td></tr> -<tr><td>\v</td><td>Vertical Tab (0x0B)</td></tr> -<tr><td>\f</td><td>Form Feed (0x0C)</td></tr> -<tr><td>\r</td><td>Carriage Return (0x0D)</td></tr> -<tr><td>\e</td><td>Escape (0x1B)</td></tr> -<tr><td>\G</td><td>Group Selector (0x1D)</td></tr> -<tr><td>\R</td><td>Record Selector (0x1E)</td></tr> -<tr><td>\\</td><td>Backslash (0x5C)</td></tr> -<tr><td>\xNN</td><td>8-bit character (N hex)</td></tr> -<tr><td>\uNNNN</td><td>16-bit Unicode (N hex)</td></tr> + Process escape sequences in input data<table cellspacing="3"> +<tr><td>\0&nbsp;</td><td>NUL character (0x00)</td></tr> +<tr><td>\E&nbsp;</td><td>End of Transmission (0x04)</td></tr> +<tr><td>\a&nbsp;</td><td>Bell (0x07)</td></tr> +<tr><td>\b&nbsp;</td><td>Backspace (0x08)</td></tr> +<tr><td>\t&nbsp;</td><td>Horizontal Tab (0x09)</td></tr> +<tr><td>\n&nbsp;</td><td>Line Feed (0x0A)</td></tr> +<tr><td>\v&nbsp;</td><td>Vertical Tab (0x0B)</td></tr> +<tr><td>\f&nbsp;</td><td>Form Feed (0x0C)</td></tr> +<tr><td>\r&nbsp;</td><td>Carriage Return (0x0D)</td></tr> +<tr><td>\e&nbsp;</td><td>Escape (0x1B)</td></tr> +<tr><td>\G&nbsp;</td><td>Group Selector (0x1D)</td></tr> +<tr><td>\R&nbsp;</td><td>Record Selector (0x1E)</td></tr> +<tr><td>\\&nbsp;</td><td>Backslash (0x5C)</td></tr> +<tr><td>\xNN&nbsp;</td><td>8-bit character (N hex)</td></tr> +<tr><td>\uNNNN&nbsp;</td><td>16-bit Unicode (N hex)</td></tr> </table> - &Parse Escapes + Parse Es&capes false