mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-23 19:46:56 -04:00
Add text_length
(length of text
) to zint_symbol
, and new
`BARCODE_PLAIN_HRT` option for `output_options` - for use primarily by ZXing-C++ but may be generally useful; centralize setting of HRT using new common `hrt_cpy_nochk()` etc. routines to ensure `text_length` always set PLESSEY: add show default check characters option CODE32: ignore `option_2` (check digit options) PZN: ignore `option_2` (check digit options) except when indicates PZN7 only DPD: exclude DEL from ident tag also out_maybe_mkdir: fix `utf8_to_wide()` return (Windows only) general: replace use of `strcpy()` etc. (except for test suite) with `memcpy()`, `hrt_()` etc. in lib & `cpy_str()` etc. in CLI & `cpy_bytearray_left()` in backend_qt clang-tidy: update README reflecting above backend_tcl: use sizeof(primary) to check length; tabs -> spaces general: various code fiddling docs: pandoc 3.6.2 -> 3.6.3
This commit is contained in:
parent
ddedd00d2d
commit
fef8b083b4
82 changed files with 2873 additions and 1671 deletions
|
@ -1,7 +1,7 @@
|
|||
/* fuzz.h - common functions for fuzzing libzint */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2024 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2024-2025 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -311,6 +311,8 @@ static const struct settings_item settings[] = {
|
|||
{ 143, BARCODE_UPNQR, 0, 0, -1, 0, -1, ZINT_FULL_MULTIBYTE, 1, 411 },
|
||||
{ 144, BARCODE_ULTRA, 0, -1, 5, 0, 2, ULTRA_COMPRESSION, 1, 504 },
|
||||
{ 145, BARCODE_RMQR, 0, -1, 4, 0, 38, 0, 1, 361 },
|
||||
{ 146, BARCODE_BC412, ARSENIC_F, 0, -1, 0, -1, 0, 7, 18 },
|
||||
{ 147, BARCODE_DXFILMEDGE, SILVER_F, 0, -1, 0, -1, 0, 1, 10 },
|
||||
};
|
||||
|
||||
/* Make sure value `v` is between `min` and `max` */
|
||||
|
|
|
@ -115,39 +115,65 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_C25STANDARD, -1, "123456789", "123456789" },
|
||||
/* 1*/ { BARCODE_C25STANDARD, 1, "123456789", "1234567895" },
|
||||
/* 2*/ { BARCODE_C25STANDARD, 2, "123456789", "123456789" }, /* Suppresses printing of check digit */
|
||||
/* 3*/ { BARCODE_C25INTER, -1, "123456789", "0123456789" }, /* Adds leading zero if odd */
|
||||
/* 4*/ { BARCODE_C25INTER, 1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */
|
||||
/* 5*/ { BARCODE_C25INTER, 2, "123456789", "123456789" },
|
||||
/* 6*/ { BARCODE_C25INTER, -1, "1234567890", "1234567890" }, /* No leading zero if even */
|
||||
/* 7*/ { BARCODE_C25INTER, 1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */
|
||||
/* 8*/ { BARCODE_C25INTER, 2, "1234567890", "01234567890" },
|
||||
/* 9*/ { BARCODE_C25IATA, -1, "123456789", "123456789" },
|
||||
/* 10*/ { BARCODE_C25IATA, 1, "123456789", "1234567895" },
|
||||
/* 11*/ { BARCODE_C25IATA, 2, "123456789", "123456789" },
|
||||
/* 12*/ { BARCODE_C25LOGIC, -1, "123456789", "123456789" },
|
||||
/* 13*/ { BARCODE_C25LOGIC, 1, "123456789", "1234567895" },
|
||||
/* 14*/ { BARCODE_C25LOGIC, 2, "123456789", "123456789" },
|
||||
/* 15*/ { BARCODE_C25IND, -1, "123456789", "123456789" },
|
||||
/* 16*/ { BARCODE_C25IND, 1, "123456789", "1234567895" },
|
||||
/* 17*/ { BARCODE_C25IND, 2, "123456789", "123456789" },
|
||||
/* 18*/ { BARCODE_DPLEIT, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 19*/ { BARCODE_DPLEIT, -1, "1234567890123", "12345.678.901.236" },
|
||||
/* 20*/ { BARCODE_DPIDENT, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 21*/ { BARCODE_DPIDENT, -1, "12345678901", "12.34 5.678.901 6" },
|
||||
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
|
||||
/* 0*/ { BARCODE_C25STANDARD, -1, -1, "123456789", "123456789" },
|
||||
/* 1*/ { BARCODE_C25STANDARD, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
|
||||
/* 2*/ { BARCODE_C25STANDARD, 1, -1, "123456789", "1234567895" },
|
||||
/* 3*/ { BARCODE_C25STANDARD, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 4*/ { BARCODE_C25STANDARD, 2, -1, "123456789", "123456789" }, /* Suppresses printing of check digit */
|
||||
/* 5*/ { BARCODE_C25STANDARD, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" }, /* Unless plain HRT */
|
||||
/* 6*/ { BARCODE_C25INTER, -1, -1, "123456789", "0123456789" }, /* Adds leading zero if odd */
|
||||
/* 6*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "123456789", "0123456789" },
|
||||
/* 7*/ { BARCODE_C25INTER, 1, -1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */
|
||||
/* 8*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 9*/ { BARCODE_C25INTER, 2, -1, "123456789", "123456789" },
|
||||
/* 10*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 11*/ { BARCODE_C25INTER, -1, -1, "1234567890", "1234567890" }, /* No leading zero if even */
|
||||
/* 12*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "1234567890", "1234567890" },
|
||||
/* 13*/ { BARCODE_C25INTER, 1, -1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */
|
||||
/* 14*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
|
||||
/* 15*/ { BARCODE_C25INTER, 2, -1, "1234567890", "01234567890" },
|
||||
/* 16*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
|
||||
/* 17*/ { BARCODE_C25IATA, -1, -1, "123456789", "123456789" },
|
||||
/* 18*/ { BARCODE_C25IATA, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
|
||||
/* 19*/ { BARCODE_C25IATA, 1, -1, "123456789", "1234567895" },
|
||||
/* 20*/ { BARCODE_C25IATA, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 21*/ { BARCODE_C25IATA, 2, -1, "123456789", "123456789" },
|
||||
/* 22*/ { BARCODE_C25IATA, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 23*/ { BARCODE_C25LOGIC, -1, -1, "123456789", "123456789" },
|
||||
/* 24*/ { BARCODE_C25LOGIC, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
|
||||
/* 25*/ { BARCODE_C25LOGIC, 1, -1, "123456789", "1234567895" },
|
||||
/* 26*/ { BARCODE_C25LOGIC, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 27*/ { BARCODE_C25LOGIC, 2, -1, "123456789", "123456789" },
|
||||
/* 28*/ { BARCODE_C25LOGIC, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 29*/ { BARCODE_C25IND, -1, -1, "123456789", "123456789" },
|
||||
/* 30*/ { BARCODE_C25IND, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
|
||||
/* 31*/ { BARCODE_C25IND, 1, -1, "123456789", "1234567895" },
|
||||
/* 32*/ { BARCODE_C25IND, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 33*/ { BARCODE_C25IND, 2, -1, "123456789", "123456789" },
|
||||
/* 34*/ { BARCODE_C25IND, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
|
||||
/* 35*/ { BARCODE_DPLEIT, -1, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 36*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567890" },
|
||||
/* 37*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345.678.901.236" },
|
||||
/* 38*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901236" },
|
||||
/* 39*/ { BARCODE_DPIDENT, -1, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
|
||||
/* 40*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "123456789", "001234567890" },
|
||||
/* 41*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "12.34 5.678.901 6" },
|
||||
/* 42*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "12345678901", "123456789016" },
|
||||
/* 43*/ { BARCODE_ITF14, -1, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
|
||||
/* 44*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567895" },
|
||||
/* 45*/ { BARCODE_ITF14, -1, -1, "1234567890123", "12345678901231" },
|
||||
/* 46*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901231" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -158,12 +184,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -100,17 +100,42 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int symbology;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_AUSPOST, "12345678901234567890123", "" }, /* None */
|
||||
/* 0*/ { BARCODE_AUSPOST, -1, "12345678", "" }, /* None */
|
||||
/* 1*/ { BARCODE_AUSPOST, BARCODE_PLAIN_HRT, "12345678", "1112345678" },
|
||||
/* 2*/ { BARCODE_AUSPOST, -1, "1234567890123", "" }, /* None */
|
||||
/* 3*/ { BARCODE_AUSPOST, BARCODE_PLAIN_HRT, "1234567890123", "591234567890123" },
|
||||
/* 4*/ { BARCODE_AUSPOST, -1, "1234567890123456", "" }, /* None */
|
||||
/* 5*/ { BARCODE_AUSPOST, BARCODE_PLAIN_HRT, "1234567890123456", "591234567890123456" },
|
||||
/* 6*/ { BARCODE_AUSPOST, -1, "123456789012345678", "" }, /* None */
|
||||
/* 7*/ { BARCODE_AUSPOST, BARCODE_PLAIN_HRT, "123456789012345678", "62123456789012345678" },
|
||||
/* 8*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "" }, /* None */
|
||||
/* 9*/ { BARCODE_AUSPOST, BARCODE_PLAIN_HRT, "12345678901234567890123", "6212345678901234567890123" },
|
||||
/* 10*/ { BARCODE_AUSREPLY, -1, "1234567", "" }, /* None */
|
||||
/* 11*/ { BARCODE_AUSREPLY, BARCODE_PLAIN_HRT, "1234567", "4501234567" },
|
||||
/* 12*/ { BARCODE_AUSREPLY, -1, "12345678", "" }, /* None */
|
||||
/* 13*/ { BARCODE_AUSREPLY, BARCODE_PLAIN_HRT, "12345678", "4512345678" },
|
||||
/* 14*/ { BARCODE_AUSROUTE, -1, "123456", "" }, /* None */
|
||||
/* 15*/ { BARCODE_AUSROUTE, BARCODE_PLAIN_HRT, "123456", "8700123456" },
|
||||
/* 16*/ { BARCODE_AUSROUTE, -1, "12345678", "" }, /* None */
|
||||
/* 17*/ { BARCODE_AUSROUTE, BARCODE_PLAIN_HRT, "12345678", "8712345678" },
|
||||
/* 18*/ { BARCODE_AUSROUTE, -1, "12345", "" }, /* None */
|
||||
/* 19*/ { BARCODE_AUSROUTE, BARCODE_PLAIN_HRT, "12345", "8700012345" },
|
||||
/* 20*/ { BARCODE_AUSREDIRECT, -1, "12345678", "" }, /* None */
|
||||
/* 21*/ { BARCODE_AUSREDIRECT, BARCODE_PLAIN_HRT, "12345678", "9212345678" },
|
||||
/* 22*/ { BARCODE_AUSREDIRECT, -1, "1234", "" }, /* None */
|
||||
/* 23*/ { BARCODE_AUSREDIRECT, BARCODE_PLAIN_HRT, "1234", "9200001234" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -121,12 +146,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
int ret;
|
||||
|
@ -48,32 +47,39 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, -1, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 792: Input length 6 too short (minimum 7)", "" },
|
||||
/* 1*/ { UNICODE_MODE, -1, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input length 19 too long (maximum 18)", "" },
|
||||
/* 2*/ { UNICODE_MODE, -1, -1, "1234567", -1, 0, 1, 102, "1U234567", "" },
|
||||
/* 3*/ { UNICODE_MODE, -1, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 8 in input (alphanumerics only, excluding \"O\")", "" },
|
||||
/* 4*/ { UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 15 in input (alphanumerics only, excluding \"O\")", "" },
|
||||
/* 5*/ { UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
|
||||
/* 6*/ { UNICODE_MODE, -1, -1, "STUVWXYZ1234567890", -1, 0, 1, 234, "SCTUVWXYZ1234567890", "" },
|
||||
/* 7*/ { UNICODE_MODE, -1, -1, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
|
||||
/* 8*/ { UNICODE_MODE, -1, -1, "123456789012345678", -1, 0, 1, 234, "1223456789012345678", "" },
|
||||
/* 9*/ { UNICODE_MODE, -1, -1, "MMMMMMMMMMMMMMMMMM", -1, 0, 1, 234, "MTMMMMMMMMMMMMMMMMM", "" },
|
||||
/* 10*/ { UNICODE_MODE, -1, -1, "00000000", -1, 0, 1, 114, "000000000", "" },
|
||||
/* 11*/ { UNICODE_MODE, -1, -1, "000000000", -1, 0, 1, 126, "0000000000", "" },
|
||||
/* 12*/ { UNICODE_MODE, -1, -1, "000S0S000S", -1, 0, 1, 138, "0S00S0S000S", "" },
|
||||
/* 13*/ { UNICODE_MODE, -1, -1, "ZYXWVUTSRQP", -1, 0, 1, 150, "Z0YXWVUTSRQP", "" },
|
||||
/* 14*/ { UNICODE_MODE, -1, -1, "0R9GLVHA8EZ4", -1, 0, 1, 162, "0DR9GLVHA8EZ4", "" },
|
||||
/* 15*/ { UNICODE_MODE, -1, -1, "NTS1J2Q6C7DYK", -1, 0, 1, 174, "NRTS1J2Q6C7DYK", "" },
|
||||
/* 16*/ { UNICODE_MODE, -1, -1, "TS1J2Q6C7DYKBU", -1, 0, 1, 186, "TWS1J2Q6C7DYKBU", "" },
|
||||
/* 17*/ { UNICODE_MODE, -1, -1, "IX3FWP5M0R9GLVH", -1, 0, 1, 198, "IBX3FWP5M0R9GLVH", "" },
|
||||
/* 18*/ { UNICODE_MODE, -1, -1, "R9GLVHA8EZ4NTS1J", -1, 0, 1, 210, "RY9GLVHA8EZ4NTS1J", "" },
|
||||
/* 19*/ { UNICODE_MODE, -1, -1, "M5PWF3XIUBKYD7C6Q", -1, 0, 1, 222, "M35PWF3XIUBKYD7C6Q", "" },
|
||||
/* 20*/ { UNICODE_MODE, -1, -1, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "" },
|
||||
/* 21*/ { UNICODE_MODE, -1, -1, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" },
|
||||
/* 0*/ { UNICODE_MODE, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 792: Input length 6 too short (minimum 7)", "" },
|
||||
/* 1*/ { UNICODE_MODE, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input length 19 too long (maximum 18)", "" },
|
||||
/* 2*/ { UNICODE_MODE, -1, "1234567", -1, 0, 1, 102, "1U234567", "" },
|
||||
/* 3*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "1234567", -1, 0, 1, 102, "1U234567", "" }, /* No difference */
|
||||
/* 4*/ { UNICODE_MODE, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 8 in input (alphanumerics only, excluding \"O\")", "" },
|
||||
/* 5*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 15 in input (alphanumerics only, excluding \"O\")", "" },
|
||||
/* 6*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
|
||||
/* 7*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* No difference */
|
||||
/* 8*/ { UNICODE_MODE, -1, "STUVWXYZ1234567890", -1, 0, 1, 234, "SCTUVWXYZ1234567890", "" },
|
||||
/* 9*/ { UNICODE_MODE, -1, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
|
||||
/* 10*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" }, /* No difference */
|
||||
/* 11*/ { UNICODE_MODE, -1, "123456789012345678", -1, 0, 1, 234, "1223456789012345678", "" },
|
||||
/* 12*/ { UNICODE_MODE, -1, "MMMMMMMMMMMMMMMMMM", -1, 0, 1, 234, "MTMMMMMMMMMMMMMMMMM", "" },
|
||||
/* 13*/ { UNICODE_MODE, -1, "00000000", -1, 0, 1, 114, "000000000", "" },
|
||||
/* 14*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "00000000", -1, 0, 1, 114, "000000000", "" }, /* No difference */
|
||||
/* 15*/ { UNICODE_MODE, -1, "000000000", -1, 0, 1, 126, "0000000000", "" },
|
||||
/* 16*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "000000000", -1, 0, 1, 126, "0000000000", "" }, /* No difference */
|
||||
/* 17*/ { UNICODE_MODE, -1, "000S0S000S", -1, 0, 1, 138, "0S00S0S000S", "" },
|
||||
/* 18*/ { UNICODE_MODE, -1, "ZYXWVUTSRQP", -1, 0, 1, 150, "Z0YXWVUTSRQP", "" },
|
||||
/* 19*/ { UNICODE_MODE, -1, "0R9GLVHA8EZ4", -1, 0, 1, 162, "0DR9GLVHA8EZ4", "" },
|
||||
/* 20*/ { UNICODE_MODE, -1, "NTS1J2Q6C7DYK", -1, 0, 1, 174, "NRTS1J2Q6C7DYK", "" },
|
||||
/* 21*/ { UNICODE_MODE, -1, "TS1J2Q6C7DYKBU", -1, 0, 1, 186, "TWS1J2Q6C7DYKBU", "" },
|
||||
/* 22*/ { UNICODE_MODE, -1, "IX3FWP5M0R9GLVH", -1, 0, 1, 198, "IBX3FWP5M0R9GLVH", "" },
|
||||
/* 23*/ { UNICODE_MODE, -1, "R9GLVHA8EZ4NTS1J", -1, 0, 1, 210, "RY9GLVHA8EZ4NTS1J", "" },
|
||||
/* 24*/ { UNICODE_MODE, -1, "M5PWF3XIUBKYD7C6Q", -1, 0, 1, 222, "M35PWF3XIUBKYD7C6Q", "" },
|
||||
/* 25*/ { UNICODE_MODE, -1, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "" },
|
||||
/* 26*/ { UNICODE_MODE, -1, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" },
|
||||
/* 27*/ { UNICODE_MODE, BARCODE_PLAIN_HRT, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" }, /* No difference */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
char bwipp_buf[8192];
|
||||
char bwipp_msg[1024];
|
||||
|
@ -89,20 +95,28 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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 (ret < ZINT_ERROR) {
|
||||
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((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
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_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, modules_dump);
|
||||
|
@ -124,8 +138,6 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int input_mode;
|
||||
int option_1;
|
||||
int option_2;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
|
@ -136,10 +148,10 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
const char *expected;
|
||||
};
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { UNICODE_MODE, -1, -1, "AQ45670", 0, 1, 102, 1, "SEMI T1-95 Figure 2, same",
|
||||
/* 0*/ { UNICODE_MODE, "AQ45670", 0, 1, 102, 1, "SEMI T1-95 Figure 2, same",
|
||||
"100101000100100100010101000100010101000101010000010101001010000101001001000101001000100101010100000101"
|
||||
},
|
||||
/* 1*/ { UNICODE_MODE, -1, -1, "A6BC1234", 0, 1, 114, 1, "https://www.grapecity.co.jp, same",
|
||||
/* 1*/ { UNICODE_MODE, "A6BC1234", 0, 1, 114, 1, "https://www.grapecity.co.jp, same",
|
||||
"100101000100100100100010100101001001000101000100010101000010100101010010000101010001000101010000100101010000010101"
|
||||
},
|
||||
};
|
||||
|
@ -162,14 +174,14 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_BC412, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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 (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
||||
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
|
||||
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, %d, \"%s\",\n",
|
||||
i, testUtilInputModeName(data[i].input_mode),
|
||||
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment);
|
||||
testUtilModulesPrint(symbol, " ", "\n");
|
||||
|
@ -184,11 +196,11 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, data[i].option_1, -1, -1, debug)) {
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
||||
if (!data[i].bwipp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
} else {
|
||||
ret = testUtilBwipp(i, symbol, data[i].option_1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
||||
|
|
|
@ -36,6 +36,7 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
|
||||
|
@ -43,31 +44,43 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { -1, "1", -1, "01" },
|
||||
/* 1*/ { 3, "1", -1, "01" },
|
||||
/* 2*/ { 3, "12", -1, "12" },
|
||||
/* 3*/ { 4, "123", -1, "123" },
|
||||
/* 4*/ { 5, "123", -1, "0123" },
|
||||
/* 5*/ { 5, "12", -1, "0012" },
|
||||
/* 6*/ { 5, "1", -1, "0001" },
|
||||
/* 7*/ { 5, "1234", -1, "1234" },
|
||||
/* 8*/ { 6, "1234", -1, "01234" },
|
||||
/* 9*/ { 6, "123", -1, "00123" },
|
||||
/* 10*/ { 6, "12", -1, "00012" },
|
||||
/* 11*/ { 6, "1", -1, "00001" },
|
||||
/* 12*/ { 7, "1234", -1, "001234" },
|
||||
/* 13*/ { 7, "12345", -1, "012345" },
|
||||
/* 14*/ { 7, "123456", -1, "123456" },
|
||||
/* 15*/ { 7, "1", -1, "000001" },
|
||||
/* 16*/ { 8, "12345", -1, "0012345" },
|
||||
/* 17*/ { 8, "123456", -1, "0123456" },
|
||||
/* 18*/ { 8, "1234567", -1, "1234567" },
|
||||
/* 19*/ { 8, "12", -1, "0000012" },
|
||||
/* 20*/ { 8, "1", -1, "0000001" },
|
||||
/* 0*/ { -1, -1, "1", -1, "01" },
|
||||
/* 1*/ { -1, BARCODE_PLAIN_HRT, "1", -1, "01" }, /* No difference */
|
||||
/* 2*/ { 3, -1, "1", -1, "01" },
|
||||
/* 3*/ { 3, BARCODE_PLAIN_HRT, "1", -1, "01" },
|
||||
/* 4*/ { 3, -1, "12", -1, "12" },
|
||||
/* 5*/ { 3, BARCODE_PLAIN_HRT, "12", -1, "12" },
|
||||
/* 6*/ { 4, -1, "123", -1, "123" },
|
||||
/* 7*/ { 4, BARCODE_PLAIN_HRT, "123", -1, "123" },
|
||||
/* 8*/ { 5, -1, "123", -1, "0123" },
|
||||
/* 9*/ { 5, BARCODE_PLAIN_HRT, "123", -1, "0123" },
|
||||
/* 10*/ { 5, -1, "12", -1, "0012" },
|
||||
/* 11*/ { 5, BARCODE_PLAIN_HRT, "12", -1, "0012" },
|
||||
/* 12*/ { 5, -1, "1", -1, "0001" },
|
||||
/* 13*/ { 5, -1, "1234", -1, "1234" },
|
||||
/* 14*/ { 6, -1, "1234", -1, "01234" },
|
||||
/* 15*/ { 6, -1, "123", -1, "00123" },
|
||||
/* 16*/ { 6, -1, "12", -1, "00012" },
|
||||
/* 17*/ { 6, -1, "1", -1, "00001" },
|
||||
/* 18*/ { 7, -1, "1234", -1, "001234" },
|
||||
/* 19*/ { 7, -1, "12345", -1, "012345" },
|
||||
/* 20*/ { 7, -1, "123456", -1, "123456" },
|
||||
/* 21*/ { 7, -1, "1", -1, "000001" },
|
||||
/* 22*/ { 8, -1, "12345", -1, "0012345" },
|
||||
/* 23*/ { 8, BARCODE_PLAIN_HRT, "12345", -1, "0012345" },
|
||||
/* 24*/ { 8, -1, "123456", -1, "0123456" },
|
||||
/* 25*/ { 8, BARCODE_PLAIN_HRT, "123456", -1, "0123456" },
|
||||
/* 26*/ { 8, -1, "1234567", -1, "1234567" },
|
||||
/* 27*/ { 8, BARCODE_PLAIN_HRT, "1234567", -1, "1234567" },
|
||||
/* 28*/ { 8, -1, "12", -1, "0000012" },
|
||||
/* 29*/ { 8, BARCODE_PLAIN_HRT, "12", -1, "0000012" },
|
||||
/* 30*/ { 8, -1, "1", -1, "0000001" },
|
||||
/* 31*/ { 8, BARCODE_PLAIN_HRT, "1", -1, "0000001" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -78,12 +91,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_CHANNEL, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -92,22 +92,30 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODABAR, -1, "A1234B", "A1234B" },
|
||||
/* 1*/ { BARCODE_CODABAR, -1, "a1234c", "A1234C" }, /* Converts to upper */
|
||||
/* 2*/ { BARCODE_CODABAR, 1, "A1234B", "A1234B" }, /* Check not included */
|
||||
/* 3*/ { BARCODE_CODABAR, 2, "A1234B", "A12345B" }, /* Check included */
|
||||
/* 4*/ { BARCODE_CODABAR, 1, "A123456A", "A123456A" }, /* Check not included */
|
||||
/* 5*/ { BARCODE_CODABAR, 2, "A123456A", "A123456$A" }, /* Check included */
|
||||
/* 0*/ { BARCODE_CODABAR, -1, -1, "A1234B", "A1234B" },
|
||||
/* 1*/ { BARCODE_CODABAR, -1, BARCODE_PLAIN_HRT, "A1234B", "A1234B" },
|
||||
/* 2*/ { BARCODE_CODABAR, -1, -1, "a1234c", "A1234C" }, /* Converts to upper */
|
||||
/* 3*/ { BARCODE_CODABAR, -1, BARCODE_PLAIN_HRT, "a1234c", "A1234C" },
|
||||
/* 4*/ { BARCODE_CODABAR, 1, -1, "A1234B", "A1234B" }, /* Check not included */
|
||||
/* 5*/ { BARCODE_CODABAR, 1, BARCODE_PLAIN_HRT, "A1234B", "A12345B" },
|
||||
/* 6*/ { BARCODE_CODABAR, 2, -1, "A1234B", "A12345B" }, /* Check included */
|
||||
/* 7*/ { BARCODE_CODABAR, 2, BARCODE_PLAIN_HRT, "A1234B", "A12345B" },
|
||||
/* 8*/ { BARCODE_CODABAR, 1, -1, "A123456A", "A123456A" }, /* Check not included */
|
||||
/* 9*/ { BARCODE_CODABAR, 1, BARCODE_PLAIN_HRT, "A123456A", "A123456$A" },
|
||||
/* 10*/ { BARCODE_CODABAR, 2, -1, "A123456A", "A123456$A" }, /* Check included */
|
||||
/* 11*/ { BARCODE_CODABAR, 2, BARCODE_PLAIN_HRT, "A123456A", "A123456$A" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -118,12 +126,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -254,6 +254,58 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_hrt(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_1;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, "12345623456", "" }, /* None */
|
||||
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, BARCODE_PLAIN_HRT, "12345623456", "" }, /* No difference */
|
||||
/* 2*/ { BARCODE_CODABLOCKF, 1, -1, -1, "12345623456", "" }, /* None (CODE128) */
|
||||
/* 3*/ { BARCODE_CODABLOCKF, 1, -1, BARCODE_PLAIN_HRT, "12345623456", "" }, /* No difference */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
data[i].option_1, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
|
||||
i, symbol->text, data[i].expected, expected_length);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_input(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
|
@ -681,6 +733,7 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_large", test_large },
|
||||
{ "test_options", test_options },
|
||||
{ "test_reader_init", test_reader_init },
|
||||
{ "test_hrt", test_hrt },
|
||||
{ "test_input", test_input },
|
||||
{ "test_encode", test_encode },
|
||||
{ "test_fuzz", test_fuzz },
|
||||
|
|
|
@ -111,47 +111,84 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
|
||||
const char *expected;
|
||||
int expected_length;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE39, -1, "ABC1234", -1, "*ABC1234*" },
|
||||
/* 1*/ { BARCODE_CODE39, 1, "ABC1234", -1, "*ABC12340*" }, /* With visible check digit */
|
||||
/* 2*/ { BARCODE_CODE39, -1, "abc1234", -1, "*ABC1234*" }, /* Converts to upper */
|
||||
/* 3*/ { BARCODE_CODE39, 1, "abc1234", -1, "*ABC12340*" }, /* Converts to upper */
|
||||
/* 4*/ { BARCODE_CODE39, -1, "123456789", -1, "*123456789*" },
|
||||
/* 5*/ { BARCODE_CODE39, 1, "123456789", -1, "*1234567892*" }, /* With visible check digit */
|
||||
/* 6*/ { BARCODE_CODE39, 2, "123456789", -1, "*123456789*" }, /* With hidden check digit */
|
||||
/* 7*/ { BARCODE_EXCODE39, -1, "ABC1234", -1, "ABC1234" },
|
||||
/* 8*/ { BARCODE_EXCODE39, 1, "ABC1234", -1, "ABC12340" }, /* With visible check digit */
|
||||
/* 9*/ { BARCODE_EXCODE39, -1, "abc1234", -1, "abc1234" },
|
||||
/* 10*/ { BARCODE_EXCODE39, 1, "abc1234", -1, "abc1234." }, /* With visible check digit (previously was hidden) */
|
||||
/* 11*/ { BARCODE_EXCODE39, 2, "abc1234", -1, "abc1234" }, /* With hidden check digit */
|
||||
/* 12*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~" }, /* NUL, ctrls and DEL replaced with spaces */
|
||||
/* 13*/ { BARCODE_EXCODE39, 1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~L" }, /* With visible check digit */
|
||||
/* 14*/ { BARCODE_EXCODE39, 2, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~" }, /* With hidden check digit */
|
||||
/* 15*/ { BARCODE_LOGMARS, -1, "ABC1234", -1, "ABC1234" },
|
||||
/* 16*/ { BARCODE_LOGMARS, -1, "abc1234", -1, "ABC1234" }, /* Converts to upper */
|
||||
/* 17*/ { BARCODE_LOGMARS, 1, "abc1234", -1, "ABC12340" }, /* With check digit */
|
||||
/* 18*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, "12345/ABCDET" }, /* With visible check digit */
|
||||
/* 19*/ { BARCODE_LOGMARS, 2, "12345/ABCDE", -1, "12345/ABCDE" }, /* With hidden check digit */
|
||||
/* 20*/ { BARCODE_CODE93, -1, "ABC1234", -1, "ABC1234" }, /* No longer shows 2 check chars added (same as BWIPP and TEC-IT) */
|
||||
/* 21*/ { BARCODE_CODE93, 1, "ABC1234", -1, "ABC1234S5" }, /* Unless requested */
|
||||
/* 22*/ { BARCODE_CODE93, -1, "abc1234", -1, "abc1234" },
|
||||
/* 23*/ { BARCODE_CODE93, 1, "abc1234", -1, "abc1234ZG" },
|
||||
/* 24*/ { BARCODE_CODE93, -1, "A\001a\000b\177d\037e", 9, "A a b d e" }, /* NUL, ctrls and DEL replaced with spaces */
|
||||
/* 25*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180" },
|
||||
/* 26*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511" }, /* Include Import char - no change */
|
||||
/* 27*/ { BARCODE_HIBC_39, -1, "ABC1234", -1, "*+ABC1234+*" },
|
||||
/* 28*/ { BARCODE_HIBC_39, -1, "abc1234", -1, "*+ABC1234+*" }, /* Converts to upper */
|
||||
/* 29*/ { BARCODE_HIBC_39, -1, "123456789", -1, "*+1234567890*" },
|
||||
/* 0*/ { BARCODE_CODE39, -1, -1, "ABC1234", -1, "*ABC1234*", -1 },
|
||||
/* 1*/ { BARCODE_CODE39, -1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC1234", -1 },
|
||||
/* 2*/ { BARCODE_CODE39, 1, -1, "ABC1234", -1, "*ABC12340*", -1 }, /* With visible check digit */
|
||||
/* 3*/ { BARCODE_CODE39, 1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC12340", -1 },
|
||||
/* 4*/ { BARCODE_CODE39, -1, -1, "abc1234", -1, "*ABC1234*", -1 }, /* Converts to upper */
|
||||
/* 5*/ { BARCODE_CODE39, -1, BARCODE_PLAIN_HRT, "abc1234", -1, "ABC1234", -1 },
|
||||
/* 6*/ { BARCODE_CODE39, 1, -1, "abc1234", -1, "*ABC12340*", -1 }, /* Converts to upper */
|
||||
/* 7*/ { BARCODE_CODE39, 1, BARCODE_PLAIN_HRT, "abc1234", -1, "ABC12340", -1 },
|
||||
/* 8*/ { BARCODE_CODE39, 1, -1, "ab", -1, "*ABL*", -1 }, /* Converts to upper */
|
||||
/* 9*/ { BARCODE_CODE39, 1, BARCODE_PLAIN_HRT, "ab", -1, "ABL", -1 },
|
||||
/* 10*/ { BARCODE_CODE39, -1, -1, "123456789", -1, "*123456789*", -1 },
|
||||
/* 11*/ { BARCODE_CODE39, -1, BARCODE_PLAIN_HRT, "123456789", -1, "123456789", -1 },
|
||||
/* 12*/ { BARCODE_CODE39, 1, -1, "123456789", -1, "*1234567892*", -1 }, /* With visible check digit */
|
||||
/* 13*/ { BARCODE_CODE39, 1, BARCODE_PLAIN_HRT, "123456789", -1, "1234567892", -1 },
|
||||
/* 14*/ { BARCODE_CODE39, 2, -1, "123456789", -1, "*123456789*", -1 }, /* With hidden check digit */
|
||||
/* 15*/ { BARCODE_CODE39, 2, BARCODE_PLAIN_HRT, "123456789", -1, "1234567892", -1 }, /* Includes check digit */
|
||||
/* 16*/ { BARCODE_EXCODE39, -1, -1, "ABC1234", -1, "ABC1234", -1 },
|
||||
/* 17*/ { BARCODE_EXCODE39, -1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC1234", -1 },
|
||||
/* 18*/ { BARCODE_EXCODE39, 1, -1, "ABC1234", -1, "ABC12340", -1 }, /* With visible check digit */
|
||||
/* 19*/ { BARCODE_EXCODE39, 1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC12340", -1 },
|
||||
/* 20*/ { BARCODE_EXCODE39, -1, -1, "abc1234", -1, "abc1234", -1 },
|
||||
/* 21*/ { BARCODE_EXCODE39, -1, BARCODE_PLAIN_HRT, "abc1234", -1, "abc1234", -1 },
|
||||
/* 22*/ { BARCODE_EXCODE39, 1, -1, "abc1234", -1, "abc1234.", -1 }, /* With visible check digit (previously was hidden) */
|
||||
/* 23*/ { BARCODE_EXCODE39, 1, BARCODE_PLAIN_HRT, "abc1234", -1, "abc1234.", -1 },
|
||||
/* 24*/ { BARCODE_EXCODE39, 2, -1, "abc1234", -1, "abc1234", -1 }, /* With hidden check digit */
|
||||
/* 25*/ { BARCODE_EXCODE39, 2, BARCODE_PLAIN_HRT, "abc1234", -1, "abc1234.", -1 }, /* Includes check digit */
|
||||
/* 26*/ { BARCODE_EXCODE39, -1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1 }, /* NUL, ctrls and DEL replaced with spaces */
|
||||
/* 27*/ { BARCODE_EXCODE39, -1, BARCODE_PLAIN_HRT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~", 16 }, /* No replacements */
|
||||
/* 28*/ { BARCODE_EXCODE39, 1, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~L", -1 }, /* With visible check digit */
|
||||
/* 29*/ { BARCODE_EXCODE39, 1, BARCODE_PLAIN_HRT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~L", 17 },
|
||||
/* 30*/ { BARCODE_EXCODE39, 2, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~", -1 }, /* With hidden check digit */
|
||||
/* 31*/ { BARCODE_EXCODE39, 2, BARCODE_PLAIN_HRT, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a%\000\001$\177z\033\037!+/\\@A~L", 17 }, /* Includes check digit */
|
||||
/* 32*/ { BARCODE_LOGMARS, -1, -1, "ABC1234", -1, "ABC1234", -1 },
|
||||
/* 33*/ { BARCODE_LOGMARS, -1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC1234", -1 },
|
||||
/* 34*/ { BARCODE_LOGMARS, -1, -1, "abc1234", -1, "ABC1234", -1 }, /* Converts to upper */
|
||||
/* 35*/ { BARCODE_LOGMARS, -1, BARCODE_PLAIN_HRT, "abc1234", -1, "ABC1234", -1 },
|
||||
/* 36*/ { BARCODE_LOGMARS, 1, -1, "abc1234", -1, "ABC12340", -1 }, /* With check digit */
|
||||
/* 37*/ { BARCODE_LOGMARS, 1, BARCODE_PLAIN_HRT, "abc1234", -1, "ABC12340", -1 },
|
||||
/* 38*/ { BARCODE_LOGMARS, 1, -1, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* With visible check digit */
|
||||
/* 39*/ { BARCODE_LOGMARS, 1, BARCODE_PLAIN_HRT, "12345/ABCDE", -1, "12345/ABCDET", -1 },
|
||||
/* 40*/ { BARCODE_LOGMARS, 2, -1, "12345/ABCDE", -1, "12345/ABCDE", -1 }, /* With hidden check digit */
|
||||
/* 41*/ { BARCODE_LOGMARS, 2, BARCODE_PLAIN_HRT, "12345/ABCDE", -1, "12345/ABCDET", -1 }, /* Includes check digit */
|
||||
/* 42*/ { BARCODE_CODE93, -1, -1, "ABC1234", -1, "ABC1234", -1 }, /* No longer shows 2 check chars added (same as BWIPP and TEC-IT) */
|
||||
/* 43*/ { BARCODE_CODE93, -1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC1234S5", -1 }, /* Unless BARCODE_PLAIN_HRT */
|
||||
/* 44*/ { BARCODE_CODE93, 1, -1, "ABC1234", -1, "ABC1234S5", -1 }, /* Unless requested */
|
||||
/* 45*/ { BARCODE_CODE93, 1, BARCODE_PLAIN_HRT, "ABC1234", -1, "ABC1234S5", -1 },
|
||||
/* 46*/ { BARCODE_CODE93, -1, -1, "abc1234", -1, "abc1234", -1 },
|
||||
/* 47*/ { BARCODE_CODE93, -1, BARCODE_PLAIN_HRT, "abc1234", -1, "abc1234ZG", -1 },
|
||||
/* 48*/ { BARCODE_CODE93, 1, -1, "abc1234", -1, "abc1234ZG", -1 },
|
||||
/* 49*/ { BARCODE_CODE93, 1, BARCODE_PLAIN_HRT, "abc1234", -1, "abc1234ZG", -1 },
|
||||
/* 50*/ { BARCODE_CODE93, -1, -1, "A\001a\000b\177d\037e", 9, "A a b d e", -1 }, /* NUL, ctrls and DEL replaced with spaces */
|
||||
/* 51*/ { BARCODE_CODE93, -1, BARCODE_PLAIN_HRT, "A\001a\000b\177d\037e", 9, "A\001a\000b\177d\037e1R", 11 }, /* No replacements */
|
||||
/* 52*/ { BARCODE_CODE93, 1, -1, "A\001a\000b\177d\037e", 9, "A a b d e1R", -1 },
|
||||
/* 53*/ { BARCODE_CODE93, 1, BARCODE_PLAIN_HRT, "A\001a\000b\177d\037e", 9, "A\001a\000b\177d\037e1R", 11 },
|
||||
/* 54*/ { BARCODE_VIN, -1, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1 },
|
||||
/* 55*/ { BARCODE_VIN, -1, BARCODE_PLAIN_HRT, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180", -1 },
|
||||
/* 56*/ { BARCODE_VIN, 1, -1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511", -1 }, /* Include Import char - no change */
|
||||
/* 57*/ { BARCODE_VIN, 1, BARCODE_PLAIN_HRT, "2FTPX28L0XCA15511", -1, "I2FTPX28L0XCA15511", -1 }, /* Unless BARCODE_PLAIN_HRT */
|
||||
/* 58*/ { BARCODE_HIBC_39, -1, -1, "ABC1234", -1, "*+ABC1234+*", -1 },
|
||||
/* 59*/ { BARCODE_HIBC_39, -1, BARCODE_PLAIN_HRT, "ABC1234", -1, "+ABC1234+", -1 },
|
||||
/* 60*/ { BARCODE_HIBC_39, -1, -1, "abc1234", -1, "*+ABC1234+*", -1 }, /* Converts to upper */
|
||||
/* 61*/ { BARCODE_HIBC_39, -1, BARCODE_PLAIN_HRT, "abc1234", -1, "+ABC1234+", -1 },
|
||||
/* 62*/ { BARCODE_HIBC_39, -1, -1, "123456789", -1, "*+1234567890*", -1 },
|
||||
/* 63*/ { BARCODE_HIBC_39, -1, BARCODE_PLAIN_HRT, "123456789", -1, "+1234567890", -1 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -162,12 +199,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
|
||||
i, symbol->text, data[i].expected, expected_length);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
|
||||
|
@ -100,14 +101,19 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, "123-4552" }, /* 2 checksums */
|
||||
/* 1*/ { BARCODE_CODE11, 1, "123-45", -1, "123-455" }, /* 1 check digit */
|
||||
/* 2*/ { BARCODE_CODE11, 2, "123-45", -1, "123-45" }, /* No checksums */
|
||||
/* 3*/ { BARCODE_CODE11, -1, "123456789012", -1, "123456789012-8" }, /* First check digit 10 (A) goes to hyphen */
|
||||
/* 0*/ { BARCODE_CODE11, -1, -1, "123-45", -1, "123-4552" }, /* 2 checksums */
|
||||
/* 1*/ { BARCODE_CODE11, -1, BARCODE_PLAIN_HRT, "123-45", -1, "123-4552" }, /* No difference */
|
||||
/* 2*/ { BARCODE_CODE11, 1, -1, "123-45", -1, "123-455" }, /* 1 check digit */
|
||||
/* 3*/ { BARCODE_CODE11, 1, BARCODE_PLAIN_HRT, "123-45", -1, "123-455" }, /* No difference */
|
||||
/* 4*/ { BARCODE_CODE11, 2, -1, "123-45", -1, "123-45" }, /* No checksums */
|
||||
/* 5*/ { BARCODE_CODE11, 2, BARCODE_PLAIN_HRT, "123-45", -1, "123-45" }, /* No difference */
|
||||
/* 6*/ { BARCODE_CODE11, -1, -1, "123456789012", -1, "123456789012-8" }, /* First check digit 10 (A) goes to hyphen */
|
||||
/* 7*/ { BARCODE_CODE11, -1, BARCODE_PLAIN_HRT, "123456789012", -1, "123456789012-8" }, /* No difference */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -118,12 +124,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -176,63 +176,84 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
int symbology;
|
||||
int input_mode;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
|
||||
const char *expected;
|
||||
int expected_length;
|
||||
};
|
||||
/*
|
||||
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
|
||||
*/
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", -1, "1234567890" },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, "\000ABC\000DEF\000", 9, " ABC DEF " },
|
||||
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, "12345\01167890\037\177", -1, "12345 67890 " },
|
||||
/* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 6*/ { BARCODE_CODE128, DATA_MODE, -1, "ab\240cd\351", -1, "ab\302\240cdé" }, /* NBSP */
|
||||
/* 7*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */
|
||||
/* 8*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "abcdé", -1, "abcdé" },
|
||||
/* 9*/ { BARCODE_CODE128AB, DATA_MODE, -1, "abcd\351", -1, "abcdé" },
|
||||
/* 10*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "1234567890", -1, "*+12345678900*" },
|
||||
/* 11*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "a99912345", -1, "*+A999123457*" }, /* Converts to upper */
|
||||
/* 12*/ { BARCODE_DPD, UNICODE_MODE, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9" }, /* DPDAPPD 4.0.2 - Illustration 7 */
|
||||
/* 13*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X" }, /* DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect */
|
||||
/* 14*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B" }, /* DPDPLS Section 4 */
|
||||
/* 15*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A" }, /* DPDPLS Section 4.6 */
|
||||
/* 16*/ { BARCODE_DPD, UNICODE_MODE, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1" }, /* DPDPLS Section 5.1 */
|
||||
/* 17*/ { BARCODE_DPD, UNICODE_MODE, 1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O" }, /* DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT */
|
||||
/* 18*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3" }, /* DPDPLS Section 8.1 */
|
||||
/* 19*/ { BARCODE_DPD, UNICODE_MODE, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L" }, /* DPDPLS Section 8.2 */
|
||||
/* 20*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J" }, /* DPDPLS Section 8.3 */
|
||||
/* 21*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W" }, /* DPDPLS Section 8.4 */
|
||||
/* 22*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C" }, /* DPDPLS Section 8.5.1 */
|
||||
/* 23*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I" }, /* DPDPLS Section 8.5.2 */
|
||||
/* 24*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H" }, /* DPDPLS Section 8.5.3 */
|
||||
/* 25*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5" }, /* DPDPLS Section 8.5.4 */
|
||||
/* 26*/ { BARCODE_DPD, UNICODE_MODE, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6" }, /* DPDPLS Section 8.5.5 */
|
||||
/* 27*/ { BARCODE_DPD, UNICODE_MODE, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U" }, /* DPDPLS Section 8.5.6 */
|
||||
/* 28*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R" }, /* DPDPLS Section 8.6.1 */
|
||||
/* 29*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y" }, /* DPDPLS Section 8.7.1 */
|
||||
/* 30*/ { BARCODE_DPD, UNICODE_MODE, 1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I" }, /* DPDPLS Section 8.7.2 relabel */
|
||||
/* 31*/ { BARCODE_DPD, UNICODE_MODE, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C" }, /* DPDPLS Section 8.8 */
|
||||
/* 32*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N" }, /* DPDPLS Section 8.9.1 */
|
||||
/* 33*/ { BARCODE_DPD, UNICODE_MODE, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O" }, /* DPDPLS Section 8.9.2 */
|
||||
/* 34*/ { BARCODE_DPD, UNICODE_MODE, 1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M" }, /* DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect */
|
||||
/* 35*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M" }, /* DPDPLS Section 9.1 */
|
||||
/* 36*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W" }, /* DPDPLS Section 9.2 */
|
||||
/* 37*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O" }, /* DPDPLS Section 9.3 */
|
||||
/* 38*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B" }, /* DPDPLS Section 9.4 */
|
||||
/* 39*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A" }, /* DPDPLS Section 9.5 */
|
||||
/* 40*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K" }, /* DPDPLS Section 9.6 */
|
||||
/* 41*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", -1, "EE 876 543 216 CA" }, /* UPU S10 Annex A */
|
||||
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "1234567890", -1, "1234567890", -1 },
|
||||
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "1234567890", -1, "1234567890", -1 },
|
||||
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "\000ABC\000DEF\000", 9, " ABC DEF ", -1 },
|
||||
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "\000ABC\000DEF\000", 9, "\000ABC\000DEF\000", 9 }, /* No replacements */
|
||||
/* 4*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "12345\00067890", 11, "12345 67890", -1 },
|
||||
/* 5*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "12345\00067890", 11, "12345\00067890", 11 },
|
||||
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "12345\01167890\037\177", -1, "12345 67890 ", -1 },
|
||||
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "12345\01167890\037\177", -1, "12345\01167890\037\177", -1 },
|
||||
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1 },
|
||||
/* 9*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "abcdé", -1, "abcdé", -1 },
|
||||
/* 10*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé\302\240", -1, "abcdé\302\240", -1 }, /* \302\240 (U+A0) NBSP */
|
||||
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "abcdé\302\240", -1, "abcdé\302\240", -1 },
|
||||
/* 12*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1 },
|
||||
/* 13*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_PLAIN_HRT, "abcd\351", -1, "abcdé", -1 },
|
||||
/* 14*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\240cd\351", -1, "ab\302\240cdé", -1 }, /* \240 (U+A0) NBSP */
|
||||
/* 15*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_PLAIN_HRT, "ab\240cd\351", -1, "ab\302\240cdé", -1 },
|
||||
/* 16*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\200cd\351", -1, "ab cdé", -1 }, /* \200 (U+80) non-ISO/IEC 8859-1 */
|
||||
/* 17*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_PLAIN_HRT, "ab\200cd\351", -1, "ab\302\200cdé", -1 },
|
||||
/* 18*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1 }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */
|
||||
/* 19*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_PLAIN_HRT, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1 },
|
||||
/* 20*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1 },
|
||||
/* 21*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "abcdé", -1, "abcdé", -1 },
|
||||
/* 22*/ { BARCODE_CODE128AB, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1 },
|
||||
/* 23*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "1234567890", -1, "*+12345678900*", -1 },
|
||||
/* 24*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "1234567890", -1, "+12345678900", -1 },
|
||||
/* 25*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "a99912345", -1, "*+A999123457*", -1 }, /* Converts to upper */
|
||||
/* 26*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "a99912345", -1, "+A999123457", -1 },
|
||||
/* 27*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1 }, /* DPDAPPD 4.0.2 - Illustration 7 */
|
||||
/* 28*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "000393206219912345678101040", -1, "0003932062199123456781010409", -1 }, /* No spaces */
|
||||
/* 29*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1 }, /* DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect */
|
||||
/* 30*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "007110601782532948375101276", -1, "007110601782532948375101276X", -1 },
|
||||
/* 31*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1 }, /* DPDPLS Section 4 */
|
||||
/* 32*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1 }, /* DPDPLS Section 4.6 */
|
||||
/* 33*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1 }, /* DPDPLS Section 5.1 */
|
||||
/* 34*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1 }, /* DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT */
|
||||
/* 35*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3", -1 }, /* DPDPLS Section 8.1 */
|
||||
/* 36*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L", -1 }, /* DPDPLS Section 8.2 */
|
||||
/* 37*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J", -1 }, /* DPDPLS Section 8.3 */
|
||||
/* 38*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W", -1 }, /* DPDPLS Section 8.4 */
|
||||
/* 39*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C", -1 }, /* DPDPLS Section 8.5.1 */
|
||||
/* 40*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I", -1 }, /* DPDPLS Section 8.5.2 */
|
||||
/* 41*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H", -1 }, /* DPDPLS Section 8.5.3 */
|
||||
/* 42*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5", -1 }, /* DPDPLS Section 8.5.4 */
|
||||
/* 43*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6", -1 }, /* DPDPLS Section 8.5.5 */
|
||||
/* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U", -1 }, /* DPDPLS Section 8.5.6 */
|
||||
/* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R", -1 }, /* DPDPLS Section 8.6.1 */
|
||||
/* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1 }, /* DPDPLS Section 8.7.1 */
|
||||
/* 47*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1 }, /* DPDPLS Section 8.7.2 relabel */
|
||||
/* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C", -1 }, /* DPDPLS Section 8.8 */
|
||||
/* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N", -1 }, /* DPDPLS Section 8.9.1 */
|
||||
/* 50*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1 }, /* DPDPLS Section 8.9.2 */
|
||||
/* 51*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1 }, /* DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect */
|
||||
/* 52*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M", -1 }, /* DPDPLS Section 9.1 */
|
||||
/* 53*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W", -1 }, /* DPDPLS Section 9.2 */
|
||||
/* 54*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O", -1 }, /* DPDPLS Section 9.3 */
|
||||
/* 55*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B", -1 }, /* DPDPLS Section 9.4 */
|
||||
/* 56*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A", -1 }, /* DPDPLS Section 9.5 */
|
||||
/* 57*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1 }, /* DPDPLS Section 9.6 */
|
||||
/* 58*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, -1, "EE876543216CA", -1, "EE 876 543 216 CA", -1 }, /* UPU S10 Annex A */
|
||||
/* 59*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, BARCODE_PLAIN_HRT, "EE876543216CA", -1, "EE876543216CA", -1 }, /* No spaces */
|
||||
/* BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
char escaped[1024];
|
||||
char escaped2[1024];
|
||||
|
@ -254,12 +275,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
memset(symbol->text, 0xDD, sizeof(symbol->text)); /* Detect non-NUL terminated HRT */
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
|
||||
i, symbol->text, data[i].expected, expected_length);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
|
||||
|
@ -964,27 +991,28 @@ static void test_dpd_input(const testCtx *const p_ctx) {
|
|||
/* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 299: Invalid character at position 27 in input (alphanumerics only after first)", "Alphanumerics only in body" },
|
||||
/* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 300: Invalid character at position 27 in input (alphanumerics only)", "Alphanumerics only" },
|
||||
/* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, 1, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" },
|
||||
/* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char <US> as DPD ident tag" },
|
||||
/* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" },
|
||||
/* 12*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 13*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 14*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 15*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 16*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 17*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 18*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 19*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 20*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" },
|
||||
/* 21*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 22*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 23*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" },
|
||||
/* 24*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 25*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 26*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 27*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 28*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 126 only", "Control char <US> as DPD ident tag" },
|
||||
/* 11*/ { -1, -1, "\177234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 126 only", "<DEL> as DPD ident tag" },
|
||||
/* 12*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 126 only", "Extended ASCII as DPD ident tag" },
|
||||
/* 13*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 14*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 15*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 16*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 17*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 18*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" },
|
||||
/* 19*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 20*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 21*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" },
|
||||
/* 22*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 23*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 24*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" },
|
||||
/* 25*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 26*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 27*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 28*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 29*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" },
|
||||
/* 30*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
/* 31*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
|
|
@ -155,6 +155,40 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_is_chr(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
int flg;
|
||||
int c;
|
||||
int ret;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { NEON_F, '1', 1 },
|
||||
/* 1*/ { NEON_F, 'a', 0 },
|
||||
/* 2*/ { NEON_F, 0xFF, 0 },
|
||||
/* 3*/ { NEON_F, 0xFFF, 0 },
|
||||
/* 4*/ { NEON_F, 0xFFFF, 0 },
|
||||
/* 5*/ { IS_UPR_F, '1', 0 },
|
||||
/* 6*/ { IS_UPR_F, 'a', 0 },
|
||||
/* 7*/ { IS_UPR_F, 'A', 1 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, ret;
|
||||
|
||||
testStart("test_is_chr");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
ret = is_chr(data[i].flg, data[i].c);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_not_sane(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
|
@ -618,15 +652,16 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
|
|||
int ret;
|
||||
int ret_length;
|
||||
unsigned int expected_vals[20];
|
||||
const char *expected_errtxt;
|
||||
const char *comment;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", -1, 1, 0, 0, {0}, "" },
|
||||
/* 1*/ { "\000a\302\200\340\240\200", 7, 1, 0, 4, { 0, 'a', 0x80, 0x800 }, "NUL a C280 E0A080" },
|
||||
/* 2*/ { "\357\277\277", -1, 1, 0, 1, { 0xFFFF }, "EFBFBF" },
|
||||
/* 3*/ { "\360\220\200\200", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Four-byte F0908080" },
|
||||
/* 4*/ { "a\200b", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Orphan continuation 0x80" },
|
||||
/* 0*/ { "", -1, 1, 0, 0, {0}, "", "" },
|
||||
/* 1*/ { "\000a\302\200\340\240\200", 7, 1, 0, 4, { 0, 'a', 0x80, 0x800 }, "", "NUL a C280 E0A080" },
|
||||
/* 2*/ { "\357\277\277", -1, 1, 0, 1, { 0xFFFF }, "", "EFBFBF" },
|
||||
/* 3*/ { "\360\220\200\200", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "242: Unicode sequences of more than 3 bytes not supported", "Four-byte F0908080" },
|
||||
/* 4*/ { "a\200b", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "240: Corrupt Unicode data", "Orphan continuation 0x80" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
@ -644,6 +679,8 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
|
|||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
|
||||
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
ret_length = length;
|
||||
|
||||
|
@ -656,6 +693,8 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
|
|||
assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%d] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]);
|
||||
}
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected_errtxt);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
|
@ -670,6 +709,8 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
|
|||
int length;
|
||||
int ret;
|
||||
const char *expected;
|
||||
const char *expected_plain;
|
||||
int expected_plain_length;
|
||||
const char *comment;
|
||||
};
|
||||
/*
|
||||
|
@ -679,34 +720,36 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
|
|||
*/
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", -1, 0, "", "" },
|
||||
/* 1*/ { "abc", -1, 0, "abc", "" },
|
||||
/* 2*/ { "\000A\001B\002\036\037C ~\177", 11, 0, " A B C ~ ", "" },
|
||||
/* 3*/ { "~\177\200\201\237\240", -1, 0, "~ \302\240", "" },
|
||||
/* 4*/ { "\241\242\243\244\257\260", -1, 0, "¡¢£¤¯°", "" },
|
||||
/* 5*/ { "\276\277\300\337\377", -1, 0, "¾¿Àßÿ", "" },
|
||||
/* 6*/ { "\351", -1, 0, "é", "" },
|
||||
/* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "127 \241" },
|
||||
/* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 127 \241" },
|
||||
/* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", "127 \241 + a" },
|
||||
/* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 (truncated)" },
|
||||
/* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 128 \241 (truncated)" },
|
||||
/* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 + a (truncated)" },
|
||||
/* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "129 \241 (truncated)" },
|
||||
/* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "127 \351" },
|
||||
/* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 127 \351" },
|
||||
/* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "127 \351 + a" },
|
||||
/* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 (truncated)" },
|
||||
/* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 128 \351 (truncated)" },
|
||||
/* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 + a (truncated)" },
|
||||
/* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "129 \351 (truncated)" },
|
||||
/* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "256 A (truncated)" },
|
||||
/* 0*/ { "", -1, 0, "", NULL, -1, "" },
|
||||
/* 1*/ { "abc", -1, 0, "abc", NULL, -1, "" },
|
||||
/* 2*/ { "\000A\001B\002\036\037C ~\177", 11, 0, " A B C ~ ", "\000A\001B\002\036\037C ~\177", 11, "" },
|
||||
/* 3*/ { "~\177\200\201\237\240", -1, 0, "~ \302\240", "~\177\302\200\302\201\302\237\302\240", -1, "" },
|
||||
/* 4*/ { "\241\242\243\244\257\260", -1, 0, "¡¢£¤¯°", NULL, -1, "" },
|
||||
/* 5*/ { "\276\277\300\337\377", -1, 0, "¾¿Àßÿ", NULL, -1, "" },
|
||||
/* 6*/ { "\351", -1, 0, "é", NULL, -1, "" },
|
||||
/* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "127 \241" },
|
||||
/* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "a + 127 \241" },
|
||||
/* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", NULL, -1, "127 \241 + a" },
|
||||
/* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "128 \241 (truncated)" },
|
||||
/* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "a + 128 \241 (truncated)" },
|
||||
/* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "128 \241 + a (truncated)" },
|
||||
/* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", NULL, -1, "129 \241 (truncated)" },
|
||||
/* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "127 \351" },
|
||||
/* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "a + 127 \351" },
|
||||
/* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", NULL, -1, "127 \351 + a" },
|
||||
/* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "128 \351 (truncated)" },
|
||||
/* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "a + 128 \351 (truncated)" },
|
||||
/* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "128 \351 + a (truncated)" },
|
||||
/* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", NULL, -1, "129 \351 (truncated)" },
|
||||
/* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", NULL, -1, "256 A (truncated)" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
struct zint_symbol s_symbol;
|
||||
struct zint_symbol *symbol = &s_symbol;
|
||||
int expected_length;
|
||||
const char *expected;
|
||||
|
||||
testStart("test_hrt_cpy_iso8859_1");
|
||||
|
||||
|
@ -717,17 +760,224 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
|
|||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
|
||||
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = hrt_cpy_iso8859_1(symbol, (unsigned char *) data[i].data, length);
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
for (j = 0; j < ret; j++) {
|
||||
for (j = 0; j < symbol->text_length; j++) {
|
||||
fprintf(stderr, "symbol->text[%d] %2X\n", j, symbol->text[j]);
|
||||
}
|
||||
}
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol->text, (int) ustrlen(symbol->text)), "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol->text);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d symbol->text (%s) != expected (%s)\n", i, symbol->text, data[i].expected);
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol->text, symbol->text_length), "i:%d testUtilIsValidUTF8(%s) != 1\n",
|
||||
i, symbol->text);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d symbol->text (%s) != expected (%s)\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
symbol->output_options = BARCODE_PLAIN_HRT;
|
||||
|
||||
if (data[i].expected_plain == NULL) {
|
||||
expected = data[i].expected;
|
||||
expected_length = (int) strlen(expected);
|
||||
} else {
|
||||
expected = data[i].expected_plain;
|
||||
expected_length = data[i].expected_plain_length == -1 ? (int) strlen(expected) : data[i].expected_plain_length;
|
||||
}
|
||||
|
||||
ret = hrt_cpy_iso8859_1(symbol, (unsigned char *) data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol->text, symbol->text_length), "i:%d testUtilIsValidUTF8(%s) != 1\n",
|
||||
i, symbol->text);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, expected, symbol->text_length), "i:%d symbol->text (%s) != expected (%s)\n", i, symbol->text, expected);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_hrt_cpy_nochk(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
const char *cpy; /* hrt_cpy_nochk() */
|
||||
int cpy_length;
|
||||
|
||||
const char cpy_chr; /* hrt_cpy_chr() */
|
||||
int cpy_chr_length;
|
||||
|
||||
const char *cat; /* hrt_cat_nochk() */
|
||||
int cat_length;
|
||||
|
||||
char cat_chr; /* hrt_cat_chr_nochk() */
|
||||
int cat_chr_length;
|
||||
|
||||
const char *expected;
|
||||
int expected_length;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", -1, 0, 0, "", -1, 0, 0, "", -1 }, /* All zero */
|
||||
/* 1*/ { "AB\000C", 4, 0, 0, "", -1, 0, 0, "AB\000C", 4 }, /* hrt_cpy_nochk() */
|
||||
/* 2*/ { "", -1, '\000', 1, "", -1, 0, 0, "\000", 1 }, /* hrt_chr() (NUL char) */
|
||||
/* 3*/ { "", -1, '\000', 1, "XYZ", -1, 0, 0, "\000XYZ", 4 }, /* hrt_chr() + hrt_cat_nochk() */
|
||||
/* 4*/ { "", -1, '\000', 1, "", -1, '\000', 1, "\000\000", 2 }, /* hrt_chr() + hrt_cat_chr_nochk() (both NULL char) */
|
||||
/* 5*/ { "", -1, '\000', 1, "XYZ", -1, '\001', 1, "\000XYZ\001", 5 }, /* hrt_chr() + hrt_cat_chr_nochk() + hrt_cat_nochk() */
|
||||
/* 6*/ { "ABC\000", 4, 0, 0, "\000XYZ\177", 5, 0, 0, "ABC\000\000XYZ\177", 9 }, /* hrt_cpy_nochk() + hrt_cat_nochk() */
|
||||
/* 7*/ { "ABC\000", 4, 0, 0, "", -1, '\177', 1, "ABC\000\177", 5 }, /* hrt_cpy_nochk() + hrt_cat_chr_nochk() */
|
||||
/* 8*/ { "ABC\000", 4, 0, 0, "X\001Y\002Z", 5, '\003', 1, "ABC\000X\001Y\002Z\003", 10 }, /* hrt_cpy_nochk() + hrt_cat_chr_nochk() + hrt_cat_chr_nochk() */
|
||||
/* 9*/ { "1234567890123456789012345678901234567890123456789012345", -1, 0, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 0, "123456789012345678901234567890123456789012345678901234512345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1 }, /* hrt_cpy_nochk() + hrt_cat_nochk() - max 255 */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length;
|
||||
|
||||
struct zint_symbol s_symbol;
|
||||
struct zint_symbol *symbol = &s_symbol;
|
||||
int expected_length;
|
||||
|
||||
testStart("test_hrt_cpy_nochk");
|
||||
|
||||
symbol->debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int j;
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
|
||||
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
|
||||
|
||||
if ((length = data[i].cpy_length == -1 ? (int) strlen(data[i].cpy) : data[i].cpy_length)) {
|
||||
hrt_cpy_nochk(symbol, TCU(data[i].cpy), length);
|
||||
}
|
||||
if (data[i].cpy_chr_length) {
|
||||
hrt_cpy_chr(symbol, data[i].cpy_chr);
|
||||
}
|
||||
if ((length = data[i].cat_length == -1 ? (int) strlen(data[i].cat) : data[i].cat_length)) {
|
||||
hrt_cat_nochk(symbol, TCU(data[i].cat), length);
|
||||
}
|
||||
if (data[i].cat_chr_length) {
|
||||
hrt_cat_chr_nochk(symbol, data[i].cat_chr);
|
||||
}
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
for (j = 0; j < symbol->text_length; j++) {
|
||||
fprintf(stderr, "symbol->text[%d] %2X\n", j, symbol->text[j]);
|
||||
}
|
||||
}
|
||||
|
||||
assert_nonzero(testUtilIsValidUTF8(symbol->text, (int) ustrlen(symbol->text)),
|
||||
"i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol->text);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
|
||||
i, symbol->text, data[i].expected, expected_length);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_hrt_printf_nochk(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
const char *fmt;
|
||||
int num_args;
|
||||
const char *data1;
|
||||
const char *data2;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", 1, "", "", "" },
|
||||
/* 1*/ { "*%s*", 1, "gosh", "", "*gosh*" },
|
||||
/* 2*/ { "%.1s.%.2s", 2, "gosh", "wow", "g.wo" },
|
||||
/* 3*/ { "ABCDEFGHIJKLMNOPQRST%sABCDEFGHIJKLMNOPQRST%sABCDEFGHIJKLMNO", 2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "ABCDEFGHIJKLMNOPQRST1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJKLMNOPQRST1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJKLMNO" }, /* Max 255 - 1 more and overflow */
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
|
||||
struct zint_symbol s_symbol;
|
||||
struct zint_symbol *symbol = &s_symbol;
|
||||
|
||||
testStart("test_hrt_printf_nochk");
|
||||
|
||||
symbol->debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
|
||||
if (data[i].num_args == 1) {
|
||||
hrt_printf_nochk(symbol, data[i].fmt, data[i].data1);
|
||||
} else if (data[i].num_args == 2) {
|
||||
hrt_printf_nochk(symbol, data[i].fmt, data[i].data1, data[i].data2);
|
||||
} else {
|
||||
assert_zero(1, "i:%d, bad num_args\n", i);
|
||||
}
|
||||
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
const char *data;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", "" },
|
||||
/* 1*/ { "[", "(" }, /* Converts mismatched opening */
|
||||
/* 2*/ { "]", "]" }, /* But not mismatched closing */
|
||||
/* 3*/ { "[]", "()" },
|
||||
/* 4*/ { "(", "(" },
|
||||
/* 5*/ { ")", ")" },
|
||||
/* 6*/ { "[[]", "(()" },
|
||||
/* 7*/ { "[]]", "()]" },
|
||||
/* 8*/ { "[[]]", "(())" },
|
||||
/* 9*/ { "[[]][", "(())(" },
|
||||
/* 10*/ { "[[]]]", "(())]" },
|
||||
/* 11*/ { "[[]][]", "(())()" },
|
||||
/* 12*/ { "[[[[]]][]]", "(((()))())" },
|
||||
/* 13*/ { "[[[[]]]][]]", "(((())))()]" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length;
|
||||
|
||||
struct zint_symbol s_symbol;
|
||||
struct zint_symbol *symbol = &s_symbol;
|
||||
|
||||
testStart("test_hrt_conv_gs1_brackets_nochk");
|
||||
|
||||
symbol->debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
hrt_conv_gs1_brackets_nochk(symbol, TCU(data[i].data), length);
|
||||
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
|
@ -835,9 +1085,10 @@ static void test_debug_test_codeword_dump_int(const testCtx *const p_ctx) {
|
|||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_chr_cnt", test_chr_cnt },
|
||||
{ "test_to_int", test_to_int },
|
||||
{ "test_to_upper", test_to_upper },
|
||||
{ "test_chr_cnt", test_chr_cnt },
|
||||
{ "test_is_chr", test_is_chr },
|
||||
{ "test_not_sane", test_not_sane },
|
||||
{ "test_not_sane_lookup", test_not_sane_lookup },
|
||||
{ "test_errtxt", test_errtxt },
|
||||
|
@ -846,6 +1097,9 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_is_valid_utf8", test_is_valid_utf8 },
|
||||
{ "test_utf8_to_unicode", test_utf8_to_unicode },
|
||||
{ "test_hrt_cpy_iso8859_1", test_hrt_cpy_iso8859_1 },
|
||||
{ "test_hrt_cpy_nochk", test_hrt_cpy_nochk },
|
||||
{ "test_hrt_printf_nochk", test_hrt_printf_nochk },
|
||||
{ "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk },
|
||||
{ "test_set_height", test_set_height },
|
||||
{ "test_debug_test_codeword_dump_int", test_debug_test_codeword_dump_int },
|
||||
};
|
||||
|
|
|
@ -3220,6 +3220,7 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int output_options;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
|
@ -3228,45 +3229,60 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */
|
||||
/* 1*/ { BARCODE_EANX_CC, -1, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */
|
||||
/* 2*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]12", 0, "1234567890128" },
|
||||
/* 3*/ { BARCODE_EANX_CC, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 4*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 5*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "1234567890128" }, /* AI (20) should be 2 nos. */
|
||||
/* 6*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, "1234567890128", "[20]1A", 0, "1234567890128" },
|
||||
/* 7*/ { BARCODE_DBAR_OMN_CC, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 8*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 9*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 10*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 11*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */
|
||||
/* 12*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, "12345678901231", "[20]1A", 0, "(01)12345678901231" },
|
||||
/* 13*/ { BARCODE_DBAR_LTD_CC, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 14*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 15*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 16*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 17*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */
|
||||
/* 18*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, "12345678901231", "[20]1A", 0, "(01)12345678901231" },
|
||||
/* 19*/ { BARCODE_UPCA_CC, -1, "12345678901", "[20]12", 0, "123456789012" },
|
||||
/* 20*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]12", 0, "123456789012" },
|
||||
/* 21*/ { BARCODE_UPCA_CC, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 22*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 23*/ { BARCODE_UPCA_CC, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "123456789012" }, /* AI (20) should be 2 nos. */
|
||||
/* 24*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, "123456789012", "[20]1A", 0, "123456789012" },
|
||||
/* 25*/ { BARCODE_UPCE_CC, -1, "123456", "[20]12", 0, "01234565" },
|
||||
/* 26*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]12", 0, "12345670" },
|
||||
/* 27*/ { BARCODE_UPCE_CC, -1, "12345670", "[20]12", 0, "12345670" },
|
||||
/* 28*/ { BARCODE_UPCE_CC, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 29*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 30*/ { BARCODE_UPCE_CC, -1, "12345670", "[20]12", 0, "12345670" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
|
||||
/* 31*/ { BARCODE_UPCE_CC, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "12345670" }, /* AI (20) should be 2 nos. */
|
||||
/* 32*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, "1234567", "[20]1A", 0, "12345670" },
|
||||
/* 33*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[20]12", 0, "" }, /* No HRT for stacked symbologies */
|
||||
/* 34*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[20]12", 0, "" },
|
||||
/* 0*/ { BARCODE_EANX_CC, -1, -1, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */
|
||||
/* 1*/ { BARCODE_EANX_CC, -1, BARCODE_PLAIN_HRT, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */
|
||||
/* 2*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */
|
||||
/* 3*/ { BARCODE_EANX_CC, -1, BARCODE_PLAIN_HRT, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */
|
||||
/* 4*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128" },
|
||||
/* 5*/ { BARCODE_EANX_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 6*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 7*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, "1234567890128" }, /* AI (20) should be 2 nos. */
|
||||
/* 8*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128" },
|
||||
/* 9*/ { BARCODE_EANX_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12" },
|
||||
/* 10*/ { BARCODE_EANX_CC, -1, BARCODE_PLAIN_HRT, "1234567890128+12", "[20]12", 0, "123456789012812" },
|
||||
/* 11*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 12*/ { BARCODE_DBAR_OMN_CC, -1, BARCODE_PLAIN_HRT, "1234567890123", "[20]12", 0, "0112345678901231" },
|
||||
/* 13*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 14*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 15*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 16*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */
|
||||
/* 17*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231" },
|
||||
/* 18*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 19*/ { BARCODE_DBAR_LTD_CC, -1, BARCODE_PLAIN_HRT, "1234567890123", "[20]12", 0, "0112345678901231" },
|
||||
/* 20*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231" },
|
||||
/* 21*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 22*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 23*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231" }, /* AI (20) should be 2 nos. */
|
||||
/* 24*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231" },
|
||||
/* 25*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "[20]12", 0, "123456789012" },
|
||||
/* 26*/ { BARCODE_UPCA_CC, -1, BARCODE_PLAIN_HRT, "12345678901", "[20]12", 0, "123456789012" },
|
||||
/* 27*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]12", 0, "123456789012" },
|
||||
/* 28*/ { BARCODE_UPCA_CC, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 29*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 30*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, "123456789012" }, /* AI (20) should be 2 nos. */
|
||||
/* 31*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789012", "[20]1A", 0, "123456789012" },
|
||||
/* 32*/ { BARCODE_UPCA_CC, -1, -1, "123456789012+123", "[20]12", 0, "123456789012+00123" },
|
||||
/* 33*/ { BARCODE_UPCA_CC, -1, BARCODE_PLAIN_HRT, "123456789012+123", "[20]12", 0, "12345678901200123" },
|
||||
/* 34*/ { BARCODE_UPCE_CC, -1, -1, "123456", "[20]12", 0, "01234565" },
|
||||
/* 35*/ { BARCODE_UPCE_CC, -1, BARCODE_PLAIN_HRT, "123456", "[20]12", 0, "01234565" },
|
||||
/* 36*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]12", 0, "12345670" },
|
||||
/* 37*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670" },
|
||||
/* 38*/ { BARCODE_UPCE_CC, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" },
|
||||
/* 39*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "" }, /* Still checked */
|
||||
/* 40*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
|
||||
/* 41*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, "12345670" }, /* AI (20) should be 2 nos. */
|
||||
/* 42*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "1234567", "[20]1A", 0, "12345670" },
|
||||
/* 43*/ { BARCODE_UPCE_CC, -1, -1, "1234567+2", "[20]12", 0, "12345670+02" },
|
||||
/* 44*/ { BARCODE_UPCE_CC, -1, BARCODE_PLAIN_HRT, "1234567+2", "[20]12", 0, "1234567002" },
|
||||
/* 45*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "" }, /* No HRT for stacked symbologies */
|
||||
/* 46*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_PLAIN_HRT, "12345678901231", "[20]12", 0, "" },
|
||||
/* 47*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "" },
|
||||
/* 48*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_PLAIN_HRT, "12345678901231", "[20]12", 0, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, composite_length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -3277,15 +3293,21 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
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);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
|
||||
strcpy(symbol->primary, data[i].data);
|
||||
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
composite_length = (int) strlen(data[i].composite);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
|
|
|
@ -1175,9 +1175,8 @@ static void test_input(const testCtx *const p_ctx) {
|
|||
data[i].expected_rows * data[i].expected_width, data[i - 1].expected_rows * data[i - 1].expected_width);
|
||||
|
||||
if ((data[i].input_mode & 0x07) == GS1_MODE) {
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, reduced);
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, reduced, &length);
|
||||
assert_zero(ret, "i:%d gs1_verify() ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
|
||||
length = (int) ustrlen(reduced);
|
||||
text = reduced;
|
||||
} else {
|
||||
text = (unsigned char *) data[i].data;
|
||||
|
|
|
@ -31,6 +31,135 @@
|
|||
|
||||
#include "testcommon.h"
|
||||
|
||||
static void test_hrt(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { -1, "79-7", "" }, /* None */
|
||||
/* 1*/ { BARCODE_PLAIN_HRT, "79-7", "1271" },
|
||||
/* 2*/ { -1, "1271", "" }, /* None */
|
||||
/* 3*/ { BARCODE_PLAIN_HRT, "1271", "1271" },
|
||||
/* 4*/ { -1, "012710", "" }, /* None */
|
||||
/* 5*/ { BARCODE_PLAIN_HRT, "012710", "1271" },
|
||||
/* 6*/ { -1, "1-0", "" }, /* None */
|
||||
/* 7*/ { BARCODE_PLAIN_HRT, "1-0", "0016" },
|
||||
/* 8*/ { -1, "2047/63A", "" }, /* None */
|
||||
/* 9*/ { BARCODE_PLAIN_HRT, "2047/63A", "204763A" },
|
||||
/* 10*/ { -1, "79-7/1", "" }, /* None */
|
||||
/* 11*/ { BARCODE_PLAIN_HRT, "79-7/1", "12711" },
|
||||
/* 12*/ { -1, "79-7/sa", "" }, /* None */
|
||||
/* 13*/ { BARCODE_PLAIN_HRT, "79-7/sa", "127162A" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_DXFILMEDGE, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s)\n",
|
||||
i, symbol->text_length, expected_length, symbol->text);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_input(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
const char *data;
|
||||
int ret;
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *expected_errtxt;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_DXFILMEDGE, -1, "79-1/123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 972: Frame number part length 4 too long (maximum 3)" },
|
||||
/* 1*/ { BARCODE_DXFILMEDGE, -1, "79-1/1@A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 973: Frame number \"1@A\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 2*/ { BARCODE_DXFILMEDGE, -1, "012312365", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 974: DX information length 9 too long (maximum 6)" },
|
||||
/* 3*/ { BARCODE_DXFILMEDGE, -1, "12-", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 977: Wrong format for DX parts 1 and 2 (expected format: NNN-NN, digits)" },
|
||||
/* 4*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 980: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" },
|
||||
/* 5*/ { BARCODE_DXFILMEDGE, -1, "0123/0AA", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"0AA\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 6*/ { BARCODE_DXFILMEDGE, -1, "128-0/24", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 978: DX part 1 \"128\" out of range (1 to 127)" },
|
||||
/* 7*/ { BARCODE_DXFILMEDGE, -1, "127-16", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 979: DX part 2 \"16\" out of range (0 to 15)" },
|
||||
/* 8*/ { BARCODE_DXFILMEDGE, -1, "79-2/A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"A\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 9*/ { BARCODE_DXFILMEDGE, -1, "79-2/-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"-1\" out of range (0 to 63)" },
|
||||
/* 10*/ { BARCODE_DXFILMEDGE, -1, "79-2/64", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"64\" out of range (0 to 63)" },
|
||||
/* 11*/ { BARCODE_DXFILMEDGE, -1, "79-2-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 976: The \"-\" is used to separate DX parts 1 and 2, and should be used no more than once" },
|
||||
/* 12*/ { BARCODE_DXFILMEDGE, -1, "110-2/2B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 985: Frame number \"2B\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 13*/ { BARCODE_DXFILMEDGE, -1, "099990/123A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 986: Input length 11 too long (maximum 10)" },
|
||||
/* 14*/ { BARCODE_DXFILMEDGE, -1, "0123123/1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 971: DX information length 7 too long (maximum 6)" },
|
||||
/* 15*/ { BARCODE_DXFILMEDGE, -1, "120481", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"2048\" out of range (16 to 2047)" },
|
||||
/* 16*/ { BARCODE_DXFILMEDGE, -1, "100151", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" },
|
||||
/* 17*/ { BARCODE_DXFILMEDGE, -1, "15", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" },
|
||||
/* 18*/ { BARCODE_DXFILMEDGE, -1, "12-12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 6 in DX info (digits and \"-\" character only)" },
|
||||
/* 19*/ { BARCODE_DXFILMEDGE, -1, "012X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 4 in DX info (digits and \"-\" character only)" },
|
||||
/* 20*/ { BARCODE_DXFILMEDGE, -1, "110-2/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 982: Frame number indicator \"/\" at position 6, but frame number is empty" },
|
||||
/* 21*/ { BARCODE_DXFILMEDGE, -1, "/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"/\", DX code should start with a number" },
|
||||
/* 22*/ { BARCODE_DXFILMEDGE, -1, "-12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"-\", DX code should start with a number" },
|
||||
/* 23*/ { BARCODE_DXFILMEDGE, -1, "X1234X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"X\", DX code should start with a number" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
testStartSymbol("test_input", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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);
|
||||
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
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);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_encode(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
|
@ -206,79 +335,10 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_input(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
const char *data;
|
||||
int ret;
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *expected_errtxt;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_DXFILMEDGE, -1, "79-1/123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 972: Frame number part length 4 too long (maximum 3)" },
|
||||
/* 1*/ { BARCODE_DXFILMEDGE, -1, "79-1/1@A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 973: Frame number \"1@A\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 2*/ { BARCODE_DXFILMEDGE, -1, "012312365", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 974: DX information length 9 too long (maximum 6)" },
|
||||
/* 3*/ { BARCODE_DXFILMEDGE, -1, "12-", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 977: Wrong format for DX parts 1 and 2 (expected format: NNN-NN, digits)" },
|
||||
/* 4*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 980: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" },
|
||||
/* 5*/ { BARCODE_DXFILMEDGE, -1, "0123/0AA", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"0AA\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 6*/ { BARCODE_DXFILMEDGE, -1, "128-0/24", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 978: DX part 1 \"128\" out of range (1 to 127)" },
|
||||
/* 7*/ { BARCODE_DXFILMEDGE, -1, "127-16", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 979: DX part 2 \"16\" out of range (0 to 15)" },
|
||||
/* 8*/ { BARCODE_DXFILMEDGE, -1, "79-2/A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"A\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 9*/ { BARCODE_DXFILMEDGE, -1, "79-2/-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"-1\" out of range (0 to 63)" },
|
||||
/* 10*/ { BARCODE_DXFILMEDGE, -1, "79-2/64", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"64\" out of range (0 to 63)" },
|
||||
/* 11*/ { BARCODE_DXFILMEDGE, -1, "79-2-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 976: The \"-\" is used to separate DX parts 1 and 2, and should be used no more than once" },
|
||||
/* 12*/ { BARCODE_DXFILMEDGE, -1, "110-2/2B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 985: Frame number \"2B\" is invalid (expected digits, optionally followed by a single \"A\")" },
|
||||
/* 13*/ { BARCODE_DXFILMEDGE, -1, "099990/123A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 986: Input length 11 too long (maximum 10)" },
|
||||
/* 14*/ { BARCODE_DXFILMEDGE, -1, "0123123/1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 971: DX information length 7 too long (maximum 6)" },
|
||||
/* 15*/ { BARCODE_DXFILMEDGE, -1, "120481", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"2048\" out of range (16 to 2047)" },
|
||||
/* 16*/ { BARCODE_DXFILMEDGE, -1, "100151", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" },
|
||||
/* 17*/ { BARCODE_DXFILMEDGE, -1, "15", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" },
|
||||
/* 18*/ { BARCODE_DXFILMEDGE, -1, "12-12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 6 in DX info (digits and \"-\" character only)" },
|
||||
/* 19*/ { BARCODE_DXFILMEDGE, -1, "012X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 4 in DX info (digits and \"-\" character only)" },
|
||||
/* 20*/ { BARCODE_DXFILMEDGE, -1, "110-2/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 982: Frame number indicator \"/\" at position 6, but frame number is empty" },
|
||||
/* 21*/ { BARCODE_DXFILMEDGE, -1, "/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"/\", DX code should start with a number" },
|
||||
/* 22*/ { BARCODE_DXFILMEDGE, -1, "-12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"-\", DX code should start with a number" },
|
||||
/* 23*/ { BARCODE_DXFILMEDGE, -1, "X1234X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"X\", DX code should start with a number" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
|
||||
testStartSymbol("test_input", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(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);
|
||||
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
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);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_hrt", test_hrt },
|
||||
{ "test_input", test_input },
|
||||
{ "test_encode", test_encode },
|
||||
};
|
||||
|
|
|
@ -265,6 +265,7 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int output_options;
|
||||
const char *data;
|
||||
const char *composite;
|
||||
|
||||
|
@ -273,64 +274,96 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_GS1_128, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" },
|
||||
/* 2*/ { BARCODE_GS1_128, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" },
|
||||
/* 3*/ { BARCODE_GS1_128, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 4*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[01]12345678901231[10]10[20]AB", "", 0, "(01)12345678901231(10)10(20)AB" },
|
||||
/* 5*/ { BARCODE_GS1_128, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 6*/ { BARCODE_GS1_128, -1, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */
|
||||
/* 7*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, "[91]ABCDEF]GH", "", 0, "(91)ABCDEF]GH" },
|
||||
/* 8*/ { BARCODE_GS1_128, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH" },
|
||||
/* 9*/ { BARCODE_GS1_128, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH" },
|
||||
/* 10*/ { BARCODE_GS1_128, -1, "[91]ABCDE(20)12", "", 0, "(91)ABCDE(20)12" },
|
||||
/* 11*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */
|
||||
/* 12*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, "(91)ABCDEF]GH", "", 0, "(91)ABCDEF]GH" },
|
||||
/* 13*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)ABCDEF)GH", "", 0, "(91)ABCDEF)GH" },
|
||||
/* 14*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[FGH" }, /* Invalid CSET 82 character */
|
||||
/* 15*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, "(91)ABCDE[FGH", "", 0, "(91)ABCDE[FGH" },
|
||||
/* 16*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[92]GH" }, /* Invalid CSET 82 character */
|
||||
/* 17*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, "(91)ABCDE[92]GH", "", 0, "(91)ABCDE[92]GH" },
|
||||
/* 18*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 19*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12" },
|
||||
/* 20*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12" },
|
||||
/* 21*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 22*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB" },
|
||||
/* 23*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 24*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 25*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 26*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "(01)12345678901231" },
|
||||
/* 27*/ { BARCODE_EAN14, -1, "1234", "", 0, "(01)00000000012348" },
|
||||
/* 28*/ { BARCODE_EAN14, -1, "12345", "", 0, "(01)00000000123457" },
|
||||
/* 29*/ { BARCODE_EAN14, -1, "12340", "", 0, "(01)00000000123402" },
|
||||
/* 30*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "(00)123456789012345675" },
|
||||
/* 31*/ { BARCODE_NVE18, -1, "1234", "", 0, "(00)000000000000012348" },
|
||||
/* 32*/ { BARCODE_NVE18, -1, "12345", "", 0, "(00)000000000000123457" },
|
||||
/* 33*/ { BARCODE_NVE18, -1, "12340", "", 0, "(00)000000000000123402" },
|
||||
/* 34*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 35*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" },
|
||||
/* 36*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" },
|
||||
/* 37*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 38*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB" },
|
||||
/* 39*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 40*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012" },
|
||||
/* 41*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12" },
|
||||
/* 42*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12" },
|
||||
/* 43*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234" },
|
||||
/* 44*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234" },
|
||||
/* 45*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231" },
|
||||
/* 46*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345" },
|
||||
/* 47*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 48*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901234[20]12", "", 0, "" },
|
||||
/* 49*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[20]12", "", 0, "" },
|
||||
/* 50*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(20)12(90)ABC(20)12" },
|
||||
/* 51*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 52*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901234[20]12", "[21]12345", 0, "" },
|
||||
/* 53*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[20]12", "[21]12345", 0, "" },
|
||||
/* 0*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 1*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" },
|
||||
/* 2*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" },
|
||||
/* 3*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" },
|
||||
/* 4*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 5*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]10[20]AB", "", 0, "(01)12345678901231(10)10(20)AB" },
|
||||
/* 6*/ { BARCODE_GS1_128, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 7*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */
|
||||
/* 8*/ { BARCODE_GS1_128, GS1NOCHECK_MODE, -1, "[91]ABCDEF]GH", "", 0, "(91)ABCDEF]GH" },
|
||||
/* 9*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[91]ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDEF]GH" },
|
||||
/* 10*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH" },
|
||||
/* 11*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[91]ABCDEF)GH", "", 0, "91ABCDEF)GH" },
|
||||
/* 12*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH" },
|
||||
/* 13*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[91]ABCDEF(GH", "", 0, "91ABCDEF(GH" },
|
||||
/* 14*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDE(20)12", "", 0, "(91)ABCDE(20)12" },
|
||||
/* 15*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[91]ABCDE(20)12", "", 0, "91ABCDE(20)12" },
|
||||
/* 16*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12", "", 0, "(90)1234(91)ABCDE(20)12" },
|
||||
/* 17*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[90]1234[91]ABCDE(20)12", "", 0, "901234\03591ABCDE(20)12" },
|
||||
/* 18*/ { BARCODE_GS1_128, -1, -1, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "(90)1234(91)ABCDE(20)12(20)12" },
|
||||
/* 19*/ { BARCODE_GS1_128, -1, BARCODE_PLAIN_HRT, "[90]1234[91]ABCDE(20)12[20]12", "", 0, "901234\03591ABCDE(20)12\0352012" },
|
||||
/* 20*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDEF]GH" }, /* Invalid CSET 82 character */
|
||||
/* 21*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDEF]GH", "", 0, "(91)ABCDEF]GH" },
|
||||
/* 22*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_PLAIN_HRT, "(91)ABCDEF]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDEF]GH" },
|
||||
/* 23*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF)GH", "", 0, "(91)ABCDEF)GH" },
|
||||
/* 24*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_PLAIN_HRT, "(91)ABCDEF)GH", "", 0, "91ABCDEF)GH" },
|
||||
/* 25*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[FGH" }, /* Invalid CSET 82 character */
|
||||
/* 26*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[FGH", "", 0, "(91)ABCDE[FGH" },
|
||||
/* 27*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_PLAIN_HRT, "(91)ABCDE[FGH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDE[FGH" },
|
||||
/* 28*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "(91)ABCDE[92]GH" }, /* Invalid CSET 82 character */
|
||||
/* 29*/ { BARCODE_GS1_128, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(91)ABCDE[92]GH", "", 0, "(91)ABCDE[92]GH" },
|
||||
/* 30*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_PLAIN_HRT, "(91)ABCDE[92]GH", "", ZINT_WARN_NONCOMPLIANT, "91ABCDE[92]GH" },
|
||||
/* 31*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 32*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12" },
|
||||
/* 33*/ { BARCODE_GS1_128_CC, -1, BARCODE_PLAIN_HRT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" },
|
||||
/* 34*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12" },
|
||||
/* 35*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 36*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB" },
|
||||
/* 37*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 38*/ { BARCODE_GS1_128_CC, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "011234567890123110AB\0352012" },
|
||||
/* 39*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 40*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 41*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231" },
|
||||
/* 42*/ { BARCODE_EAN14, -1, BARCODE_PLAIN_HRT, "1234567890123", "", 0, "0112345678901231" },
|
||||
/* 43*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348" },
|
||||
/* 44*/ { BARCODE_EAN14, -1, BARCODE_PLAIN_HRT, "1234", "", 0, "0100000000012348" },
|
||||
/* 45*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457" },
|
||||
/* 46*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402" },
|
||||
/* 47*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675" },
|
||||
/* 48*/ { BARCODE_NVE18, -1, BARCODE_PLAIN_HRT, "12345678901234567", "", 0, "00123456789012345675" },
|
||||
/* 49*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348" },
|
||||
/* 50*/ { BARCODE_NVE18, -1, BARCODE_PLAIN_HRT, "1234", "", 0, "00000000000000012348" },
|
||||
/* 51*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457" },
|
||||
/* 52*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402" },
|
||||
/* 53*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12" }, /* Incorrect check digit */
|
||||
/* 54*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12" },
|
||||
/* 55*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" },
|
||||
/* 56*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12" },
|
||||
/* 57*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[20]12", "", 0, "01123456789012312012" },
|
||||
/* 58*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB" }, /* AI (20) should be 2 nos. */
|
||||
/* 59*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB" },
|
||||
/* 60*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "01123456789012311012\03520AB" },
|
||||
/* 61*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12" },
|
||||
/* 62*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12", "", 0, "011234567890123110AB\0352012" },
|
||||
/* 63*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012" },
|
||||
/* 64*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "011234567890123110AB\035201290ABC(2012" },
|
||||
/* 65*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12" },
|
||||
/* 66*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "011234567890123110AB\035201290ABC20)12" },
|
||||
/* 67*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12" },
|
||||
/* 68*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "011234567890123110AB\035201290ABC(20)12" },
|
||||
/* 69*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" },
|
||||
/* 70*/ { BARCODE_DBAR_EXP, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "011234567890123110AB\035201290ABC(20)12\0359112(" },
|
||||
/* 71*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234" },
|
||||
/* 72*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234" },
|
||||
/* 73*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_PLAIN_HRT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "0112345678901234" },
|
||||
/* 74*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231" },
|
||||
/* 75*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345" },
|
||||
/* 76*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_PLAIN_HRT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "011234567890123120122112345" },
|
||||
/* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 78*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "" },
|
||||
/* 79*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_PLAIN_HRT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "" },
|
||||
/* 81*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 82*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "" },
|
||||
/* 83*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_PLAIN_HRT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" },
|
||||
/* 84*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
const char *text;
|
||||
|
||||
|
@ -349,12 +382,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
} else {
|
||||
text = data[i].data;
|
||||
}
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, text, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
text, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(text), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
@ -1407,6 +1446,7 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
|
|||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int reduced_length;
|
||||
|
||||
char reduced[1024];
|
||||
char escaped[1024];
|
||||
|
@ -1422,7 +1462,7 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
|
|||
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced);
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced, &reduced_length);
|
||||
|
||||
if (p_ctx->generate) {
|
||||
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
|
||||
|
@ -1435,6 +1475,8 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
|
|||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, reduced, data[i].expected);
|
||||
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
|
||||
i, reduced_length, (int) strlen(reduced));
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
@ -2112,6 +2154,7 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
|
|||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int reduced_length;
|
||||
|
||||
char reduced[1024];
|
||||
|
||||
|
@ -2126,11 +2169,13 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
|
|||
|
||||
length = (int) strlen(data[i].data);
|
||||
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced);
|
||||
ret = gs1_verify(symbol, (unsigned char *) data[i].data, length, (unsigned char *) reduced, &reduced_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n", i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, reduced, data[i].expected);
|
||||
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
|
||||
i, reduced_length, (int) strlen(reduced));
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
|
|
|
@ -167,16 +167,19 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int output_options;
|
||||
const char *data;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "53379777234994544928-51135759461", "" }, /* None */
|
||||
/* 0*/ { -1, "53379777234994544928-51135759461", "" }, /* None */
|
||||
/* 1*/ { BARCODE_PLAIN_HRT, "53379777234994544928-51135759461", "53379777234994544928-51135759461" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -187,12 +190,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,61 @@
|
|||
|
||||
#include "testcommon.h"
|
||||
|
||||
static void test_4s_hrt(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { -1, "1100000000000XY11", "" }, /* None */
|
||||
/* 1*/ { BARCODE_PLAIN_HRT, "1100000000000XY11", "1100000000000XY11 " },
|
||||
/* 2*/ { -1, "1100000000000XY11 ", "" }, /* None */
|
||||
/* 3*/ { BARCODE_PLAIN_HRT, "1100000000000XY11 ", "1100000000000XY11 " },
|
||||
/* 4*/ { -1, "0100000000000A00AA0A", "" }, /* None */
|
||||
/* 5*/ { BARCODE_PLAIN_HRT, "0100000000000A00AA0A", "0100000000000A00AA0A " }, /* None */
|
||||
/* 6*/ { -1, "41038422416563762XY11 ", "" }, /* None */
|
||||
/* 7*/ { BARCODE_PLAIN_HRT, "41038422416563762XY11 ", "41038422416563762XY11 " },
|
||||
/* 8*/ { -1, "01000000000000000AA000AA0A", "" }, /* None */
|
||||
/* 9*/ { BARCODE_PLAIN_HRT, "01000000000000000AA000AA0A", "01000000000000000AA000AA0A" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_4s_hrt", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, BARCODE_MAILMARK_4S, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s)\n",
|
||||
i, symbol->text_length, expected_length, symbol->text);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_4s_input(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
|
@ -604,6 +659,7 @@ static void test_2d_encode(const testCtx *const p_ctx) {
|
|||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func */
|
||||
{ "test_4s_hrt", test_4s_hrt },
|
||||
{ "test_4s_input", test_4s_input },
|
||||
{ "test_4s_encode_vector", test_4s_encode_vector },
|
||||
{ "test_4s_encode", test_4s_encode },
|
||||
|
|
|
@ -99,28 +99,48 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_PHARMA, -1, "123456", "" }, /* None */
|
||||
/* 1*/ { BARCODE_PHARMA_TWO, -1, "123456", "" }, /* None */
|
||||
/* 2*/ { BARCODE_CODE32, -1, "123456", "A001234564" },
|
||||
/* 3*/ { BARCODE_CODE32, -1, "12345678", "A123456788" },
|
||||
/* 4*/ { BARCODE_PZN, -1, "12345", "PZN - 00123458" }, /* Pads with zeroes if length < 7 */
|
||||
/* 5*/ { BARCODE_PZN, -1, "123456", "PZN - 01234562" },
|
||||
/* 6*/ { BARCODE_PZN, -1, "1234567", "PZN - 12345678" },
|
||||
/* 7*/ { BARCODE_PZN, -1, "12345678", "PZN - 12345678" },
|
||||
/* 8*/ { BARCODE_PZN, 1, "1234", "PZN - 0012345" }, /* PZN7, pads with zeroes if length < 6 */
|
||||
/* 9*/ { BARCODE_PZN, 1, "12345", "PZN - 0123458" },
|
||||
/* 10*/ { BARCODE_PZN, 1, "123456", "PZN - 1234562" },
|
||||
/* 11*/ { BARCODE_PZN, 1, "1234562", "PZN - 1234562" },
|
||||
/* 0*/ { BARCODE_PHARMA, -1, -1, "123456", "" }, /* None */
|
||||
/* 1*/ { BARCODE_PHARMA, -1, BARCODE_PLAIN_HRT, "123456", "123456" },
|
||||
/* 2*/ { BARCODE_PHARMA_TWO, -1, -1, "123456", "" }, /* None */
|
||||
/* 3*/ { BARCODE_PHARMA_TWO, -1, BARCODE_PLAIN_HRT, "123456", "123456" },
|
||||
/* 4*/ { BARCODE_CODE32, -1, -1, "123456", "A001234564" },
|
||||
/* 5*/ { BARCODE_CODE32, -1, BARCODE_PLAIN_HRT, "123456", "015PN4" }, /* Actual encoded CODE39 value */
|
||||
/* 6*/ { BARCODE_CODE32, -1, -1, "12345678", "A123456788" },
|
||||
/* 7*/ { BARCODE_CODE32, -1, BARCODE_PLAIN_HRT, "12345678", "3PRM8N" },
|
||||
/* 8*/ { BARCODE_CODE32, 1, -1, "12345678", "A123456788" }, /* Ignore option_2 re check digits */
|
||||
/* 9*/ { BARCODE_CODE32, 1, BARCODE_PLAIN_HRT, "12345678", "3PRM8N" },
|
||||
/* 10*/ { BARCODE_CODE32, 2, -1, "12345678", "A123456788" }, /* Ignore option_2 re check digits */
|
||||
/* 11*/ { BARCODE_CODE32, 2, BARCODE_PLAIN_HRT, "12345678", "3PRM8N" },
|
||||
/* 12*/ { BARCODE_PZN, -1, -1, "12345", "PZN - 00123458" }, /* Pads with zeroes if length < 7 */
|
||||
/* 13*/ { BARCODE_PZN, -1, BARCODE_PLAIN_HRT, "12345", "-00123458" }, /* Actual encoded CODE39 value */
|
||||
/* 14*/ { BARCODE_PZN, -1, -1, "123456", "PZN - 01234562" },
|
||||
/* 15*/ { BARCODE_PZN, -1, BARCODE_PLAIN_HRT, "123456", "-01234562" },
|
||||
/* 16*/ { BARCODE_PZN, -1, -1, "1234567", "PZN - 12345678" },
|
||||
/* 17*/ { BARCODE_PZN, -1, BARCODE_PLAIN_HRT, "1234567", "-12345678" },
|
||||
/* 18*/ { BARCODE_PZN, -1, -1, "12345678", "PZN - 12345678" },
|
||||
/* 19*/ { BARCODE_PZN, -1, BARCODE_PLAIN_HRT, "12345678", "-12345678" },
|
||||
/* 20*/ { BARCODE_PZN, 1, -1, "1234", "PZN - 0012345" }, /* PZN7, pads with zeroes if length < 6 */
|
||||
/* 21*/ { BARCODE_PZN, 1, BARCODE_PLAIN_HRT, "1234", "-0012345" },
|
||||
/* 22*/ { BARCODE_PZN, 1, -1, "12345", "PZN - 0123458" },
|
||||
/* 23*/ { BARCODE_PZN, 1, BARCODE_PLAIN_HRT, "12345", "-0123458" },
|
||||
/* 24*/ { BARCODE_PZN, 1, -1, "123456", "PZN - 1234562" },
|
||||
/* 25*/ { BARCODE_PZN, 1, BARCODE_PLAIN_HRT, "123456", "-1234562" },
|
||||
/* 26*/ { BARCODE_PZN, 1, -1, "1234562", "PZN - 1234562" },
|
||||
/* 27*/ { BARCODE_PZN, 1, BARCODE_PLAIN_HRT, "1234562", "-1234562" },
|
||||
/* 28*/ { BARCODE_PZN, 2, -1, "12345", "PZN - 00123458" }, /* Ignore option_2 re check digits */
|
||||
/* 29*/ { BARCODE_PZN, 2, BARCODE_PLAIN_HRT, "12345", "-00123458" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -131,12 +151,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s)\n",
|
||||
i, symbol->text_length, expected_length, symbol->text);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
@ -270,15 +296,24 @@ static void test_encode(const testCtx *const p_ctx) {
|
|||
/* 4*/ { BARCODE_CODE32, -1, "34567890", 0, 1, 103, "Verified manually against TEC-IT",
|
||||
"1001011011010101101001011010110010110101011011010010101100101101011010010101101010101100110100101101101"
|
||||
},
|
||||
/* 5*/ { BARCODE_PZN, -1, "1234567", 0, 1, 142, "Example from IFA Info Code 39 EN V2.1; verified manually against TEC-IT",
|
||||
/* 5*/ { BARCODE_CODE32, 1, "34567890", 0, 1, 103, "Make sure option_2 doesn't add extra check digit",
|
||||
"1001011011010101101001011010110010110101011011010010101100101101011010010101101010101100110100101101101"
|
||||
},
|
||||
/* 6*/ { BARCODE_CODE32, 2, "34567890", 0, 1, 103, "Make sure option_2 doesn't add extra check digit",
|
||||
"1001011011010101101001011010110010110101011011010010101100101101011010010101101010101100110100101101101"
|
||||
},
|
||||
/* 7*/ { BARCODE_PZN, -1, "1234567", 0, 1, 142, "Example from IFA Info Code 39 EN V2.1; verified manually against TEC-IT",
|
||||
"1001011011010100101011011011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010100101101101"
|
||||
},
|
||||
/* 6*/ { BARCODE_PZN, -1, "2758089", 0, 1, 142, "Example from IFA Info Check Digit Calculations EN 15 July 2019; verified manually against TEC-IT",
|
||||
/* 8*/ { BARCODE_PZN, -1, "2758089", 0, 1, 142, "Example from IFA Info Check Digit Calculations EN 15 July 2019; verified manually against TEC-IT",
|
||||
"1001011011010100101011011010110010101101010010110110110100110101011010010110101010011011010110100101101010110010110101011001011010100101101101"
|
||||
},
|
||||
/* 7*/ { BARCODE_PZN, 1, "123456", 0, 1, 129, "Example from BWIPP; verified manually against TEC-IT",
|
||||
/* 9*/ { BARCODE_PZN, 1, "123456", 0, 1, 129, "Example from BWIPP; verified manually against TEC-IT",
|
||||
"100101101101010010101101101101001010110101100101011011011001010101010011010110110100110101010110011010101011001010110100101101101"
|
||||
},
|
||||
/* 10*/ { BARCODE_PZN, 2, "1234567", 0, 1, 142, "Make sure option_2 ignored for check digit",
|
||||
"1001011011010100101011011011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010100101101101"
|
||||
},
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
|
|
@ -346,6 +346,9 @@ static void test_fopen(const testCtx *const p_ctx) {
|
|||
/* 13*/ { "out_test\\", "\\out_test_subdir\\", "out.png", 1 },
|
||||
/* 14*/ { "", "", "outé.png", 1 },
|
||||
/* 15*/ { "outé_test", "", "outé.png", 1 },
|
||||
#ifdef _WIN32
|
||||
/* 16*/ { "out\351_test", "", "out.png", 0 }, /* Invalid UTF-8 */
|
||||
#endif
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, len;
|
||||
|
|
|
@ -109,45 +109,93 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567", "1234567" },
|
||||
/* 1*/ { BARCODE_MSI_PLESSEY, 0, "1234567", "1234567" },
|
||||
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "1234567", "12345674" },
|
||||
/* 3*/ { BARCODE_MSI_PLESSEY, 1 + 10, "1234567", "1234567" },
|
||||
/* 4*/ { BARCODE_MSI_PLESSEY, 1, "9999999999", "99999999990" },
|
||||
/* 5*/ { BARCODE_MSI_PLESSEY, 2, "1234567", "123456741" },
|
||||
/* 6*/ { BARCODE_MSI_PLESSEY, 2 + 10, "1234567", "1234567" },
|
||||
/* 7*/ { BARCODE_MSI_PLESSEY, 2, "9999999999", "999999999900" },
|
||||
/* 8*/ { BARCODE_MSI_PLESSEY, 3, "1234567", "12345674" },
|
||||
/* 9*/ { BARCODE_MSI_PLESSEY, 3 + 10, "1234567", "1234567" },
|
||||
/* 10*/ { BARCODE_MSI_PLESSEY, 3, "9999999999", "99999999995" },
|
||||
/* 11*/ { BARCODE_MSI_PLESSEY, 4, "1234567", "123456741" },
|
||||
/* 12*/ { BARCODE_MSI_PLESSEY, 4 + 10, "1234567", "1234567" },
|
||||
/* 13*/ { BARCODE_MSI_PLESSEY, 4, "9999999999", "999999999959" },
|
||||
/* 14*/ { BARCODE_MSI_PLESSEY, 5, "1234567", "12345679" },
|
||||
/* 15*/ { BARCODE_MSI_PLESSEY, 5 + 10, "1234567", "1234567" },
|
||||
/* 16*/ { BARCODE_MSI_PLESSEY, 5, "9999999999", "999999999910" },
|
||||
/* 17*/ { BARCODE_MSI_PLESSEY, 6, "1234567", "123456790" },
|
||||
/* 18*/ { BARCODE_MSI_PLESSEY, 6 + 10, "1234567", "1234567" },
|
||||
/* 19*/ { BARCODE_MSI_PLESSEY, 6, "9999999999", "9999999999109" },
|
||||
/* 20*/ { BARCODE_MSI_PLESSEY, 1, "123456", "1234566" },
|
||||
/* 21*/ { BARCODE_MSI_PLESSEY, 2, "123456", "12345666" },
|
||||
/* 22*/ { BARCODE_MSI_PLESSEY, 3, "123456", "1234560" },
|
||||
/* 23*/ { BARCODE_MSI_PLESSEY, 4, "123456", "12345609" },
|
||||
/* 24*/ { BARCODE_MSI_PLESSEY, 3, "2211", "221110" }, /* Mod-11 check digit '10' */
|
||||
/* 25*/ { BARCODE_MSI_PLESSEY, 3 + 10, "2211", "2211" }, /* Mod-11 check digit '10' */
|
||||
/* 26*/ { BARCODE_MSI_PLESSEY, 4, "2211", "2211100" },
|
||||
/* 27*/ { BARCODE_MSI_PLESSEY, 4 + 10, "2211", "2211" },
|
||||
/* 28*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", "0123456789ABCDEF" },
|
||||
/* 0*/ { BARCODE_MSI_PLESSEY, -1, -1, "1234567", "1234567" },
|
||||
/* 1*/ { BARCODE_MSI_PLESSEY, -1, BARCODE_PLAIN_HRT, "1234567", "1234567" },
|
||||
/* 2*/ { BARCODE_MSI_PLESSEY, 0, -1, "1234567", "1234567" },
|
||||
/* 3*/ { BARCODE_MSI_PLESSEY, 0, BARCODE_PLAIN_HRT, "1234567", "1234567" },
|
||||
/* 4*/ { BARCODE_MSI_PLESSEY, 1, -1, "1234567", "12345674" },
|
||||
/* 5*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_PLAIN_HRT, "1234567", "12345674" },
|
||||
/* 6*/ { BARCODE_MSI_PLESSEY, 1 + 10, -1, "1234567", "1234567" },
|
||||
/* 7*/ { BARCODE_MSI_PLESSEY, 1 + 10, BARCODE_PLAIN_HRT, "1234567", "12345674" },
|
||||
/* 8*/ { BARCODE_MSI_PLESSEY, 1, -1, "9999999999", "99999999990" },
|
||||
/* 9*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_PLAIN_HRT, "9999999999", "99999999990" },
|
||||
/* 10*/ { BARCODE_MSI_PLESSEY, 2, -1, "1234567", "123456741" },
|
||||
/* 11*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_PLAIN_HRT, "1234567", "123456741" },
|
||||
/* 12*/ { BARCODE_MSI_PLESSEY, 2 + 10, -1, "1234567", "1234567" },
|
||||
/* 13*/ { BARCODE_MSI_PLESSEY, 2 + 10, BARCODE_PLAIN_HRT, "1234567", "123456741" },
|
||||
/* 14*/ { BARCODE_MSI_PLESSEY, 2, -1, "9999999999", "999999999900" },
|
||||
/* 15*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_PLAIN_HRT, "9999999999", "999999999900" },
|
||||
/* 16*/ { BARCODE_MSI_PLESSEY, 3, -1, "1234567", "12345674" },
|
||||
/* 17*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_PLAIN_HRT, "1234567", "12345674" },
|
||||
/* 18*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "1234567", "1234567" },
|
||||
/* 19*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_PLAIN_HRT, "1234567", "12345674" },
|
||||
/* 20*/ { BARCODE_MSI_PLESSEY, 3, -1, "9999999999", "99999999995" },
|
||||
/* 21*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_PLAIN_HRT, "9999999999", "99999999995" },
|
||||
/* 22*/ { BARCODE_MSI_PLESSEY, 4, -1, "1234567", "123456741" },
|
||||
/* 23*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_PLAIN_HRT, "1234567", "123456741" },
|
||||
/* 24*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "1234567", "1234567" },
|
||||
/* 25*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_PLAIN_HRT, "1234567", "123456741" },
|
||||
/* 26*/ { BARCODE_MSI_PLESSEY, 4, -1, "9999999999", "999999999959" },
|
||||
/* 27*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_PLAIN_HRT, "9999999999", "999999999959" },
|
||||
/* 28*/ { BARCODE_MSI_PLESSEY, 5, -1, "1234567", "12345679" },
|
||||
/* 29*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_PLAIN_HRT, "1234567", "12345679" },
|
||||
/* 30*/ { BARCODE_MSI_PLESSEY, 5 + 10, -1, "1234567", "1234567" },
|
||||
/* 31*/ { BARCODE_MSI_PLESSEY, 5 + 10, BARCODE_PLAIN_HRT, "1234567", "12345679" },
|
||||
/* 32*/ { BARCODE_MSI_PLESSEY, 5, -1, "9999999999", "999999999910" },
|
||||
/* 33*/ { BARCODE_MSI_PLESSEY, 5, BARCODE_PLAIN_HRT, "9999999999", "999999999910" },
|
||||
/* 34*/ { BARCODE_MSI_PLESSEY, 6, -1, "1234567", "123456790" },
|
||||
/* 35*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_PLAIN_HRT, "1234567", "123456790" },
|
||||
/* 36*/ { BARCODE_MSI_PLESSEY, 6 + 10, -1, "1234567", "1234567" },
|
||||
/* 37*/ { BARCODE_MSI_PLESSEY, 6 + 10, BARCODE_PLAIN_HRT, "1234567", "123456790" },
|
||||
/* 38*/ { BARCODE_MSI_PLESSEY, 6, -1, "9999999999", "9999999999109" },
|
||||
/* 39*/ { BARCODE_MSI_PLESSEY, 6, BARCODE_PLAIN_HRT, "9999999999", "9999999999109" },
|
||||
/* 40*/ { BARCODE_MSI_PLESSEY, 1, -1, "123456", "1234566" },
|
||||
/* 41*/ { BARCODE_MSI_PLESSEY, 1, BARCODE_PLAIN_HRT, "123456", "1234566" },
|
||||
/* 42*/ { BARCODE_MSI_PLESSEY, 2, -1, "123456", "12345666" },
|
||||
/* 43*/ { BARCODE_MSI_PLESSEY, 2, BARCODE_PLAIN_HRT, "123456", "12345666" },
|
||||
/* 44*/ { BARCODE_MSI_PLESSEY, 3, -1, "123456", "1234560" },
|
||||
/* 45*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_PLAIN_HRT, "123456", "1234560" },
|
||||
/* 46*/ { BARCODE_MSI_PLESSEY, 4, -1, "123456", "12345609" },
|
||||
/* 47*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_PLAIN_HRT, "123456", "12345609" },
|
||||
/* 48*/ { BARCODE_MSI_PLESSEY, 3, -1, "2211", "221110" }, /* Mod-11 check digit '10' */
|
||||
/* 49*/ { BARCODE_MSI_PLESSEY, 3, BARCODE_PLAIN_HRT, "2211", "221110" },
|
||||
/* 50*/ { BARCODE_MSI_PLESSEY, 3 + 10, -1, "2211", "2211" }, /* Mod-11 check digit '10' */
|
||||
/* 51*/ { BARCODE_MSI_PLESSEY, 3 + 10, BARCODE_PLAIN_HRT, "2211", "221110" },
|
||||
/* 52*/ { BARCODE_MSI_PLESSEY, 4, -1, "2211", "2211100" },
|
||||
/* 53*/ { BARCODE_MSI_PLESSEY, 4, BARCODE_PLAIN_HRT, "2211", "2211100" },
|
||||
/* 54*/ { BARCODE_MSI_PLESSEY, 4 + 10, -1, "2211", "2211" },
|
||||
/* 55*/ { BARCODE_MSI_PLESSEY, 4 + 10, BARCODE_PLAIN_HRT, "2211", "2211100" },
|
||||
/* 56*/ { BARCODE_PLESSEY, -1, -1, "0123456789ABCDEF", "0123456789ABCDEF" },
|
||||
/* 57*/ { BARCODE_PLESSEY, -1, BARCODE_PLAIN_HRT, "0123456789ABCDEF", "0123456789ABCDEF90" },
|
||||
/* 58*/ { BARCODE_PLESSEY, 1, -1, "0123456789ABCDEF", "0123456789ABCDEF90" },
|
||||
/* 59*/ { BARCODE_PLESSEY, 1, BARCODE_PLAIN_HRT, "0123456789ABCDEF", "0123456789ABCDEF90" },
|
||||
/* 60*/ { BARCODE_PLESSEY, -1, -1, "1", "1" },
|
||||
/* 61*/ { BARCODE_PLESSEY, -1, BARCODE_PLAIN_HRT, "1", "173" },
|
||||
/* 62*/ { BARCODE_PLESSEY, 1, -1, "1", "173" },
|
||||
/* 63*/ { BARCODE_PLESSEY, 1, BARCODE_PLAIN_HRT, "1", "173" },
|
||||
/* 64*/ { BARCODE_PLESSEY, -1, -1, "7", "7" },
|
||||
/* 65*/ { BARCODE_PLESSEY, -1, BARCODE_PLAIN_HRT, "7", "758" },
|
||||
/* 66*/ { BARCODE_PLESSEY, 1, -1, "7", "758" },
|
||||
/* 67*/ { BARCODE_PLESSEY, 1, BARCODE_PLAIN_HRT, "7", "758" },
|
||||
/* 68*/ { BARCODE_PLESSEY, -1, -1, "75", "75" },
|
||||
/* 69*/ { BARCODE_PLESSEY, -1, BARCODE_PLAIN_HRT, "75", "7580" },
|
||||
/* 70*/ { BARCODE_PLESSEY, 1, -1, "75", "7580" },
|
||||
/* 71*/ { BARCODE_PLESSEY, 1, BARCODE_PLAIN_HRT, "75", "7580" },
|
||||
/* 72*/ { BARCODE_PLESSEY, -1, -1, "993", "993" },
|
||||
/* 73*/ { BARCODE_PLESSEY, -1, BARCODE_PLAIN_HRT, "993", "993AA" },
|
||||
/* 74*/ { BARCODE_PLESSEY, 1, -1, "993", "993AA" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -158,12 +206,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -214,6 +214,74 @@ static void test_japanpost(const testCtx *const p_ctx) {
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_hrt(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
struct item {
|
||||
int symbology;
|
||||
int option_2;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_FLAT, -1, -1, "12345", "" }, /* None */
|
||||
/* 1*/ { BARCODE_FLAT, -1, BARCODE_PLAIN_HRT, "12345", "12345" },
|
||||
/* 2*/ { BARCODE_POSTNET, -1, -1, "12345", "" }, /* None */
|
||||
/* 3*/ { BARCODE_POSTNET, -1, BARCODE_PLAIN_HRT, "12345", "123455" },
|
||||
/* 4*/ { BARCODE_FIM, -1, -1, "e", "" }, /* None */
|
||||
/* 5*/ { BARCODE_FIM, -1, BARCODE_PLAIN_HRT, "e", "E" },
|
||||
/* 6*/ { BARCODE_CEPNET, -1, -1, "12345678", "" }, /* None */
|
||||
/* 7*/ { BARCODE_CEPNET, -1, BARCODE_PLAIN_HRT, "12345678", "123456784" },
|
||||
/* 8*/ { BARCODE_RM4SCC, -1, -1, "BX11LT1A", "" }, /* None*/
|
||||
/* 9*/ { BARCODE_RM4SCC, -1, BARCODE_PLAIN_HRT, "BX11LT1A", "BX11LT1AI" },
|
||||
/* 10*/ { BARCODE_JAPANPOST, -1, -1, "1234", "" }, /* None*/
|
||||
/* 11*/ { BARCODE_JAPANPOST, -1, BARCODE_PLAIN_HRT, "1234", "1234" }, /* Note check char not included */
|
||||
/* 12*/ { BARCODE_JAPANPOST, -1, BARCODE_PLAIN_HRT, "123456-AB", "123456-AB" }, /* Ditto */
|
||||
/* 13*/ { BARCODE_KOREAPOST, -1, -1, "123456", "1234569" },
|
||||
/* 14*/ { BARCODE_KOREAPOST, -1, BARCODE_PLAIN_HRT, "123456", "1234569" }, /* No difference */
|
||||
/* 15*/ { BARCODE_PLANET, -1, -1, "12345678901", "" }, /* None */
|
||||
/* 16*/ { BARCODE_PLANET, -1, BARCODE_PLAIN_HRT, "12345678901", "123456789014" },
|
||||
/* 17*/ { BARCODE_KIX, -1, -1, "0123456789ABCDEFGH", "" }, /* None */
|
||||
/* 18*/ { BARCODE_KIX, -1, BARCODE_PLAIN_HRT, "0123456789ABCDEFGH", "0123456789ABCDEFGH" },
|
||||
/* 19*/ { BARCODE_DAFT, -1, -1, "DAFT", "" }, /* None */
|
||||
/* 20*/ { BARCODE_DAFT, -1, BARCODE_PLAIN_HRT, "DAFT", "DAFT" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_input(const testCtx *const p_ctx) {
|
||||
int debug = p_ctx->debug;
|
||||
|
||||
|
@ -641,6 +709,7 @@ int main(int argc, char *argv[]) {
|
|||
{ "test_large", test_large },
|
||||
{ "test_koreapost", test_koreapost },
|
||||
{ "test_japanpost", test_japanpost },
|
||||
{ "test_hrt", test_hrt },
|
||||
{ "test_input", test_input },
|
||||
{ "test_encode", test_encode },
|
||||
{ "test_perf", test_perf },
|
||||
|
|
|
@ -1301,7 +1301,7 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int symbology;
|
||||
int input_mode;
|
||||
int output_options;
|
||||
const char *data;
|
||||
|
||||
int ret;
|
||||
|
@ -1310,18 +1310,28 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_DBAR_OMN, -1, "1234567890123", 0, "(01)12345678901231" },
|
||||
/* 1*/ { BARCODE_DBAR_OMN, -1, "12345678901231", 0, "(01)12345678901231" },
|
||||
/* 1*/ { BARCODE_DBAR_OMN, BARCODE_PLAIN_HRT, "1234567890123", 0, "0112345678901231" },
|
||||
/* 2*/ { BARCODE_DBAR_OMN, -1, "12345678901231", 0, "(01)12345678901231" },
|
||||
/* 3*/ { BARCODE_DBAR_OMN, BARCODE_PLAIN_HRT, "12345678901231", 0, "0112345678901231" },
|
||||
/* 4*/ { BARCODE_DBAR_OMN, -1, "1000000000009", 0, "(01)10000000000090" },
|
||||
/* 5*/ { BARCODE_DBAR_LTD, -1, "1341056790138", 0, "(01)13410567901384" },
|
||||
/* 6*/ { BARCODE_DBAR_LTD, -1, "13410567901384", 0, "(01)13410567901384" },
|
||||
/* 9*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */
|
||||
/* 10*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "" }, /* No HRT for stacked */
|
||||
/* 11*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "" },
|
||||
/* 12*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "" },
|
||||
/* 5*/ { BARCODE_DBAR_OMN, BARCODE_PLAIN_HRT, "1000000000009", 0, "0110000000000090" },
|
||||
/* 6*/ { BARCODE_DBAR_LTD, -1, "1341056790138", 0, "(01)13410567901384" },
|
||||
/* 7*/ { BARCODE_DBAR_LTD, BARCODE_PLAIN_HRT, "1341056790138", 0, "0113410567901384" },
|
||||
/* 8*/ { BARCODE_DBAR_LTD, -1, "13410567901384", 0, "(01)13410567901384" },
|
||||
/* 9*/ { BARCODE_DBAR_LTD, BARCODE_PLAIN_HRT, "13410567901384", 0, "0113410567901384" },
|
||||
/* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */
|
||||
/* 11*/ { BARCODE_DBAR_EXP, BARCODE_PLAIN_HRT, "[01]12345678901231", 0, "0112345678901231" },
|
||||
/* 12*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "" }, /* No HRT for stacked */
|
||||
/* 13*/ { BARCODE_DBAR_STK, BARCODE_PLAIN_HRT, "12345678901231", 0, "" },
|
||||
/* 14*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "" },
|
||||
/* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_PLAIN_HRT, "10000000000090", 0, "" },
|
||||
/* 16*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "" },
|
||||
/* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_PLAIN_HRT, "[01]12345678901231", 0, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -1332,12 +1342,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
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);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -91,25 +91,38 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int symbology;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int length;
|
||||
|
||||
const char *expected;
|
||||
int expected_length;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_TELEPEN, "ABC1234.;$", -1, "ABC1234.;$" },
|
||||
/* 1*/ { BARCODE_TELEPEN, "abc1234.;$", -1, "abc1234.;$" },
|
||||
/* 2*/ { BARCODE_TELEPEN, "ABC1234\001", -1, "ABC1234\001" },
|
||||
/* 3*/ { BARCODE_TELEPEN, "ABC\0001234", 8, "ABC 1234" },
|
||||
/* 4*/ { BARCODE_TELEPEN_NUM, "1234", -1, "1234" },
|
||||
/* 5*/ { BARCODE_TELEPEN_NUM, "123X", -1, "123X" },
|
||||
/* 6*/ { BARCODE_TELEPEN_NUM, "123x", -1, "123X" }, /* Converts to upper */
|
||||
/* 7*/ { BARCODE_TELEPEN_NUM, "12345", -1, "012345" }, /* Adds leading zero if odd */
|
||||
/* 0*/ { BARCODE_TELEPEN, -1, "ABC1234.;$", -1, "ABC1234.;$", -1 },
|
||||
/* 1*/ { BARCODE_TELEPEN, BARCODE_PLAIN_HRT, "ABC1234.;$", -1, "ABC1234.;$^", -1 },
|
||||
/* 2*/ { BARCODE_TELEPEN, -1, "abc1234.;$", -1, "abc1234.;$", -1 },
|
||||
/* 3*/ { BARCODE_TELEPEN, BARCODE_PLAIN_HRT, "abc1234.;$", -1, "abc1234.;$}", -1 },
|
||||
/* 4*/ { BARCODE_TELEPEN, -1, "ABC1234\001", -1, "ABC1234 ", -1 }, /* Note used to put control chars (apart from NUL) in HRT */
|
||||
/* 5*/ { BARCODE_TELEPEN, BARCODE_PLAIN_HRT, "ABC1234\001", -1, "ABC1234\001k", -1 },
|
||||
/* 6*/ { BARCODE_TELEPEN, -1, "ABC\0001234", 8, "ABC 1234", -1 },
|
||||
/* 7*/ { BARCODE_TELEPEN, BARCODE_PLAIN_HRT, "ABC\0001234", 8, "ABC\0001234l", 9 },
|
||||
/* 8*/ { BARCODE_TELEPEN, -1, "ABK0", -1, "ABK0", -1 },
|
||||
/* 9*/ { BARCODE_TELEPEN, BARCODE_PLAIN_HRT, "ABK0", -1, "ABK0\000", 5 },
|
||||
/* 10*/ { BARCODE_TELEPEN_NUM, -1, "1234", -1, "1234", -1 },
|
||||
/* 11*/ { BARCODE_TELEPEN_NUM, BARCODE_PLAIN_HRT, "1234", -1, "1234\033", -1 },
|
||||
/* 12*/ { BARCODE_TELEPEN_NUM, -1, "123X", -1, "123X", -1 },
|
||||
/* 13*/ { BARCODE_TELEPEN_NUM, BARCODE_PLAIN_HRT, "123X", -1, "123XD", -1 },
|
||||
/* 14*/ { BARCODE_TELEPEN_NUM, -1, "123x", -1, "123X", -1 }, /* Converts to upper */
|
||||
/* 15*/ { BARCODE_TELEPEN_NUM, BARCODE_PLAIN_HRT, "123x", -1, "123XD", -1 },
|
||||
/* 16*/ { BARCODE_TELEPEN_NUM, -1, "12345", -1, "012345", -1 }, /* Adds leading zero if odd */
|
||||
/* 17*/ { BARCODE_TELEPEN_NUM, BARCODE_PLAIN_HRT, "12345", -1, "012345h", -1 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -120,12 +133,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, data[i].length, debug);
|
||||
expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
|
||||
i, symbol->text, data[i].expected, expected_length);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -650,73 +650,110 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
|
||||
struct item {
|
||||
int symbology;
|
||||
int output_options;
|
||||
const char *data;
|
||||
int ret;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_EANX, "12345678901", 0, "0123456789012" },
|
||||
/* 1*/ { BARCODE_EANX, "123456789012", 0, "1234567890128" },
|
||||
/* 2*/ { BARCODE_EANX, "1234567890128", 0, "1234567890128" }, /* EANX accepts CHK (treated as such if no leading zeroes required) */
|
||||
/* 3*/ { BARCODE_EANX_CHK, "1234567890128", 0, "1234567890128" },
|
||||
/* 4*/ { BARCODE_EANX_CHK, "123456789012", 0, "0123456789012" }, /* '2' happens to be correct check digit for "012345678901" */
|
||||
/* 5*/ { BARCODE_EANX, "1234567890128+1", 0, "1234567890128+01" },
|
||||
/* 6*/ { BARCODE_EANX_CHK, "1234567890128+1", 0, "1234567890128+01" },
|
||||
/* 7*/ { BARCODE_EANX, "12345678", 0, "0000123456784" },
|
||||
/* 8*/ { BARCODE_EANX, "1234567", 0, "12345670" }, /* EAN-8 */
|
||||
/* 9*/ { BARCODE_EANX_CHK, "12345670", 0, "12345670" }, /* EAN-8 */
|
||||
/* 10*/ { BARCODE_EANX, "123456", 0, "01234565" }, /* EAN-8 */
|
||||
/* 11*/ { BARCODE_EANX_CHK, "123457", 0, "00123457" }, /* EAN-8 */
|
||||
/* 12*/ { BARCODE_EANX, "12345", 0, "12345" }, /* EAN-5 */
|
||||
/* 13*/ { BARCODE_EANX, "123", 0, "00123" }, /* EAN-5 */
|
||||
/* 14*/ { BARCODE_EANX, "12", 0, "12" }, /* EAN-2 */
|
||||
/* 15*/ { BARCODE_EANX, "1", 0, "01" }, /* EAN-2 */
|
||||
/* 16*/ { BARCODE_EANX, "0", 0, "00" }, /* EAN-2 */
|
||||
/* 17*/ { BARCODE_ISBNX, "0", 0, "9780000000002" },
|
||||
/* 18*/ { BARCODE_ISBNX, "123456789X", 0, "9781234567897" },
|
||||
/* 19*/ { BARCODE_ISBNX, "9781234567897", 0, "9781234567897" },
|
||||
/* 20*/ { BARCODE_ISBNX, "9791234567896+12", 0, "9791234567896+12" },
|
||||
/* 21*/ { BARCODE_UPCA, "12345678901", 0, "123456789012" },
|
||||
/* 22*/ { BARCODE_UPCA, "123456789012", 0, "123456789012" },
|
||||
/* 23*/ { BARCODE_UPCA_CHK, "123456789012", 0, "123456789012" },
|
||||
/* 24*/ { BARCODE_UPCA, "12345678905+1", 0, "123456789050+01" },
|
||||
/* 25*/ { BARCODE_UPCA_CHK, "123456789050+1", 0, "123456789050+01" },
|
||||
/* 26*/ { BARCODE_UPCA, "123456789050+123", 0, "123456789050+00123" },
|
||||
/* 27*/ { BARCODE_UPCA_CHK, "123456789050+123", 0, "123456789050+00123" },
|
||||
/* 28*/ { BARCODE_UPCE, "12345", 0, "00123457" }, /* equivalent: 00123400005, hrt: 00123457, Check digit: 7 */
|
||||
/* 29*/ { BARCODE_UPCE_CHK, "12344", 0, "00012344" }, /* equivalent: 00012000003, hrt: 00012344, Check digit: 4 */
|
||||
/* 30*/ { BARCODE_UPCE, "123456", 0, "01234565" }, /* equivalent: 01234500006, hrt: 01234565, Check digit: 5 */
|
||||
/* 31*/ { BARCODE_UPCE_CHK, "123457", 0, "00123457" }, /* equivalent: 00123400005, hrt: 00123457, Check digit: 7 */
|
||||
/* 32*/ { BARCODE_UPCE, "1234567", 0, "12345670" }, /* equivalent: 12345600007, hrt: 12345670, Check digit: 0 */
|
||||
/* 33*/ { BARCODE_UPCE_CHK, "1234565", 0, "01234565" }, /* equivalent: 01234500006, hrt: 01234565, Check digit: 5 */
|
||||
/* 34*/ { BARCODE_UPCE_CHK, "12345670", 0, "12345670" }, /* equivalent: 12345600007, hrt: 12345670, Check digit: 0 */
|
||||
/* 35*/ { BARCODE_UPCE, "2345678", 0, "03456781" }, /* 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1 */
|
||||
/* 36*/ { BARCODE_UPCE_CHK, "23456781", 0, "03456781" }, /* 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1 */
|
||||
/* 37*/ { BARCODE_UPCE, "123455", 0, "01234558" }, /* equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a)) */
|
||||
/* 38*/ { BARCODE_UPCE_CHK, "1234558", 0, "01234558" }, /* equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a)) */
|
||||
/* 39*/ { BARCODE_UPCE, "456784", 0, "04567840" }, /* equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b)) */
|
||||
/* 40*/ { BARCODE_UPCE_CHK, "4567840", 0, "04567840" }, /* equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b)) */
|
||||
/* 41*/ { BARCODE_UPCE, "345670", 0, "03456703" }, /* equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c)) */
|
||||
/* 42*/ { BARCODE_UPCE_CHK, "3456703", 0, "03456703" }, /* equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c)) */
|
||||
/* 43*/ { BARCODE_UPCE, "984753", 0, "09847531" }, /* equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d)) */
|
||||
/* 44*/ { BARCODE_UPCE_CHK, "9847531", 0, "09847531" }, /* equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d)) */
|
||||
/* 45*/ { BARCODE_UPCE, "123453", 0, "01234531" },
|
||||
/* 46*/ { BARCODE_UPCE, "000000", 0, "00000000" },
|
||||
/* 47*/ { BARCODE_UPCE, "0000000", 0, "00000000" },
|
||||
/* 48*/ { BARCODE_UPCE, "1000000", 0, "10000007" },
|
||||
/* 49*/ { BARCODE_UPCE, "2000000", 0, "00000000" }, /* First char 2-9 ignored, replaced with 0 */
|
||||
/* 50*/ { BARCODE_UPCE, "3000000", 0, "00000000" },
|
||||
/* 51*/ { BARCODE_UPCE, "8000000", 0, "00000000" },
|
||||
/* 52*/ { BARCODE_UPCE, "9000000", 0, "00000000" },
|
||||
/* 53*/ { BARCODE_UPCE, "1234567+1", 0, "12345670+01" },
|
||||
/* 54*/ { BARCODE_UPCE, "12345670+1", 0, "12345670+01" },
|
||||
/* 55*/ { BARCODE_UPCE_CHK, "12345670+1", 0, "12345670+01" },
|
||||
/* 56*/ { BARCODE_UPCE_CHK, "1234565+1", 0, "01234565+01" },
|
||||
/* 0*/ { BARCODE_EANX, -1, "12345678901", 0, "0123456789012" },
|
||||
/* 1*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "12345678901", 0, "0123456789012" },
|
||||
/* 2*/ { BARCODE_EANX, -1, "123456789012", 0, "1234567890128" },
|
||||
/* 3*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "123456789012", 0, "1234567890128" },
|
||||
/* 4*/ { BARCODE_EANX, -1, "1234567890128", 0, "1234567890128" }, /* EANX accepts CHK (treated as such if no leading zeroes required) */
|
||||
/* 5*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, "1234567890128" },
|
||||
/* 6*/ { BARCODE_EANX_CHK, BARCODE_PLAIN_HRT, "1234567890128", 0, "1234567890128" },
|
||||
/* 7*/ { BARCODE_EANX_CHK, -1, "123456789012", 0, "0123456789012" }, /* '2' happens to be correct check digit for "012345678901" */
|
||||
/* 8*/ { BARCODE_EANX, -1, "1234567890128+1", 0, "1234567890128+01" },
|
||||
/* 9*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "1234567890128+1", 0, "123456789012801" },
|
||||
/* 10*/ { BARCODE_EANX_CHK, -1, "1234567890128+1", 0, "1234567890128+01" },
|
||||
/* 11*/ { BARCODE_EANX_CHK, BARCODE_PLAIN_HRT, "1234567890128+1", 0, "123456789012801" },
|
||||
/* 12*/ { BARCODE_EANX, -1, "12345678", 0, "0000123456784" },
|
||||
/* 13*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "12345678", 0, "0000123456784" },
|
||||
/* 14*/ { BARCODE_EANX, -1, "1234567", 0, "12345670" }, /* EAN-8 */
|
||||
/* 15*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "1234567", 0, "12345670" },
|
||||
/* 16*/ { BARCODE_EANX_CHK, -1, "12345670", 0, "12345670" }, /* EAN-8 */
|
||||
/* 17*/ { BARCODE_EANX_CHK, BARCODE_PLAIN_HRT, "12345670", 0, "12345670" },
|
||||
/* 18*/ { BARCODE_EANX, -1, "123456", 0, "01234565" }, /* EAN-8 */
|
||||
/* 19*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "123456", 0, "01234565" },
|
||||
/* 20*/ { BARCODE_EANX_CHK, -1, "123457", 0, "00123457" }, /* EAN-8 */
|
||||
/* 21*/ { BARCODE_EANX, -1, "12345", 0, "12345" }, /* EAN-5 */
|
||||
/* 22*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "12345", 0, "12345" },
|
||||
/* 23*/ { BARCODE_EANX, -1, "123", 0, "00123" }, /* EAN-5 */
|
||||
/* 24*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "123", 0, "00123" },
|
||||
/* 25*/ { BARCODE_EANX, -1, "12", 0, "12" }, /* EAN-2 */
|
||||
/* 26*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "12", 0, "12" },
|
||||
/* 27*/ { BARCODE_EANX, -1, "1", 0, "01" }, /* EAN-2 */
|
||||
/* 28*/ { BARCODE_EANX, BARCODE_PLAIN_HRT, "1", 0, "01" },
|
||||
/* 29*/ { BARCODE_EANX, -1, "0", 0, "00" }, /* EAN-2 */
|
||||
/* 30*/ { BARCODE_ISBNX, -1, "0", 0, "9780000000002" },
|
||||
/* 31*/ { BARCODE_ISBNX, BARCODE_PLAIN_HRT, "0", 0, "9780000000002" },
|
||||
/* 32*/ { BARCODE_ISBNX, -1, "123456789X", 0, "9781234567897" },
|
||||
/* 33*/ { BARCODE_ISBNX, BARCODE_PLAIN_HRT, "123456789X", 0, "9781234567897" },
|
||||
/* 34*/ { BARCODE_ISBNX, -1, "9781234567897", 0, "9781234567897" },
|
||||
/* 35*/ { BARCODE_ISBNX, BARCODE_PLAIN_HRT, "9781234567897", 0, "9781234567897" },
|
||||
/* 36*/ { BARCODE_ISBNX, -1, "9791234567896+12", 0, "9791234567896+12" },
|
||||
/* 37*/ { BARCODE_ISBNX, BARCODE_PLAIN_HRT, "9791234567896+12", 0, "979123456789612" },
|
||||
/* 38*/ { BARCODE_UPCA, -1, "12345678901", 0, "123456789012" },
|
||||
/* 39*/ { BARCODE_UPCA, BARCODE_PLAIN_HRT, "12345678901", 0, "123456789012" },
|
||||
/* 40*/ { BARCODE_UPCA, -1, "123456789012", 0, "123456789012" },
|
||||
/* 41*/ { BARCODE_UPCA, BARCODE_PLAIN_HRT, "123456789012", 0, "123456789012" },
|
||||
/* 42*/ { BARCODE_UPCA_CHK, -1, "123456789012", 0, "123456789012" },
|
||||
/* 43*/ { BARCODE_UPCA_CHK, BARCODE_PLAIN_HRT, "123456789012", 0, "123456789012" },
|
||||
/* 44*/ { BARCODE_UPCA, -1, "12345678905+1", 0, "123456789050+01" },
|
||||
/* 45*/ { BARCODE_UPCA, BARCODE_PLAIN_HRT, "12345678905+1", 0, "12345678905001" },
|
||||
/* 46*/ { BARCODE_UPCA_CHK, -1, "123456789050+1", 0, "123456789050+01" },
|
||||
/* 47*/ { BARCODE_UPCA_CHK, BARCODE_PLAIN_HRT, "123456789050+1", 0, "12345678905001" },
|
||||
/* 48*/ { BARCODE_UPCA, -1, "123456789050+123", 0, "123456789050+00123" },
|
||||
/* 49*/ { BARCODE_UPCA, BARCODE_PLAIN_HRT, "123456789050+123", 0, "12345678905000123" },
|
||||
/* 50*/ { BARCODE_UPCA_CHK, -1, "123456789050+123", 0, "123456789050+00123" },
|
||||
/* 51*/ { BARCODE_UPCE, -1, "12345", 0, "00123457" }, /* equivalent: 00123400005, hrt: 00123457, Check digit: 7 */
|
||||
/* 52*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "12345", 0, "00123457" },
|
||||
/* 53*/ { BARCODE_UPCE_CHK, -1, "12344", 0, "00012344" }, /* equivalent: 00012000003, hrt: 00012344, Check digit: 4 */
|
||||
/* 54*/ { BARCODE_UPCE_CHK, BARCODE_PLAIN_HRT, "12344", 0, "00012344" },
|
||||
/* 55*/ { BARCODE_UPCE, -1, "123456", 0, "01234565" }, /* equivalent: 01234500006, hrt: 01234565, Check digit: 5 */
|
||||
/* 56*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "123456", 0, "01234565" },
|
||||
/* 57*/ { BARCODE_UPCE_CHK, -1, "123457", 0, "00123457" }, /* equivalent: 00123400005, hrt: 00123457, Check digit: 7 */
|
||||
/* 58*/ { BARCODE_UPCE_CHK, BARCODE_PLAIN_HRT, "123457", 0, "00123457" },
|
||||
/* 59*/ { BARCODE_UPCE, -1, "1234567", 0, "12345670" }, /* equivalent: 12345600007, hrt: 12345670, Check digit: 0 */
|
||||
/* 60*/ { BARCODE_UPCE_CHK, -1, "1234565", 0, "01234565" }, /* equivalent: 01234500006, hrt: 01234565, Check digit: 5 */
|
||||
/* 61*/ { BARCODE_UPCE_CHK, -1, "12345670", 0, "12345670" }, /* equivalent: 12345600007, hrt: 12345670, Check digit: 0 */
|
||||
/* 62*/ { BARCODE_UPCE, -1, "2345678", 0, "03456781" }, /* 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1 */
|
||||
/* 63*/ { BARCODE_UPCE_CHK, -1, "23456781", 0, "03456781" }, /* 2 ignored, equivalent: 03456700008, hrt: 03456781, Check digit: 1 */
|
||||
/* 64*/ { BARCODE_UPCE, -1, "123455", 0, "01234558" }, /* equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a)) */
|
||||
/* 65*/ { BARCODE_UPCE_CHK, -1, "1234558", 0, "01234558" }, /* equivalent: 01234500005, hrt: 01234558, Check digit: 8 (BS 797 Rule 3 (a)) */
|
||||
/* 66*/ { BARCODE_UPCE, -1, "456784", 0, "04567840" }, /* equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b)) */
|
||||
/* 67*/ { BARCODE_UPCE_CHK, -1, "4567840", 0, "04567840" }, /* equivalent: 04567000008, hrt: 04567840, Check digit: 0 (BS 797 Rule 3 (b)) */
|
||||
/* 68*/ { BARCODE_UPCE, -1, "345670", 0, "03456703" }, /* equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c)) */
|
||||
/* 69*/ { BARCODE_UPCE_CHK, -1, "3456703", 0, "03456703" }, /* equivalent: 03400000567, hrt: 03456703, Check digit: 3 (BS 797 Rule 3 (c)) */
|
||||
/* 70*/ { BARCODE_UPCE, -1, "984753", 0, "09847531" }, /* equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d)) */
|
||||
/* 71*/ { BARCODE_UPCE_CHK, -1, "9847531", 0, "09847531" }, /* equivalent: 09840000075, hrt: 09847531, Check digit: 1 (BS 797 Rule 3 (d)) */
|
||||
/* 72*/ { BARCODE_UPCE, -1, "123453", 0, "01234531" },
|
||||
/* 73*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "123453", 0, "01234531" },
|
||||
/* 74*/ { BARCODE_UPCE, -1, "000000", 0, "00000000" },
|
||||
/* 75*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "000000", 0, "00000000" },
|
||||
/* 76*/ { BARCODE_UPCE, -1, "0000000", 0, "00000000" },
|
||||
/* 77*/ { BARCODE_UPCE, -1, "1000000", 0, "10000007" },
|
||||
/* 78*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "1000000", 0, "10000007" },
|
||||
/* 79*/ { BARCODE_UPCE, -1, "2000000", 0, "00000000" }, /* First char 2-9 ignored, replaced with 0 */
|
||||
/* 80*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "2000000", 0, "00000000" },
|
||||
/* 81*/ { BARCODE_UPCE, -1, "3000000", 0, "00000000" },
|
||||
/* 82*/ { BARCODE_UPCE, -1, "8000000", 0, "00000000" },
|
||||
/* 83*/ { BARCODE_UPCE, -1, "9000000", 0, "00000000" },
|
||||
/* 84*/ { BARCODE_UPCE, -1, "1234567+1", 0, "12345670+01" },
|
||||
/* 85*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "1234567+1", 0, "1234567001" },
|
||||
/* 86*/ { BARCODE_UPCE, -1, "12345670+1", 0, "12345670+01" },
|
||||
/* 87*/ { BARCODE_UPCE, BARCODE_PLAIN_HRT, "12345670+1", 0, "1234567001" },
|
||||
/* 88*/ { BARCODE_UPCE_CHK, -1, "12345670+1", 0, "12345670+01" },
|
||||
/* 89*/ { BARCODE_UPCE_CHK, BARCODE_PLAIN_HRT, "12345670+1", 0, "1234567001" },
|
||||
/* 90*/ { BARCODE_UPCE_CHK, -1, "1234565+1", 0, "01234565+01" },
|
||||
/* 91*/ { BARCODE_UPCE_CHK, BARCODE_PLAIN_HRT, "1234565+1", 0, "0123456501" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
struct zint_symbol *symbol = NULL;
|
||||
int expected_length;
|
||||
|
||||
testStartSymbol("test_hrt", &symbol);
|
||||
|
||||
|
@ -727,12 +764,18 @@ static void test_hrt(const testCtx *const p_ctx) {
|
|||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
|
||||
data[i].data, -1, debug);
|
||||
expected_length = (int) strlen(data[i].expected);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
||||
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
|
||||
i, symbol->text_length, expected_length);
|
||||
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->text, data[i].expected);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "../eci.h"
|
||||
#include "../output.h"
|
||||
|
||||
#define ustrcpy(target, source) strcpy((char *) (target), (const char *) (source))
|
||||
|
||||
static int testTests = 0;
|
||||
static int testFailed = 0;
|
||||
static int testSkipped = 0;
|
||||
|
@ -124,7 +126,7 @@ void assert_notequal(int e1, int e2, const char *fmt, ...) {
|
|||
#ifdef _WIN32
|
||||
#define utf8_to_wide(u, w) \
|
||||
{ \
|
||||
int lenW; /* Includes NUL terminator */ \
|
||||
int lenW; /* Includes terminating NUL */ \
|
||||
if ((lenW = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u, -1, NULL, 0)) == 0) return 0; \
|
||||
w = (wchar_t *) z_alloca(sizeof(wchar_t) * lenW); \
|
||||
if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u, -1, w, lenW) == 0) return 0; \
|
||||
|
@ -681,6 +683,8 @@ const char *testUtilOutputOptionsName(int output_options) {
|
|||
{ "COMPLIANT_HEIGHT", COMPLIANT_HEIGHT, 0x2000 },
|
||||
{ "EANUPC_GUARD_WHITESPACE", EANUPC_GUARD_WHITESPACE, 0x4000 },
|
||||
{ "EMBED_VECTOR_FONT", EMBED_VECTOR_FONT, 0x8000 },
|
||||
{ "BARCODE_MEMORY_FILE", BARCODE_MEMORY_FILE, 0x10000 },
|
||||
{ "BARCODE_PLAIN_HRT", BARCODE_PLAIN_HRT, 0x20000 },
|
||||
};
|
||||
static int const data_size = ARRAY_SIZE(data);
|
||||
int set = 0;
|
||||
|
@ -4183,12 +4187,12 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
|||
expected = escaped;
|
||||
}
|
||||
if (gs1 && symbology != BARCODE_EAN14 && symbology != BARCODE_NVE18) {
|
||||
ret = gs1_verify(symbol, (const unsigned char *) expected, expected_len, (unsigned char *) reduced);
|
||||
ret = gs1_verify(symbol, (const unsigned char *) expected, expected_len, (unsigned char *) reduced,
|
||||
&expected_len);
|
||||
if (ret >= ZINT_ERROR) {
|
||||
sprintf(msg, "gs1_verify %d != 0", ret);
|
||||
return 4;
|
||||
}
|
||||
expected_len = (int) strlen(reduced);
|
||||
expected = reduced;
|
||||
if (primary) {
|
||||
/* TODO: */
|
||||
|
@ -4450,7 +4454,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
|||
/* Add hyphen at start */
|
||||
pzn[0] = '-';
|
||||
memcpy(pzn + 1, expected, expected_len);
|
||||
if ((symbol->option_2 == 0 && expected_len != 8) || (symbol->option_2 == 1 && expected_len != 7)) {
|
||||
if ((symbol->option_2 != 1 && expected_len != 8) || (symbol->option_2 == 1 && expected_len != 7)) {
|
||||
cmp_len--; /* Don't bother with check digit */
|
||||
}
|
||||
expected = pzn;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue