mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-28 05:54:19 -04:00
GUI: tooltip tables too spaced; tests: Ultracode READER_INIT, more signedness fixes
This commit is contained in:
parent
5a8bbb28f0
commit
0617a5fec0
7 changed files with 104 additions and 47 deletions
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 },
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue