mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
GUI: tooltip tables too spaced; tests: Ultracode READER_INIT, more signedness fixes
This commit is contained in:
parent
5a8bbb28f0
commit
0617a5fec0
@ -37,12 +37,12 @@ static void test_utf8_to_unicode(int index, int debug) {
|
|||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
struct item {
|
struct item {
|
||||||
unsigned char *data;
|
char *data;
|
||||||
int length;
|
int length;
|
||||||
int disallow_4byte;
|
int disallow_4byte;
|
||||||
int ret;
|
int ret;
|
||||||
size_t ret_length;
|
size_t ret_length;
|
||||||
int expected_vals[20];
|
unsigned int expected_vals[20];
|
||||||
char *comment;
|
char *comment;
|
||||||
};
|
};
|
||||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
// 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 data_size = sizeof(data) / sizeof(struct item);
|
||||||
|
|
||||||
int vals[20];
|
unsigned int vals[20];
|
||||||
struct zint_symbol symbol;
|
struct zint_symbol symbol;
|
||||||
symbol.debug |= debug;
|
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;
|
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||||
size_t ret_length = 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);
|
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||||
if (ret == 0) {
|
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);
|
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("");
|
testStart("");
|
||||||
|
|
||||||
int ret;
|
|
||||||
struct item {
|
struct item {
|
||||||
int codewords[50];
|
int codewords[50];
|
||||||
int length;
|
int length;
|
||||||
|
@ -38,7 +38,7 @@ static void test_large(int index, int debug) {
|
|||||||
int ret;
|
int ret;
|
||||||
struct item {
|
struct item {
|
||||||
int symbology;
|
int symbology;
|
||||||
unsigned char *pattern;
|
char *pattern;
|
||||||
int length;
|
int length;
|
||||||
int ret;
|
int ret;
|
||||||
int expected_rows;
|
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);
|
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);
|
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) {
|
if (ret < 5) {
|
||||||
@ -92,7 +92,7 @@ static void test_buffer(int index, int debug) {
|
|||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
struct item {
|
struct item {
|
||||||
unsigned char *data;
|
char *data;
|
||||||
int eci;
|
int eci;
|
||||||
int input_mode;
|
int input_mode;
|
||||||
int output_options;
|
int output_options;
|
||||||
@ -121,7 +121,7 @@ static void test_buffer(int index, int debug) {
|
|||||||
|
|
||||||
int length = strlen(data[i].data);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
|
|
||||||
ZBarcode_Delete(symbol);
|
ZBarcode_Delete(symbol);
|
||||||
@ -141,7 +141,7 @@ static void test_input(int index, int generate, int debug) {
|
|||||||
int option_1;
|
int option_1;
|
||||||
int option_2;
|
int option_2;
|
||||||
int option_3;
|
int option_3;
|
||||||
unsigned char *data;
|
char *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
int expected_eci;
|
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);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
@ -207,7 +207,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
struct item {
|
struct item {
|
||||||
int symbology;
|
int symbology;
|
||||||
int input_mode;
|
int input_mode;
|
||||||
unsigned char *data;
|
char *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
int expected_rows;
|
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);
|
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);
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
|
||||||
|
|
||||||
if (generate) {
|
if (generate) {
|
||||||
|
@ -31,6 +31,63 @@
|
|||||||
|
|
||||||
#include "testcommon.h"
|
#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) {
|
static void test_input(int index, int generate, int debug) {
|
||||||
|
|
||||||
testStart("");
|
testStart("");
|
||||||
@ -464,6 +521,7 @@ static void test_encode(int index, int generate, int debug) {
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
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_input", test_input, 1, 1, 1 },
|
||||||
{ "test_encode", test_encode, 1, 1, 1 },
|
{ "test_encode", test_encode, 1, 1, 1 },
|
||||||
};
|
};
|
||||||
|
@ -57,20 +57,20 @@ will be converted to spaces</string>
|
|||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Get input data from a file. Certain characters <br/>will be converted to escape sequences
|
<string>Get input data from a file. Certain characters <br/>will be converted to escape sequences
|
||||||
<table cellpadding="3">
|
<table cellspacing="3">
|
||||||
<tr><td>End of Transmission (0x04)</td><td>\E</td></tr>
|
<tr><td>End of Transmission (0x04)</td><td>&nbsp;\E</td></tr>
|
||||||
<tr><td>Bell (0x07)</td><td>\a</td></tr>
|
<tr><td>Bell (0x07)</td><td>&nbsp;\a</td></tr>
|
||||||
<tr><td>Backspace (0x08)</td><td>\b</td></tr>
|
<tr><td>Backspace (0x08)</td><td>&nbsp;\b</td></tr>
|
||||||
<tr><td>Horizontal Tab (0x09)</td><td>\t</td></tr>
|
<tr><td>Horizontal Tab (0x09)</td><td>&nbsp;\t</td></tr>
|
||||||
<tr><td>Vertical Tab (0x0B)</td><td>\v</td></tr>
|
<tr><td>Vertical Tab (0x0B)</td><td>&nbsp;\v</td></tr>
|
||||||
<tr><td>Form Feed (0x0C)</td><td>\f</td></tr>
|
<tr><td>Form Feed (0x0C)</td><td>&nbsp;\f</td></tr>
|
||||||
<tr><td>Carriage Return (0x0D)</td><td>\r</td></tr>
|
<tr><td>Carriage Return (0x0D)</td><td>&nbsp;\r</td></tr>
|
||||||
<tr><td>Escape (0x1B)</td><td>\e</td></tr>
|
<tr><td>Escape (0x1B)</td><td>&nbsp;\e</td></tr>
|
||||||
<tr><td>Group Selector (0x1D)</td><td>\G</td></tr>
|
<tr><td>Group Selector (0x1D)</td><td>&nbsp;\G</td></tr>
|
||||||
<tr><td>Record Selector (0x1E)</td><td>\R</td></tr>
|
<tr><td>Record Selector (0x1E)</td><td>&nbsp;\R</td></tr>
|
||||||
<tr><td>Backslash (0x5C)</td><td>\\</td></tr>
|
<tr><td>Backslash (0x5C)</td><td>&nbsp;\\</td></tr>
|
||||||
</table>
|
</table>
|
||||||
Note that newlines (Line Feed (0x0A)) are <br/>not included</string>
|
Note that newlines (Line Feeds (0x0A)) are <br/>not included</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<cstring>linFormat</cstring>
|
<cstring>linFormat</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Format sequence using special characters<table cellpadding="3">
|
<string>Format sequence using special characters<table cellspacing="3">
|
||||||
<tr><td>#</td><td>Number or space</td></tr>
|
<tr><td>#</td><td>Number or space</td></tr>
|
||||||
<tr><td>$</td><td>Number or '0'</td></tr>
|
<tr><td>$</td><td>Number or '0'</td></tr>
|
||||||
<tr><td>*</td><td>Number or '*'</td></tr>
|
<tr><td>*</td><td>Number or '*'</td></tr>
|
||||||
@ -172,7 +172,7 @@
|
|||||||
<string>$$$$$$</string>
|
<string>$$$$$$</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Format sequence using special characters<table cellpadding="3">
|
<string>Format sequence using special characters<table cellspacing="3">
|
||||||
<tr><td>#</td><td>Number or space</td></tr>
|
<tr><td>#</td><td>Number or space</td></tr>
|
||||||
<tr><td>$</td><td>Number or '0'</td></tr>
|
<tr><td>$</td><td>Number or '0'</td></tr>
|
||||||
<tr><td>*</td><td>Number or '*'</td></tr>
|
<tr><td>*</td><td>Number or '*'</td></tr>
|
||||||
|
@ -241,7 +241,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="radPDFTruncated">
|
<widget class="QRadioButton" name="radPDFTruncated">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Compact PDF417</string>
|
<string>&Compact PDF417</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -301,7 +301,7 @@ or import from file</string>
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>2D &Component Data:</string>
|
<string>2D C&omponent Data:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>txtComposite</cstring>
|
<cstring>txtComposite</cstring>
|
||||||
@ -540,26 +540,26 @@ p, li { white-space: pre-wrap; }
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chkEscape">
|
<widget class="QCheckBox" name="chkEscape">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Process escape sequences in input data<table cellpadding="3">
|
<string>Process escape sequences in input data<table cellspacing="3">
|
||||||
<tr><td>\0</td><td>NUL character (0x00)</td></tr>
|
<tr><td>\0&nbsp;</td><td>NUL character (0x00)</td></tr>
|
||||||
<tr><td>\E</td><td>End of Transmission (0x04)</td></tr>
|
<tr><td>\E&nbsp;</td><td>End of Transmission (0x04)</td></tr>
|
||||||
<tr><td>\a</td><td>Bell (0x07)</td></tr>
|
<tr><td>\a&nbsp;</td><td>Bell (0x07)</td></tr>
|
||||||
<tr><td>\b</td><td>Backspace (0x08)</td></tr>
|
<tr><td>\b&nbsp;</td><td>Backspace (0x08)</td></tr>
|
||||||
<tr><td>\t</td><td>Horizontal Tab (0x09)</td></tr>
|
<tr><td>\t&nbsp;</td><td>Horizontal Tab (0x09)</td></tr>
|
||||||
<tr><td>\n</td><td>Line Feed (0x0A)</td></tr>
|
<tr><td>\n&nbsp;</td><td>Line Feed (0x0A)</td></tr>
|
||||||
<tr><td>\v</td><td>Vertical Tab (0x0B)</td></tr>
|
<tr><td>\v&nbsp;</td><td>Vertical Tab (0x0B)</td></tr>
|
||||||
<tr><td>\f</td><td>Form Feed (0x0C)</td></tr>
|
<tr><td>\f&nbsp;</td><td>Form Feed (0x0C)</td></tr>
|
||||||
<tr><td>\r</td><td>Carriage Return (0x0D)</td></tr>
|
<tr><td>\r&nbsp;</td><td>Carriage Return (0x0D)</td></tr>
|
||||||
<tr><td>\e</td><td>Escape (0x1B)</td></tr>
|
<tr><td>\e&nbsp;</td><td>Escape (0x1B)</td></tr>
|
||||||
<tr><td>\G</td><td>Group Selector (0x1D)</td></tr>
|
<tr><td>\G&nbsp;</td><td>Group Selector (0x1D)</td></tr>
|
||||||
<tr><td>\R</td><td>Record Selector (0x1E)</td></tr>
|
<tr><td>\R&nbsp;</td><td>Record Selector (0x1E)</td></tr>
|
||||||
<tr><td>\\</td><td>Backslash (0x5C)</td></tr>
|
<tr><td>\\&nbsp;</td><td>Backslash (0x5C)</td></tr>
|
||||||
<tr><td>\xNN</td><td>8-bit character (N hex)</td></tr>
|
<tr><td>\xNN&nbsp;</td><td>8-bit character (N hex)</td></tr>
|
||||||
<tr><td>\uNNNN</td><td>16-bit Unicode (N hex)</td></tr>
|
<tr><td>\uNNNN&nbsp;</td><td>16-bit Unicode (N hex)</td></tr>
|
||||||
</table></string>
|
</table></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Parse Escapes</string>
|
<string>Parse Es&capes</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
Loading…
Reference in New Issue
Block a user