2019-09-02 08:09:47 +12:00
|
|
|
/*
|
|
|
|
libzint - the open source barcode library
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
|
2019-09-02 08:09:47 +12:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
|
|
|
without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
SUCH DAMAGE.
|
|
|
|
*/
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2019-09-02 08:09:47 +12:00
|
|
|
/*
|
|
|
|
* Intelligent Mail barcode Encoder Test Case Reference Set (csv file)
|
|
|
|
* Copyright (C) 2009 U.S. Postal Service
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "testcommon.h"
|
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define TEST_PERF_TIME(arg) (((arg) * 1000.0) / CLOCKS_PER_SEC)
|
|
|
|
|
|
|
|
#define TEST_CSV_PERF_ITERATIONS 100
|
|
|
|
|
2022-12-05 23:11:36 +13:00
|
|
|
#if 0
|
|
|
|
#define TEST_IMAIL_CSV_MAX 300
|
|
|
|
#endif
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_csv(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-05-06 09:28:25 +12:00
|
|
|
|
2021-06-14 11:48:29 +12:00
|
|
|
char csvfile[1024];
|
|
|
|
FILE *fd;
|
2019-09-02 08:09:47 +12:00
|
|
|
char buffer[1024];
|
|
|
|
char id[10];
|
|
|
|
char tracking_code[50];
|
|
|
|
char routing_code[50];
|
|
|
|
char data[102];
|
|
|
|
char expected_daft[70];
|
|
|
|
char return_code[10];
|
|
|
|
char actual_daft[70];
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
int lc = 0;
|
2021-06-14 11:48:29 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
int j;
|
|
|
|
clock_t start;
|
|
|
|
clock_t total = 0;
|
|
|
|
int test_performance = debug & ZINT_DEBUG_TEST_PERFORMANCE; /* -d 256 */
|
|
|
|
int perf_iterations = test_performance ? TEST_CSV_PERF_ITERATIONS : 1;
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
testStart("test_csv");
|
2021-06-14 11:48:29 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if (test_performance) {
|
|
|
|
printf("test_csv perf iterations: %d\n", perf_iterations);
|
|
|
|
}
|
|
|
|
|
2021-06-14 11:48:29 +12:00
|
|
|
assert_nonzero(testUtilDataPath(csvfile, sizeof(csvfile),
|
|
|
|
"/backend/tests/data/imail/usps/", "uspsIMbEncoderTestCases.csv"), "testUtilDataPath == 0\n");
|
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
for (j = 0; j < perf_iterations; j++) {
|
2023-05-11 08:29:09 +12:00
|
|
|
fd = testUtilOpen(csvfile, "r");
|
|
|
|
assert_nonnull(fd, "testUtilOpen(%s) == NULL", csvfile);
|
2021-06-14 11:48:29 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
|
|
|
|
const char *b;
|
|
|
|
struct zint_symbol *symbol;
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
lc++;
|
2020-05-06 09:28:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, lc - 1)) continue;
|
2020-05-06 09:28:25 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
#ifdef TEST_IMAIL_CSV_MAX
|
2022-09-13 06:26:04 +12:00
|
|
|
if (lc > TEST_IMAIL_CSV_MAX && p_ctx->index == -1) {
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
id[0] = tracking_code[0] = routing_code[0] = expected_daft[0] = return_code[0] = '\0';
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
b = testUtilReadCSVField(buffer, id, sizeof(id));
|
|
|
|
assert_nonnull(b, "lc:%d id b == NULL", lc);
|
|
|
|
assert_equal(*b, ',', "lc:%d id *b %c != ','", lc, *b);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
b = testUtilReadCSVField(++b, tracking_code, sizeof(tracking_code));
|
|
|
|
assert_nonnull(b, "lc:%d tracking_code b == NULL", lc);
|
|
|
|
assert_equal(*b, ',', "lc:%d tracking_code *b %c != ','", lc, *b);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
b = testUtilReadCSVField(++b, routing_code, sizeof(routing_code));
|
|
|
|
assert_nonnull(b, "lc:%d routing_code b == NULL", lc);
|
|
|
|
assert_equal(*b, ',', "lc:%d routing_code *b %c != ','", lc, *b);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
b = testUtilReadCSVField(++b, expected_daft, sizeof(expected_daft));
|
|
|
|
assert_nonnull(b, "lc:%d expected_daft b == NULL", lc);
|
|
|
|
assert_equal(*b, ',', "lc:%d expected_daft *b %c != ','", lc, *b);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
b = testUtilReadCSVField(++b, return_code, sizeof(return_code));
|
|
|
|
assert_nonnull(b, "lc:%d return_code b == NULL", lc);
|
|
|
|
assert_equal(*b, ',', "lc:%d return_code *b %c != ','", lc, *b);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
strcpy(data, tracking_code);
|
|
|
|
strcat(data, "-");
|
|
|
|
strcat(data, routing_code);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
2022-09-13 07:19:41 +12:00
|
|
|
assert_nonzero((int) strlen(data), "lc:%d strlen(data) == 0", lc);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
symbol = ZBarcode_Create();
|
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
symbol->symbology = BARCODE_USPS_IMAIL;
|
|
|
|
symbol->debug |= debug;
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if (test_performance) {
|
|
|
|
start = clock();
|
|
|
|
}
|
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data, (int) strlen(data));
|
|
|
|
if (test_performance) {
|
|
|
|
total += clock() - start;
|
|
|
|
}
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if (strcmp(return_code, "00") == 0) {
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
assert_zero(ret, "lc:%d ZBarcode_Encode ret %d != 0\n", lc, ret);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
assert_equal(symbol->rows, 3, "rows %d != 3", symbol->rows);
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
ret = testUtilDAFTConvert(symbol, actual_daft, sizeof(actual_daft));
|
|
|
|
assert_nonzero(ret, "lc:%d testUtilDAFTConvert == 0", lc);
|
|
|
|
assert_zero(strcmp(actual_daft, expected_daft), "lc:%d\n actual %s\nexpected %s\n", lc, actual_daft, expected_daft);
|
|
|
|
} else {
|
|
|
|
assert_nonzero(ret, "lc:%d ZBarcode_Encode ret %d == 0\n", lc, ret);
|
|
|
|
}
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
assert_zero(fclose(fd), "fclose != 0\n");
|
|
|
|
}
|
2019-09-02 08:09:47 +12:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if (test_performance) {
|
|
|
|
printf("test_csv perf total: %8gms\n", TEST_PERF_TIME(total));
|
|
|
|
}
|
2019-09-02 08:09:47 +12:00
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_hrt(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
|
|
|
char *expected;
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 0*/ { "53379777234994544928-51135759461", "" }, /* None */
|
2020-06-05 05:45:25 +12:00
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
testStart("test_hrt");
|
|
|
|
|
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
|
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_input(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
2020-06-05 05:45:25 +12:00
|
|
|
int ret;
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
};
|
2022-09-13 06:26:04 +12:00
|
|
|
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
2020-06-05 05:45:25 +12:00
|
|
|
struct item data[] = {
|
|
|
|
/* 0*/ { "53379777234994544928-51135759461", 0, 3, 129 },
|
|
|
|
/* 1*/ { "123456789012345678901234567890123", ZINT_ERROR_TOO_LONG, -1, -1 },
|
|
|
|
/* 2*/ { "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 3*/ { "12345678901234567890", 0, 3, 129 }, /* Tracker only, no ZIP */
|
|
|
|
/* 4*/ { "15345678901234567890", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Tracker 2nd char > 4 */
|
|
|
|
/* 5*/ { "1234567890123456789", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Tracker 20 chars */
|
|
|
|
/* 6*/ { "12345678901234567890-1234", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
|
2020-06-05 05:45:25 +12:00
|
|
|
/* 7*/ { "12345678901234567890-12345", 0, 3, 129 },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 8*/ { "12345678901234567890-123456", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
|
|
|
|
/* 9*/ { "12345678901234567890-12345678", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
|
2020-06-05 05:45:25 +12:00
|
|
|
/* 10*/ { "12345678901234567890-123456789", 0, 3, 129 },
|
2022-09-13 06:26:04 +12:00
|
|
|
/* 11*/ { "12345678901234567890-1234567890", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
|
2020-06-05 05:45:25 +12:00
|
|
|
/* 12*/ { "12345678901234567890-12345678901", 0, 3, 129 },
|
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
|
|
|
|
2022-10-14 01:33:59 +13:00
|
|
|
char cmp_buf[8192];
|
|
|
|
char cmp_msg[1024];
|
|
|
|
|
|
|
|
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
testStart("test_input");
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
|
|
|
|
2021-02-23 13:01:15 +13:00
|
|
|
if (ret < ZINT_ERROR) {
|
2020-06-05 05:45:25 +12:00
|
|
|
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);
|
2022-10-14 01:33:59 +13:00
|
|
|
|
|
|
|
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
|
|
|
char modules_dump[4096];
|
|
|
|
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
|
|
|
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
|
|
|
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
|
|
|
|
|
|
|
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
|
|
|
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
|
|
|
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
|
|
|
|
}
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
static void test_encode(const testCtx *const p_ctx) {
|
|
|
|
int debug = p_ctx->debug;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
struct item {
|
2020-10-04 10:51:08 +13:00
|
|
|
char *data;
|
2020-06-05 05:45:25 +12:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
int expected_rows;
|
|
|
|
int expected_width;
|
|
|
|
char *comment;
|
|
|
|
char *expected;
|
|
|
|
};
|
|
|
|
struct item data[] = {
|
|
|
|
/* 0*/ { "01234567094987654321-01234567891", 0, 3, 129, "USPS-B-3200 Rev. H (2015) Figure 5",
|
|
|
|
"101000001010001000001000001010001010001000000000101010000000000000001010100010000000001010100000000000100010101010001000001010001"
|
|
|
|
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
|
|
|
|
"000010001010101000100010000000100000001010001010000000101000100000100010001000101010001010101010000000001010000000101000100000100"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
int data_size = ARRAY_SIZE(data);
|
2021-06-24 02:00:49 +12:00
|
|
|
int i, length, ret;
|
|
|
|
struct zint_symbol *symbol;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
|
|
|
char escaped[1024];
|
2020-10-01 00:19:12 +13:00
|
|
|
char bwipp_buf[8192];
|
|
|
|
char bwipp_msg[1024];
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
|
2021-06-24 02:00:49 +12:00
|
|
|
|
|
|
|
testStart("test_encode");
|
|
|
|
|
|
|
|
for (i = 0; i < data_size; i++) {
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (testContinue(p_ctx, i)) continue;
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
symbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_nonnull(symbol, "Symbol not created\n");
|
|
|
|
|
2021-06-24 02:00:49 +12:00
|
|
|
length = testUtilSetSymbol(symbol, BARCODE_USPS_IMAIL, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
2020-06-05 05:45:25 +12:00
|
|
|
|
2020-10-04 10:51:08 +13:00
|
|
|
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
|
2020-06-05 05:45:25 +12:00
|
|
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
if (p_ctx->generate) {
|
2020-06-05 05:45:25 +12:00
|
|
|
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
|
|
|
|
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
|
|
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
2021-02-23 13:01:15 +13:00
|
|
|
testUtilModulesPrint(symbol, " ", "\n");
|
2020-06-05 05:45:25 +12:00
|
|
|
printf(" },\n");
|
|
|
|
} else {
|
2021-02-23 13:01:15 +13:00
|
|
|
if (ret < ZINT_ERROR) {
|
2021-06-24 02:00:49 +12:00
|
|
|
int width, row;
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
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);
|
|
|
|
|
2020-10-06 11:22:06 +13:00
|
|
|
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);
|
2020-10-01 00:19:12 +13:00
|
|
|
|
2020-10-27 01:21:43 +13:00
|
|
|
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL);
|
2020-10-06 11:22:06 +13:00
|
|
|
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
2020-10-01 00:19:12 +13:00
|
|
|
|
2020-10-06 11:22:06 +13:00
|
|
|
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
|
|
|
|
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
|
|
|
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected);
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ZBarcode_Delete(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
testFinish();
|
|
|
|
}
|
|
|
|
|
2020-05-06 09:28:25 +12:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
2022-09-13 06:26:04 +12:00
|
|
|
testFunction funcs[] = { /* name, func */
|
|
|
|
{ "test_csv", test_csv },
|
|
|
|
{ "test_hrt", test_hrt },
|
|
|
|
{ "test_input", test_input },
|
|
|
|
{ "test_encode", test_encode },
|
2020-05-06 09:28:25 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
2019-09-02 08:09:47 +12:00
|
|
|
|
|
|
|
testReport();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et : */
|