zint-barcode-generator/backend/tests
gitlost fcb3f9b422 GS1PARENS_MODE: allow parentheses in AI data if backslashed and
in `ESCAPE_MODE`
composite: empty primary now returns `ZINT_ERROR_INVALID_DATA`
  rather than `ZINT_ERROR_INVALID_OPTION`;
  check that primary NUL-terminated
library: check that `outfile` NUL-terminated
gs1: preface all routines and linters with "gs1_"
general: some code fiddling
2025-04-24 18:40:50 +01:00
..
cmake/Modules Remove further refs to QZint; win32/README; add zintconfig.h to Win make files 2020-11-24 22:22:12 +00:00
data UPCA/UPCE: descend add-ons to same level as guards following 2024-11-05 22:50:03 +00:00
fuzz - AZTEC/CHANNEL/CODABLOCKF/CODE16K/CODE49/CODEONE/DATAMATRIX/ 2025-03-07 16:51:36 +00:00
tools Re commit [789e04] and [86363f] allow prefixes without check digit 2025-04-21 18:45:23 +01:00
CMakeLists.txt - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
README - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_2of5.c Re commit [789e04] and [86363f] allow prefixes without check digit 2025-04-21 18:45:23 +01:00
test_auspost.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_aztec.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_bc412.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_big5.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_big5_tab.h eci: Add support for all ECIs (Big5, Korean, UCS-2BE) 2021-01-11 18:11:41 +00:00
test_bmp.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_bwipp.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_channel.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_codabar.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_codablock.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_code.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_code1.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_code11.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_code16k.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_code49.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_code128.c Re commit [789e04] and [86363f] allow prefixes without check digit 2025-04-21 18:45:23 +01:00
test_common.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_composite.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_dmatrix.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_dotcode.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_dxfilmedge.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_eci.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_emf.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_filemem.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_gb2312.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_gb2312_tab.h eci: Add support for all ECIs (Big5, Korean, UCS-2BE) 2021-01-11 18:11:41 +00:00
test_gb18030.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_gb18030_tab.h eci: Add support for all ECIs (Big5, Korean, UCS-2BE) 2021-01-11 18:11:41 +00:00
test_gbk_tab.h eci.c: replace libiconv-adapted code with own implementations so 2022-06-02 20:32:25 +01:00
test_gif.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_gridmtx.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_gs1.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_hanxin.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_imail.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_iso3166.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_iso4217.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_ksx1001.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_ksx1001_tab.h Add convenience API funcs ZBarcode_UTF8_To_ECI() and 2025-03-02 20:50:55 +00:00
test_large.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_library.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_mailmark.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_maxicode.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_medical.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_output.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_pcx.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_pdf417.c - CODABLOCKF: fix misencodation of extended ASCII 0xB0-0xB9 when 2025-04-03 16:08:15 +01:00
test_perf.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_plessey.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_png.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_postal.c RAW_TEXT: expand UPC-A, UPC-E to EAN-13, and EAN-8 if has add-on, 2025-04-11 13:02:59 +01:00
test_print.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_ps.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_qr.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_random.c Re commit [789e04] and [86363f] allow prefixes without check digit 2025-04-21 18:45:23 +01:00
test_raster.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_reedsol.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_rss.c Re commit [789e04] and [86363f] allow prefixes without check digit 2025-04-21 18:45:23 +01:00
test_sjis.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_sjis_tab.h eci: Add support for all ECIs (Big5, Korean, UCS-2BE) 2021-01-11 18:11:41 +00:00
test_svg.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_telepen.c general: change BARCODE_RAW_TEXT to write to new zint_symbol 2025-03-28 10:02:19 +00:00
test_tif.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_ultra.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
test_upcean.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
test_vector.c - Add new symbologies BARCODE_EAN8, BARCODE_EAN_2ADDON, 2025-04-16 22:26:43 +01:00
testcommon.c GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00
testcommon.h GS1PARENS_MODE: allow parentheses in AI data if backslashed and 2025-04-24 18:40:50 +01:00

% backend/tests/README 2025-04-03

Zint backend test suite
-----------------------

In order to build the zint test suite, zint has to be compiled with the
ZINT_TEST option enabled:

  cd <project-dir>
  mkdir build
  cd build
  cmake -DZINT_TEST=ON ..
  cmake --build .

When using generators that support multiple build configurations, such as
Visual C++ Project Files (the default generator on win32), the configuration
can be provided via --config:

  cd <project-dir>
  mkdir build
  cd build
  cmake -DZINT_TEST=ON -DCMAKE_BUILD_TYPE=Debug ..
  cmake --build . --config Debug

Note specifying a matching CMAKE_BUILD_TYPE is required to set the test PATH
environment for Windows.

------------------------------------------------------------------------------

In order to run the test suite, the path of the zint library may need to be
communicated to the runtime linker. On UNIX-like systems, this is done by
exporting LD_LIBRARY_PATH to the path containing the zint library, which is
<build-dir>/backend:

  cd <project-dir>
  cd build
  export LD_LIBRARY_PATH=$(pwd)/backend

Setting LD_LIBRARY_PATH is not required if the zint library to be tested is
installed into a system library path ( /usr/lib for example ) prior to running
the tests, or if the tests are not run individually.

(On Windows, the PATH may need to be set to include the DLL location.)

------------------------------------------------------------------------------

To run all tests (within <build-dir>):

  ctest

When using a generator that does support multiple build configurations, the
configuration that was used to build the project has to be explicitly provided
to ctest, even if it was the default one:

  ctest -C Debug

For various useful options, e.g. matching (-R) and excluding (-E) tests, see
https://cmake.org/cmake/help/latest/manual/ctest.1.html#options

Tests can also be run individually, eg:

  backend/tests/test_common
  backend/tests/test_vector

To run a single test function within an individual test, use '-f <func-name>':

  backend/tests/test_common -f utf8_to_unicode
  backend/tests/test_dotcode -f input

To exclude a single test function, use '-n <func-name>':

  backend/tests/test_common -n utf8_to_unicode
  backend/tests/test_dotcode -n input

To run all test functions that match (i.e. contain) a string, use '-m <string>':

  backend/tests/test_common -m not_sane
  backend/tests/test_dotcode -m encode

To run a single dataset item in a single test function, use '-i <index>':

  backend/tests/test_dotcode -f input -i 2

To run a range of dataset items in a single test function, use '-i <start>-<end>':

  backend/tests/test_dotcode -f input -i 2-5

The '<start>' or '<end>' can be left out:

  backend/tests/test_dotcode -f input -i 2-

To exclude a single dataset item in a single test function, use '-x <index>':

  backend/tests/test_dotcode -f input -x 4

This can also take a range, '-x <start>-<end>':

  backend/tests/test_dotcode -f input -x 4-6

Exclude can be used multiple times (unlike '-i'):

  backend/tests/test_dotcode -f input -x 4 -x 6-8

The include and exclude options can be used together:

  backend/tests/test_dotcode -f input -i 2-7 -x 4 -x 6

To show debug info (if any), use '-d <flag>':

  backend/tests/test_dotcode -f input -i 2 -d 1

E.g. to print which dataset items are being run, use '-d 16':

  backend/tests/test_dotcode -f input -d 16 -i 2

(for other flags see <project-dir>/backend/tests/testcommon.h)

To run a test against BWIPP (if any), use '-d 128':

  backend/tests/test_composite -d 128

(see also <project-dir>/backend/tests/tools/run_bwipp_tests.sh)

To run a test against ZXing-C++ (if any), use '-d 512':

  backend/tests/test_rss -d 512

  ------------------------------------------------------------------------
  For testing against ZXing-C++, the "diagnostics2" branch from
  https://github.com/gitlost/zxing-cpp is required, built with
  ZXING_EXAMPLE_DECODER defined, and "zxingcppdecoder" placed in PATH,
  e.g.:
    git clone --branch diagnostics2 https://github.com/gitlost/zxing-cpp \
        zxing-cpp-diagnostics2
    cd zxing-cpp-diagnostics2 && mkdir build && cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DZXING_EXAMPLE_DECODER=ON ..
    make && sudo make install
  ------------------------------------------------------------------------

(see also <project-dir>/backend/tests/tools/run_zxingcpp_tests.sh)

To generate test data (if available), use '-g':

  backend/tests/test_dotcode -f encode -g

------------------------------------------------------------------------------

If the zint library was built with static linkage support, i.e. ZINT_STATIC
is ON, an additional test executable, which uses the zint-static library, will
be built. The static variant of each test shares the test name, but has a
"-static" suffix. For example,

  backend/tests/test_dotcode

would run the dotcode test that uses the shared zint library, while

  backend/tests/test_dotcode-static

runs the same test built against the zint-static library.

------------------------------------------------------------------------------

To make with gcc sanitize, first set for libzint and make:

  cd <project-dir>
  cd build
  cmake -DZINT_SANITIZE=ON ..
  make && sudo make install

Similarly to make with gcc debug:

  cd <project-dir>
  cd build
  cmake -DZINT_DEBUG=ON ..
  make && sudo make install

To undo sanitize/debug, remake each after setting:

  cmake -DZINT_SANITIZE=OFF ..
  cmake -DZINT_DEBUG=OFF ..

To get a clean libzint, set the above and also:

  cmake -DZINT_TEST=OFF ..

(The tests will now fail to link.)