KOREAPOST missing from is_linear; tests update

This commit is contained in:
gitlost 2019-10-14 09:49:15 +01:00
parent 6e1283ccd8
commit 433046abbf
17 changed files with 1057 additions and 316 deletions

View file

@ -30,10 +30,11 @@
#include "testcommon.h"
//#define TEST_RSS_LINEAR_GENERATE_EXPECTED 1
//#define TEST_RSS_COMPOSITE_GENERATE_EXPECTED 1
extern int general_rules(char type[]);
static void test_linear(void)
//#define TEST_RSS_BINARY_DIV_MODULO_DIVISOR_GENERATE_EXPECTED 1
static void test_binary_div_modulo_divisor(void)
{
testStart("");
@ -44,24 +45,24 @@ static void test_linear(void)
int ret_encode;
float w;
float h;
int ret_render;
int ret_vector;
int expected_rows;
int expected_width;
unsigned char* expected;
};
struct item data[] = {
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 1, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 1, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 1, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 1, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 1, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 1, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 1, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 1, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 8*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 1, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 9*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 1, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/*10*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 1, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 0, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 0, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 0, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 8*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 9*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/*10*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -76,12 +77,10 @@ static void test_linear(void)
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
#ifdef TEST_RSS_LINEAR_GENERATE_EXPECTED
printf("symbology %d, data %s, length %d, rows %d, height %d\n", symbol->symbology, data[i].data, length, symbol->rows, symbol->height);
testUtilModulesDump(symbol);
#ifdef TEST_RSS_BINARY_DIV_MODULO_DIVISOR_GENERATE_EXPECTED
printf(" /*%2d*/ { %s, \"%s\", %d, %.0f, %.0f, %d, %d, %d, ",
i, testUtilBarcodeName(data[i].symbology), data[i].data, ret, data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width);
testUtilModulesDump(symbol, "", " },\n");
#else
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -90,72 +89,9 @@ static void test_linear(void)
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
#endif
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_composite(void)
{
testStart("");
int ret;
struct item {
int symbology;
unsigned char* data;
unsigned char* composite;
int ret_encode;
float w;
float h;
int ret_render;
int expected_rows;
int expected_width;
unsigned char* expected;
};
struct item data[] = {
/* 0*/ { BARCODE_RSS14_CC, "0361234567890", "[11]990102", 0, 100, 30, 1, 5, 100, // TODO: verify expected
"1101101110111010001001110001100110010100000010011101001110100110011110011101110010010000110110001010"
"1101101100111000010011010001000010111110011010011001001011111001000111011111010001101110110010001010"
"1101101000110111110010010001011110100100000010011001101001111000110011011000010111111010111010001010"
"0000000000010110001110100000000101001011010111111011001101010000011010000000010100101000110011110000"
"0000010011101001110001001111111000010100101000000100110010101111100101111111100011010111001100001101"
},
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
struct zint_symbol* symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
int length = strlen(data[i].data);
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
strcpy(symbol->primary, data[i].data);
int composite_length = strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, data[i].composite, composite_length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
ret = ZBarcode_Render( symbol, data[i].w, data[i].h );
assert_equal(ret, data[i].ret_render, "i:%d ZBarcode_Render ret %d != %d\n", i, ret, data[i].ret_render);
#ifdef TEST_RSS_COMPOSITE_GENERATE_EXPECTED
printf("symbology %d, data %s, length %d, rows %d, height %d\n", symbol->symbology, data[i].data, length, symbol->rows, symbol->height);
testUtilModulesDump(symbol);
#else
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);
#endif
ZBarcode_Delete(symbol);
@ -166,8 +102,7 @@ static void test_composite(void)
int main()
{
test_linear();
test_composite();
test_binary_div_modulo_divisor();
testReport();