GUI: tooltip tables too spaced; tests: Ultracode READER_INIT, more signedness fixes

This commit is contained in:
gitlost 2020-10-04 14:27:28 +01:00
parent 5a8bbb28f0
commit 0617a5fec0
7 changed files with 104 additions and 47 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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 },
};

View File

@ -57,20 +57,20 @@ will be converted to spaces</string>
</property>
<property name="toolTip">
<string>Get input data from a file. Certain characters &lt;br/&gt;will be converted to escape sequences
&lt;table cellpadding=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;End of Transmission (0x04)&lt;/td&gt;&lt;td&gt;\E&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Bell (0x07)&lt;/td&gt;&lt;td&gt;\a&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Backspace (0x08)&lt;/td&gt;&lt;td&gt;\b&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Horizontal Tab (0x09)&lt;/td&gt;&lt;td&gt;\t&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Vertical Tab (0x0B)&lt;/td&gt;&lt;td&gt;\v&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Form Feed (0x0C)&lt;/td&gt;&lt;td&gt;\f&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Carriage Return (0x0D)&lt;/td&gt;&lt;td&gt;\r&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Escape (0x1B)&lt;/td&gt;&lt;td&gt;\e&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Group Selector (0x1D)&lt;/td&gt;&lt;td&gt;\G&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Record Selector (0x1E)&lt;/td&gt;&lt;td&gt;\R&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Backslash (0x5C)&lt;/td&gt;&lt;td&gt;\\&lt;/td&gt;&lt;/tr&gt;
&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;End of Transmission (0x04)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\E&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Bell (0x07)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\a&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Backspace (0x08)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\b&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Horizontal Tab (0x09)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\t&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Vertical Tab (0x0B)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\v&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Form Feed (0x0C)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\f&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Carriage Return (0x0D)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\r&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Escape (0x1B)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\e&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Group Selector (0x1D)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\G&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Record Selector (0x1E)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\R&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Backslash (0x5C)&lt;/td&gt;&lt;td&gt;&amp;nbsp;\\&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
Note that newlines (Line Feed (0x0A)) are &lt;br/&gt;not included</string>
Note that newlines (Line Feeds (0x0A)) are &lt;br/&gt;not included</string>
</property>
</widget>
</item>

View File

@ -87,7 +87,7 @@
<cstring>linFormat</cstring>
</property>
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellpadding=&quot;3&quot;&gt;
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;#&lt;/td&gt;&lt;td&gt;Number or space&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or &apos;0&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or &apos;*&apos;&lt;/td&gt;&lt;/tr&gt;
@ -172,7 +172,7 @@
<string>$$$$$$</string>
</property>
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellpadding=&quot;3&quot;&gt;
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;#&lt;/td&gt;&lt;td&gt;Number or space&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Number or &apos;0&apos;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Number or &apos;*&apos;&lt;/td&gt;&lt;/tr&gt;

View File

@ -241,7 +241,7 @@
<item row="1" column="0">
<widget class="QRadioButton" name="radPDFTruncated">
<property name="text">
<string>Compact PDF417</string>
<string>&amp;Compact PDF417</string>
</property>
</widget>
</item>

View File

@ -301,7 +301,7 @@ or import from file</string>
<bool>false</bool>
</property>
<property name="text">
<string>2D &amp;Component Data:</string>
<string>2D C&amp;omponent Data:</string>
</property>
<property name="buddy">
<cstring>txtComposite</cstring>
@ -540,26 +540,26 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QCheckBox" name="chkEscape">
<property name="toolTip">
<string>Process escape sequences in input data&lt;table cellpadding=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;\0&lt;/td&gt;&lt;td&gt;NUL character (0x00)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\E&lt;/td&gt;&lt;td&gt;End of Transmission (0x04)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\a&lt;/td&gt;&lt;td&gt;Bell (0x07)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\b&lt;/td&gt;&lt;td&gt;Backspace (0x08)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\t&lt;/td&gt;&lt;td&gt;Horizontal Tab (0x09)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\n&lt;/td&gt;&lt;td&gt;Line Feed (0x0A)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\v&lt;/td&gt;&lt;td&gt;Vertical Tab (0x0B)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\f&lt;/td&gt;&lt;td&gt;Form Feed (0x0C)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\r&lt;/td&gt;&lt;td&gt;Carriage Return (0x0D)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\e&lt;/td&gt;&lt;td&gt;Escape (0x1B)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\G&lt;/td&gt;&lt;td&gt;Group Selector (0x1D)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\R&lt;/td&gt;&lt;td&gt;Record Selector (0x1E)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\\&lt;/td&gt;&lt;td&gt;Backslash (0x5C)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\xNN&lt;/td&gt;&lt;td&gt;8-bit character (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\uNNNN&lt;/td&gt;&lt;td&gt;16-bit Unicode (N hex)&lt;/td&gt;&lt;/tr&gt;
<string>Process escape sequences in input data&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;\0&amp;nbsp;&lt;/td&gt;&lt;td&gt;NUL character (0x00)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\E&amp;nbsp;&lt;/td&gt;&lt;td&gt;End of Transmission (0x04)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\a&amp;nbsp;&lt;/td&gt;&lt;td&gt;Bell (0x07)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\b&amp;nbsp;&lt;/td&gt;&lt;td&gt;Backspace (0x08)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\t&amp;nbsp;&lt;/td&gt;&lt;td&gt;Horizontal Tab (0x09)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\n&amp;nbsp;&lt;/td&gt;&lt;td&gt;Line Feed (0x0A)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\v&amp;nbsp;&lt;/td&gt;&lt;td&gt;Vertical Tab (0x0B)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\f&amp;nbsp;&lt;/td&gt;&lt;td&gt;Form Feed (0x0C)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\r&amp;nbsp;&lt;/td&gt;&lt;td&gt;Carriage Return (0x0D)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\e&amp;nbsp;&lt;/td&gt;&lt;td&gt;Escape (0x1B)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\G&amp;nbsp;&lt;/td&gt;&lt;td&gt;Group Selector (0x1D)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\R&amp;nbsp;&lt;/td&gt;&lt;td&gt;Record Selector (0x1E)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\\&amp;nbsp;&lt;/td&gt;&lt;td&gt;Backslash (0x5C)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\xNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;8-bit character (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\uNNNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;16-bit Unicode (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<property name="text">
<string>&amp;Parse Escapes</string>
<string>Parse Es&amp;capes</string>
</property>
<property name="checked">
<bool>false</bool>