From 3f33ed3eb944387c576353d6ef65aa723ee8d0e1 Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 26 Jul 2021 15:29:05 +0100 Subject: [PATCH] CMakeLists.txt: cmake min required 3.13 -> 3.5 using CMAKE_REQUIRED_LIBRARIES; add ZINT_COVERAGE option bmp/emf/ps.c: allow for foreground colour in ULTRA bmp/gif/pcx.c: allow for BARCODE_STDOUT (fflush/fclose) emf.c: hexagon rotation field not used; dont't use float index in font loop; Windows stdout binary mode png.c: remove unused 8-bit; simplify libpng error handling and fclose outfile on error ps.c: fix buffer overflow on colour_to_pscolor() CMYK tif.c: fix BLACKISZERO indexes CODE39: simplify check digit setting reedsol.c: rs_uint_init_gf() log/alog tables must be zeroed ZBarcode_Encode: debug: fix access out-of-bounds on non-NUL-terminated source if length < 10 manual.txt/zint.h: document NUL-terminated strings tests: cover further cases for output (bmp/emf/etc), eci/gb18030/gb2312/sjis, reedsol, AZTEC, CODE39 --- CMakeLists.txt | 37 +- backend/aztec.c | 48 +-- backend/bmp.c | 60 ++- backend/code.c | 32 +- backend/emf.c | 183 ++++----- backend/gb18030.c | 4 +- backend/gif.c | 59 +-- backend/library.c | 4 +- backend/pcx.c | 13 +- backend/png.c | 95 ++--- backend/ps.c | 67 ++- backend/reedsol.c | 5 +- backend/rss.c | 2 +- backend/svg.c | 14 +- backend/telepen.c | 4 + backend/tests/CMakeLists.txt | 2 +- backend/tests/data/bmp/ultracode_fg_bg.bmp | Bin 714 -> 718 bytes .../data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp | Bin 0 -> 774 bytes .../tests/data/emf/code128_egrave_bold.emf | Bin 1248 -> 1248 bytes backend/tests/data/emf/code39_rotate_180.emf | Bin 1136 -> 1136 bytes backend/tests/data/emf/code39_rotate_270.emf | Bin 1136 -> 1136 bytes backend/tests/data/emf/code39_rotate_90.emf | Bin 1136 -> 1136 bytes backend/tests/data/emf/ean13_5addon_#185.emf | Bin 1876 -> 1876 bytes .../data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf | Bin 1876 -> 1876 bytes backend/tests/data/emf/itf14_bold.emf | Bin 1552 -> 1552 bytes backend/tests/data/emf/maxicode_#185.emf | Bin 26928 -> 26928 bytes .../data/emf/maxicode_rotate_90_nobg.emf | Bin 0 -> 26936 bytes backend/tests/data/emf/telenum_fg_bg.emf | Bin 1268 -> 1268 bytes backend/tests/data/emf/ultracode_fg_bg.emf | Bin 2808 -> 2808 bytes .../tests/data/emf/ultracode_fg_bg_box2.emf | Bin 0 -> 2940 bytes .../data/emf/upca_2addon_ggs_5.2.6.6-5.emf | Bin 1860 -> 1860 bytes backend/tests/data/emf/upce_2addon.emf | Bin 1460 -> 1460 bytes .../tests/data/emf/upce_2addon_small_bold.emf | Bin 1460 -> 1460 bytes .../eps/code128_egrave_bold_rotate_90.eps | 98 +++++ .../tests/data/eps/code39_fgalpha_bg_cmyk.eps | 76 ++++ backend/tests/data/eps/dotcode_no_bg.eps | 42 ++ .../data/eps/maxicode_rotate_270_cmyk.eps | 382 ++++++++++++++++++ backend/tests/data/eps/ultra_fg_bg_box.eps | 227 +++++++++++ .../tests/data/eps/ultra_fg_bg_box_cmyk.eps | 227 +++++++++++ backend/tests/data/gif/dotcode_bgfgalpha.gif | Bin 0 -> 70 bytes backend/tests/data/gif/dotcode_bgfgtrans.gif | Bin 0 -> 78 bytes .../tests/data/gif/ultra_fgbg_hvwsp1_box1.gif | Bin 0 -> 324 bytes backend/tests/data/pcx/codeblockf_reverse.pcx | Bin 0 -> 28664 bytes backend/tests/data/pcx/gridmatrix_fg_0.75.pcx | Bin 0 -> 3197 bytes backend/tests/data/pcx/qr_bg.pcx | Bin 0 -> 2756 bytes .../data/pcx/ultra_fg_bg_hvwsp1_box1.pcx | Bin 0 -> 2068 bytes backend/tests/data/png/aztec.png | Bin 0 -> 154 bytes backend/tests/data/png/ultra_hvwsp1_box1.png | Bin 0 -> 214 bytes backend/tests/data/print/emf/code128_aim.emf | Bin 956 -> 956 bytes .../tests/data/print/emf/dotcode_aim_fig7.emf | Bin 1212 -> 1212 bytes .../tests/data/print/emf/maxicode_fig_2.emf | Bin 26928 -> 26928 bytes backend/tests/data/print/emf/qr_v1_m.emf | Bin 2148 -> 2148 bytes backend/tests/data/print/emf/ultracode_a.emf | Bin 2688 -> 2688 bytes .../data/svg/maxicode_fgbg_rotate_90.svg | 380 +++++++++++++++++ .../tests/data/svg/ultra_fgbg_hvwsp2_box3.svg | 181 +++++++++ .../svg/upce_cc_2addon_cca_5x2_fgbgalpha.svg | 107 +++++ .../data/svg/upce_cc_2addon_cca_5x2_nobg.svg | 106 +++++ .../svg/upce_cc_2addon_cca_5x2_rotate_270.svg | 107 +++++ backend/tests/data/tif/code128_cmyk_fgbg.tif | Bin 0 -> 3718 bytes backend/tests/data/tif/code128_reverse.tif | Bin 0 -> 374 bytes backend/tests/data/tif/ultra_cmyk.tif | Bin 0 -> 590 bytes backend/tests/data/tif/ultra_cmyk_bgalpha.tif | Bin 0 -> 780 bytes .../tests/data/tif/ultra_fgbg_hvwsp1_box1.tif | Bin 0 -> 506 bytes backend/tests/test_aztec.c | 199 +++++++-- backend/tests/test_bmp.c | 96 +++-- backend/tests/test_channel.c | 73 ++-- backend/tests/test_code.c | 147 ++++--- backend/tests/test_code128.c | 201 ++++++--- backend/tests/test_code16k.c | 1 + backend/tests/test_eci.c | 182 +++++++++ backend/tests/test_emf.c | 73 +++- backend/tests/test_gb18030.c | 22 + backend/tests/test_gb2312.c | 1 + backend/tests/test_gif.c | 129 ++++-- backend/tests/test_library.c | 1 + backend/tests/test_pcx.c | 110 +++-- backend/tests/test_png.c | 158 ++++++-- backend/tests/test_ps.c | 115 ++++-- backend/tests/test_reedsol.c | 106 ++++- backend/tests/test_sjis.c | 1 + backend/tests/test_svg.c | 143 ++++--- backend/tests/test_telepen.c | 3 + backend/tests/test_tif.c | 155 ++++--- backend/tests/testcommon.c | 21 +- backend/tif.c | 18 +- backend/vector.c | 30 +- backend/zint.h | 14 +- docs/manual.txt | 51 +-- frontend/tests/CMakeLists.txt | 2 +- win32/README | 3 + 90 files changed, 3754 insertions(+), 863 deletions(-) create mode 100644 backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp create mode 100644 backend/tests/data/emf/maxicode_rotate_90_nobg.emf create mode 100644 backend/tests/data/emf/ultracode_fg_bg_box2.emf create mode 100644 backend/tests/data/eps/code128_egrave_bold_rotate_90.eps create mode 100644 backend/tests/data/eps/code39_fgalpha_bg_cmyk.eps create mode 100644 backend/tests/data/eps/dotcode_no_bg.eps create mode 100644 backend/tests/data/eps/maxicode_rotate_270_cmyk.eps create mode 100644 backend/tests/data/eps/ultra_fg_bg_box.eps create mode 100644 backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps create mode 100644 backend/tests/data/gif/dotcode_bgfgalpha.gif create mode 100644 backend/tests/data/gif/dotcode_bgfgtrans.gif create mode 100644 backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif create mode 100644 backend/tests/data/pcx/codeblockf_reverse.pcx create mode 100644 backend/tests/data/pcx/gridmatrix_fg_0.75.pcx create mode 100644 backend/tests/data/pcx/qr_bg.pcx create mode 100644 backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx create mode 100644 backend/tests/data/png/aztec.png create mode 100644 backend/tests/data/png/ultra_hvwsp1_box1.png create mode 100644 backend/tests/data/svg/maxicode_fgbg_rotate_90.svg create mode 100644 backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg create mode 100644 backend/tests/data/svg/upce_cc_2addon_cca_5x2_fgbgalpha.svg create mode 100644 backend/tests/data/svg/upce_cc_2addon_cca_5x2_nobg.svg create mode 100644 backend/tests/data/svg/upce_cc_2addon_cca_5x2_rotate_270.svg create mode 100644 backend/tests/data/tif/code128_cmyk_fgbg.tif create mode 100644 backend/tests/data/tif/code128_reverse.tif create mode 100644 backend/tests/data/tif/ultra_cmyk.tif create mode 100644 backend/tests/data/tif/ultra_cmyk_bgalpha.tif create mode 100644 backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a237e90..643f3f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (C) 2009-2021 Robin Stuart # vim: set ts=4 sw=4 et : -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.5) project(zint-package) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -17,9 +17,10 @@ add_definitions(-DZINT_VERSION=\"${ZINT_VERSION}\") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") -option(ZINT_DEBUG "Set debug compile flag" OFF) +option(ZINT_DEBUG "Set debug compile flags" OFF) option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF) option(ZINT_TEST "Set test compile flag" OFF) +option(ZINT_COVERAGE "Set code coverage flags" OFF) option(ZINT_STATIC "Build static library" OFF) option(ZINT_USE_PNG "Build with PNG support" ON) option(ZINT_USE_QT "Build with QT support" ON) @@ -51,6 +52,7 @@ if(ZINT_DEBUG) if(CXX_COMPILER_FLAG_G) add_compile_options("-g") endif() + check_cxx_compiler_flag("-O0" CXX_COMPILER_FLAG_O0) if(CXX_COMPILER_FLAG_O0) add_compile_options("-O0") @@ -61,6 +63,21 @@ if(ZINT_TEST) enable_testing() endif() +if(ZINT_COVERAGE) + set(CMAKE_REQUIRED_LIBRARIES -fprofile-arcs) + check_cxx_compiler_flag(--coverage CXX_COMPILER_FLAG_COVERAGE) + unset(CMAKE_REQUIRED_LIBRARIES) + if(CXX_COMPILER_FLAG_COVERAGE) + add_compile_options(--coverage) + link_libraries(-fprofile-arcs) + + check_cxx_compiler_flag(-O0 CXX_COMPILER_FLAG_O0) + if(CXX_COMPILER_FLAG_O0) + add_compile_options(-O0) + endif() + endif() +endif() + if(ZINT_SANITIZE) if(MSVC) if(MSVC_VERSION GREATER_EQUAL 1920) @@ -70,19 +87,17 @@ if(ZINT_SANITIZE) message(STATUS "ZINT_SANITIZE: ignoring for MSVC < 2019") endif() else() - file(WRITE ${CMAKE_BINARY_DIR}/dummy.c "int main() { return 0; }") set(SANITIZERS address undefined) foreach(sanitizer IN ITEMS ${SANITIZERS}) - set(sanitizer_flag "-fsanitize=${sanitizer}") - try_compile(RESULT_VAR ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/dummy.c - COMPILE_DEFINITIONS ${sanitizer_flag} - LINK_LIBRARIES ${sanitizer_flag}) - message(STATUS "Support for ${sanitizer_flag} available ... ${RESULT_VAR}") - if(RESULT_VAR) - add_compile_options(${sanitizer_flag}) - link_libraries(${sanitizer_flag}) + set(CMAKE_REQUIRED_LIBRARIES -fsanitize=${sanitizer}) + check_cxx_compiler_flag(-fsanitize=${sanitizer} CXX_COMPILER_FLAG_FSANITIZE_${sanitizer}) + if(CXX_COMPILER_FLAG_FSANITIZE_${sanitizer}) + add_compile_options(-fsanitize=${sanitizer}) + link_libraries(-fsanitize=${sanitizer}) endif() + unset(CMAKE_REQUIRED_LIBRARIES) endforeach() + if(NOT ZINT_DEBUG AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") # Gives warning on MainWindow::setupUI() and retries (& takes forever) if var-tracking-assignments enabled add_compile_options(-fno-var-tracking-assignments) diff --git a/backend/aztec.c b/backend/aztec.c index 203e489c..f59b6c04 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -192,10 +192,7 @@ static int aztec_text_process(const unsigned char source[], int src_len, char bi if (debug) { printf("First Pass:\n"); - for (i = 0; i < src_len; i++) { - printf("%c", encode_mode[i]); - } - printf("\n"); + printf("%.*s\n", src_len, encode_mode); } // Reduce two letter combinations to one codeword marked as [abcd] in Punct mode @@ -459,14 +456,8 @@ static int aztec_text_process(const unsigned char source[], int src_len, char bi } if (debug) { - for (i = 0; i < reduced_length; i++) { - printf("%c", reduced_source[i]); - } - printf("\n"); - for (i = 0; i < reduced_length; i++) { - printf("%c", reduced_encode_mode[i]); - } - printf("\n"); + printf("%.*s\n", reduced_length, reduced_source); + printf("%.*s\n", reduced_length, reduced_encode_mode); } bp = 0; @@ -840,7 +831,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt char adjusted_string[AZTEC_MAX_CAPACITY]; short AztecMap[AZTEC_MAP_SIZE]; unsigned char desc_data[4], desc_ecc[6]; - int error_number, ecc_level, compact, data_length, data_maxsize, codeword_size, adjusted_length; + int error_number, compact, data_length, data_maxsize, codeword_size, adjusted_length; int remainder, padbits, count, gs1, adjustment_size; int debug = (symbol->debug & ZINT_DEBUG_PRINT), reader = 0; int comp_loop = 4; @@ -878,21 +869,20 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt strcpy(symbol->errtxt, "503: Invalid error correction level - using default instead"); if (symbol->warn_level == WARN_FAIL_ALL) { return ZINT_ERROR_INVALID_OPTION; - } else { - error_number = ZINT_WARN_INVALID_OPTION; } + error_number = ZINT_WARN_INVALID_OPTION; symbol->option_1 = -1; } - ecc_level = symbol->option_1; - - if ((ecc_level == -1) || (ecc_level == 0)) { - ecc_level = 2; - } - data_maxsize = 0; /* Keep compiler happy! */ adjustment_size = 0; if (symbol->option_2 == 0) { /* The size of the symbol can be determined by Zint */ + int ecc_level = symbol->option_1; + + if ((ecc_level == -1) || (ecc_level == 0)) { + ecc_level = 2; + } + do { /* Decide what size symbol to use - the smallest that fits the data */ compact = 0; /* 1 = Aztec Compact, 0 = Normal Aztec */ @@ -1013,6 +1003,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt if (padbits == codeword_size) { padbits = 0; } + if (debug) printf("Remainder: %d Pad bits: %d\n", remainder, padbits); for (i = 0; i < padbits; i++) { adjusted_string[adjusted_length++] = '1'; @@ -1102,6 +1093,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt if (padbits == codeword_size) { padbits = 0; } + if (debug) printf("Remainder: %d Pad bits: %d\n", remainder, padbits); for (i = 0; i < padbits; i++) { adjusted_string[adjusted_length++] = '1'; @@ -1132,10 +1124,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt if (debug) { printf("Codewords:\n"); for (i = 0; i < (adjusted_length / codeword_size); i++) { - for (j = 0; j < codeword_size; j++) { - printf("%c", adjusted_string[(i * codeword_size) + j]); - } - printf(" "); + printf("%.*s ", codeword_size, adjusted_string + i * codeword_size); } printf("\n"); } @@ -1157,12 +1146,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt if (debug) { printf("Generating a %s symbol with %d layers\n", compact ? "compact" : "full-size", layers); - printf("Requires "); - if (compact) { - printf("%d", AztecCompactSizes[layers - 1]); - } else { - printf("%d", AztecSizes[layers - 1]); - } + printf("Requires %d", compact ? AztecCompactSizes[layers - 1] : AztecSizes[layers - 1]); printf(" codewords of %d-bits\n", codeword_size); printf(" (%d data words, %d ecc words)\n", data_blocks, ecc_blocks); } @@ -1431,7 +1415,7 @@ INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int input_value = 0; if (length > 3) { strcpy(symbol->errtxt, "507: Input too large (3 character maximum)"); - return ZINT_ERROR_INVALID_DATA; + return ZINT_ERROR_TOO_LONG; } error_number = is_sane(NEON, source, length); if (error_number != 0) { diff --git a/backend/bmp.c b/backend/bmp.c index 14f35a83..80145f0b 100644 --- a/backend/bmp.c +++ b/backend/bmp.c @@ -54,10 +54,30 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) color_ref_t bg_color_ref; color_ref_t fg_color_ref; color_ref_t ultra_color_ref[8]; + int ultra_fg_index = 9; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */ + + fg_color_ref.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); + fg_color_ref.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); + fg_color_ref.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); + fg_color_ref.reserved = 0x00; + bg_color_ref.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]); + bg_color_ref.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]); + bg_color_ref.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]); + bg_color_ref.reserved = 0x00; if (symbol->symbology == BARCODE_ULTRA) { + for (i = 0; i < 8; i++) { + ultra_color_ref[i].red = colour_to_red(i + 1); + ultra_color_ref[i].green = colour_to_green(i + 1); + ultra_color_ref[i].blue = colour_to_blue(i + 1); + ultra_color_ref[i].reserved = 0x00; + if (memcmp(&ultra_color_ref[i], &fg_color_ref, sizeof(fg_color_ref)) == 0) { + ultra_fg_index = i + 1; + } + } bits_per_pixel = 4; - colour_count = 9; + colour_count = ultra_fg_index == 9 ? 10 : 9; } else { bits_per_pixel = 1; colour_count = 2; @@ -70,29 +90,13 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) bitmap_file_start = (unsigned char *) malloc(file_size); if (bitmap_file_start == NULL) { - strcpy(symbol->errtxt, "602: Out of memory"); + strcpy(symbol->errtxt, "602: Insufficient memory for BMP file buffer"); return ZINT_ERROR_MEMORY; } memset(bitmap_file_start, 0, file_size); /* Not required but keeps padding bytes consistent */ bitmap = bitmap_file_start + data_offset; - fg_color_ref.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); - fg_color_ref.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); - fg_color_ref.blue = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); - fg_color_ref.reserved = 0x00; - bg_color_ref.red = (16 * ctoi(symbol->bgcolour[0])) + ctoi(symbol->bgcolour[1]); - bg_color_ref.green = (16 * ctoi(symbol->bgcolour[2])) + ctoi(symbol->bgcolour[3]); - bg_color_ref.blue = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]); - bg_color_ref.reserved = 0x00; - - for (i = 0; i < 8; i++) { - ultra_color_ref[i].red = colour_to_red(i + 1); - ultra_color_ref[i].green = colour_to_green(i + 1); - ultra_color_ref[i].blue = colour_to_blue(i + 1); - ultra_color_ref[i].reserved = 0x00; - } - /* Pixel Plotting */ if (symbol->symbology == BARCODE_ULTRA) { for (row = 0; row < symbol->bitmap_height; row++) { @@ -123,6 +127,9 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) case 'W': // White bitmap[i] += 8 << (4 * (1 - (column % 2))); break; + case '1': // Foreground + bitmap[i] += ultra_fg_index << (4 * (1 - (column % 2))); + break; } } } @@ -168,16 +175,20 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) bmp_posn += sizeof(color_ref_t); memcpy(bmp_posn, &ultra_color_ref[i], sizeof(color_ref_t)); } + if (ultra_fg_index == 9) { + bmp_posn += sizeof(color_ref_t); + memcpy(bmp_posn, &fg_color_ref, sizeof(color_ref_t)); + } } else { bmp_posn += sizeof(color_ref_t); memcpy(bmp_posn, &fg_color_ref, sizeof(color_ref_t)); } /* Open output file in binary mode */ - if ((symbol->output_options & BARCODE_STDOUT) != 0) { + if (output_to_stdout) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { - sprintf(symbol->errtxt, "600: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "600: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); free(bitmap_file_start); return ZINT_ERROR_FILE_ACCESS; } @@ -186,13 +197,18 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } else { if (!(bmp_file = fopen(symbol->outfile, "wb"))) { free(bitmap_file_start); - sprintf(symbol->errtxt, "601: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "601: Could not open output file (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } } fwrite(bitmap_file_start, file_header.file_size, 1, bmp_file); - fclose(bmp_file); + + if (output_to_stdout) { + fflush(bmp_file); + } else { + fclose(bmp_file); + } free(bitmap_file_start); return 0; diff --git a/backend/code.c b/backend/code.c index 81bcde9b..a39c0f7c 100644 --- a/backend/code.c +++ b/backend/code.c @@ -259,33 +259,8 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length) if (symbol->option_2 == 1) { char check_digit; - counter = counter % 43; - if (counter < 10) { - check_digit = itoc(counter); - } else { - if (counter < 36) { - check_digit = (counter - 10) + 'A'; - } else { - switch (counter) { - case 36: check_digit = '-'; - break; - case 37: check_digit = '.'; - break; - case 38: check_digit = ' '; - break; - case 39: check_digit = '$'; - break; - case 40: check_digit = '/'; - break; - case 41: check_digit = '+'; - break; - case 42: check_digit = 37; - break; - default: check_digit = ' '; - break; /* Keep compiler happy */ - } - } - } + counter %= 43; + check_digit = SILVER[counter]; lookup(SILVER, C39Table, check_digit, dest); /* Display a space check digit as _, otherwise it looks like an error */ @@ -727,7 +702,8 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in if (channels == 8) { sprintf(symbol->errtxt, "305: Value out of range (0 to %d)", max_ranges[channels]); } else { - sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels", max_ranges[channels], channels); + sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels", + max_ranges[channels], channels); } return ZINT_ERROR_INVALID_DATA; } diff --git a/backend/emf.c b/backend/emf.c index fc3e6220..4ab5ab0c 100644 --- a/backend/emf.c +++ b/backend/emf.c @@ -38,6 +38,8 @@ #include #include #ifdef _MSC_VER +#include +#include #include #endif #include "common.h" @@ -172,31 +174,34 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { float previous_diameter; float radius, half_radius, half_sqrt3_radius; int colours_used = 0; - int rectangle_count_bycolour[9]; - unsigned char *this_string[6]; + int rectangle_bycolour[9] = {0}; + int width, height; - int utfle_len; - int bumped_len; int draw_background = 1; int bold; - - float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; struct zint_vector_rect *rect; struct zint_vector_circle *circ; struct zint_vector_hexagon *hex; struct zint_vector_string *str; + /* Allow for up to 6 strings (current max 3 for UPC/EAN) */ + unsigned char *this_string[6]; + emr_exttextoutw_t text[6]; + float text_fsizes[6]; + int text_haligns[6]; + emr_header_t emr_header; emr_eof_t emr_eof; emr_mapmode_t emr_mapmode; emr_setworldtransform_t emr_setworldtransform; emr_createbrushindirect_t emr_createbrushindirect_fg; emr_createbrushindirect_t emr_createbrushindirect_bg; - emr_createbrushindirect_t emr_createbrushindirect_colour[8]; // Used for colour symbols only + emr_createbrushindirect_t emr_createbrushindirect_colour[9]; // Used for colour symbols only emr_selectobject_t emr_selectobject_fgbrush; emr_selectobject_t emr_selectobject_bgbrush; - emr_selectobject_t emr_selectobject_colour[8]; // Used for colour symbols only + emr_selectobject_t emr_selectobject_colour[9]; // Used for colour symbols only emr_createpen_t emr_createpen; emr_selectobject_t emr_selectobject_pen; emr_rectangle_t background; @@ -222,11 +227,13 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_rectangle_t *rectangle; emr_ellipse_t *circle; emr_polygon_t *hexagon; - emr_exttextoutw_t *text; - float *text_fsizes; - int *text_haligns; #endif + if (symbol->vector == NULL) { + strcpy(symbol->errtxt, "643: Vector header NULL"); + return ZINT_ERROR_INVALID_DATA; + } + fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); @@ -250,36 +257,34 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_rectangle_t rectangle[rectangle_count ? rectangle_count : 1]; emr_ellipse_t circle[circle_count ? circle_count : 1]; emr_polygon_t hexagon[hexagon_count ? hexagon_count : 1]; - emr_exttextoutw_t text[string_count ? string_count: 1]; - float text_fsizes[string_count ? string_count: 1]; - int text_haligns[string_count ? string_count: 1]; #else rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof(emr_rectangle_t)); circle = (emr_ellipse_t*) _alloca(circle_count * sizeof(emr_ellipse_t)); hexagon = (emr_polygon_t*) _alloca(hexagon_count * sizeof(emr_polygon_t)); - text = (emr_exttextoutw_t*) _alloca(string_count * sizeof(emr_exttextoutw_t)); - text_fsizes = (float *) _alloca(string_count * sizeof(float)); - text_haligns = (int *) _alloca(string_count * sizeof(int)); #endif - //Calculate how many coloured rectangles + // Calculate how many coloured rectangles if (symbol->symbology == BARCODE_ULTRA) { - for (i = 0; i <= 8; i++) { - rectangle_count_bycolour[i] = 0; - } rect = symbol->vector->rectangles; while (rect) { - if (rectangle_count_bycolour[rect->colour] == 0) { - colours_used++; + if (rect->colour == -1) { /* Foreground colour */ + if (rectangle_bycolour[0] == 0) { + colours_used++; + rectangle_bycolour[0] = 1; + } + } else { + if (rectangle_bycolour[rect->colour] == 0) { + colours_used++; + rectangle_bycolour[rect->colour] = 1; + } } - rectangle_count_bycolour[rect->colour]++; rect = rect->next; } } - width = (int) ceil(symbol->vector->width); - height = (int) ceil(symbol->vector->height); + width = (int) ceilf(symbol->vector->width); + height = (int) ceilf(symbol->vector->height); /* Header */ emr_header.type = 0x00000001; // EMR_HEADER @@ -295,7 +300,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_header.emf_header.record_signature = 0x464d4520; // ENHMETA_SIGNATURE emr_header.emf_header.version = 0x00010000; if (symbol->symbology == BARCODE_ULTRA) { - emr_header.emf_header.handles = 11; // Number of graphics objects + emr_header.emf_header.handles = 12; // Number of graphics objects } else { emr_header.emf_header.handles = fsize2 != 0.0f ? 5 : 4; } @@ -350,14 +355,20 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { recordcount++; if (symbol->symbology == BARCODE_ULTRA) { - for (i = 0; i < 8; i++) { + for (i = 0; i < 9; i++) { emr_createbrushindirect_colour[i].type = 0x00000027; // EMR_CREATEBRUSHINDIRECT emr_createbrushindirect_colour[i].size = 24; emr_createbrushindirect_colour[i].ih_brush = 2 + i; emr_createbrushindirect_colour[i].log_brush.brush_style = 0x0000; // BS_SOLID - emr_createbrushindirect_colour[i].log_brush.color.red = colour_to_red(i + 1); - emr_createbrushindirect_colour[i].log_brush.color.green = colour_to_green(i + 1); - emr_createbrushindirect_colour[i].log_brush.color.blue = colour_to_blue(i + 1); + if (i == 0) { + emr_createbrushindirect_colour[i].log_brush.color.red = fgred; + emr_createbrushindirect_colour[i].log_brush.color.green = fggrn; + emr_createbrushindirect_colour[i].log_brush.color.blue = fgblu; + } else { + emr_createbrushindirect_colour[i].log_brush.color.red = colour_to_red(i); + emr_createbrushindirect_colour[i].log_brush.color.green = colour_to_green(i); + emr_createbrushindirect_colour[i].log_brush.color.blue = colour_to_blue(i); + } emr_createbrushindirect_colour[i].log_brush.color.reserved = 0; emr_createbrushindirect_colour[i].log_brush.brush_hatch = 0x0006; // HS_SOLIDCLR } @@ -384,7 +395,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { recordcount++; if (symbol->symbology == BARCODE_ULTRA) { - for (i = 0; i < 8; i++) { + for (i = 0; i < 9; i++) { emr_selectobject_colour[i].type = 0x00000025; // EMR_SELECTOBJECT emr_selectobject_colour[i].size = 12; emr_selectobject_colour[i].ih_object = 2 + i; @@ -402,7 +413,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { /* Create Pens */ emr_createpen.type = 0x00000026; // EMR_CREATEPEN emr_createpen.size = 28; - emr_createpen.ih_pen = 10; + emr_createpen.ih_pen = 11; emr_createpen.log_pen.pen_style = 0x00000005; // PS_NULL emr_createpen.log_pen.width.x = 1; emr_createpen.log_pen.width.y = 0; // ignored @@ -415,7 +426,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_selectobject_pen.type = 0x00000025; // EMR_SELECTOBJECT emr_selectobject_pen.size = 12; - emr_selectobject_pen.ih_object = 10; + emr_selectobject_pen.ih_object = 11; bytecount += 12; recordcount++; @@ -431,7 +442,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { recordcount++; } - //Rectangles + // Rectangles rect = symbol->vector->rectangles; this_rectangle = 0; while (rect) { @@ -447,7 +458,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { rect = rect->next; } - //Circles + // Circles previous_diameter = radius = 0.0f; circ = symbol->vector->circles; this_circle = 0; @@ -468,7 +479,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { circ = circ->next; } - //Hexagons + // Hexagons previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f; hex = symbol->vector->hexagons; this_hexagon = 0; @@ -483,46 +494,20 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { half_radius = (float) (0.25 * previous_diameter); half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter); } - if ((hex->rotation == 0) || (hex->rotation == 180)) { - ay = hex->y + radius; - by = hex->y + half_radius; - cy = hex->y - half_radius; - dy = hex->y - radius; - ey = hex->y - half_radius; - fy = hex->y + half_radius; - ax = hex->x; - bx = hex->x + half_sqrt3_radius; - cx = hex->x + half_sqrt3_radius; - dx = hex->x; - ex = hex->x - half_sqrt3_radius; - fx = hex->x - half_sqrt3_radius; - } else { - ay = hex->y; - by = hex->y + half_sqrt3_radius; - cy = hex->y + half_sqrt3_radius; - dy = hex->y; - ey = hex->y - half_sqrt3_radius; - fy = hex->y - half_sqrt3_radius; - ax = hex->x - radius; - bx = hex->x - half_radius; - cx = hex->x + half_radius; - dx = hex->x + radius; - ex = hex->x + half_radius; - fx = hex->x - half_radius; - } - hexagon[this_hexagon].a_points_a.x = (int32_t) ax; - hexagon[this_hexagon].a_points_a.y = (int32_t) ay; - hexagon[this_hexagon].a_points_b.x = (int32_t) bx; - hexagon[this_hexagon].a_points_b.y = (int32_t) by; - hexagon[this_hexagon].a_points_c.x = (int32_t) cx; - hexagon[this_hexagon].a_points_c.y = (int32_t) cy; - hexagon[this_hexagon].a_points_d.x = (int32_t) dx; - hexagon[this_hexagon].a_points_d.y = (int32_t) dy; - hexagon[this_hexagon].a_points_e.x = (int32_t) ex; - hexagon[this_hexagon].a_points_e.y = (int32_t) ey; - hexagon[this_hexagon].a_points_f.x = (int32_t) fx; - hexagon[this_hexagon].a_points_f.y = (int32_t) fy; + /* Note rotation done via world transform */ + hexagon[this_hexagon].a_points_a.x = (int32_t) (hex->x); + hexagon[this_hexagon].a_points_a.y = (int32_t) (hex->y + radius); + hexagon[this_hexagon].a_points_b.x = (int32_t) (hex->x + half_sqrt3_radius); + hexagon[this_hexagon].a_points_b.y = (int32_t) (hex->y + half_radius); + hexagon[this_hexagon].a_points_c.x = (int32_t) (hex->x + half_sqrt3_radius); + hexagon[this_hexagon].a_points_c.y = (int32_t) (hex->y - half_radius); + hexagon[this_hexagon].a_points_d.x = (int32_t) (hex->x); + hexagon[this_hexagon].a_points_d.y = (int32_t) (hex->y - radius); + hexagon[this_hexagon].a_points_e.x = (int32_t) (hex->x - half_sqrt3_radius); + hexagon[this_hexagon].a_points_e.y = (int32_t) (hex->y - half_radius); + hexagon[this_hexagon].a_points_f.x = (int32_t) (hex->x - half_sqrt3_radius); + hexagon[this_hexagon].a_points_f.y = (int32_t) (hex->y + half_radius); hexagon[this_hexagon].bounds.top = hexagon[this_hexagon].a_points_d.y; hexagon[this_hexagon].bounds.bottom = hexagon[this_hexagon].a_points_a.y; @@ -541,7 +526,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { memset(&emr_extcreatefontindirectw, 0, sizeof(emr_extcreatefontindirectw)); emr_extcreatefontindirectw.type = 0x00000052; // EMR_EXTCREATEFONTINDIRECTW emr_extcreatefontindirectw.size = 104; - emr_extcreatefontindirectw.ih_fonts = 11; + emr_extcreatefontindirectw.ih_fonts = 12; emr_extcreatefontindirectw.elw.height = (int32_t) fsize; emr_extcreatefontindirectw.elw.width = 0; // automatic emr_extcreatefontindirectw.elw.weight = bold ? 700 : 400; @@ -555,20 +540,20 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_selectobject_font.type = 0x00000025; // EMR_SELECTOBJECT emr_selectobject_font.size = 12; - emr_selectobject_font.ih_object = 11; + emr_selectobject_font.ih_object = 12; bytecount += 12; recordcount++; if (fsize2) { memcpy(&emr_extcreatefontindirectw2, &emr_extcreatefontindirectw, sizeof(emr_extcreatefontindirectw)); - emr_extcreatefontindirectw2.ih_fonts = 12; + emr_extcreatefontindirectw2.ih_fonts = 13; emr_extcreatefontindirectw2.elw.height = (int32_t) fsize2; bytecount += 104; recordcount++; emr_selectobject_font2.type = 0x00000025; // EMR_SELECTOBJECT emr_selectobject_font2.size = 12; - emr_selectobject_font2.ih_object = 12; + emr_selectobject_font2.ih_object = 13; bytecount += 12; recordcount++; } @@ -599,13 +584,15 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { recordcount++; } - //Text + // Text this_text = 0; // Loop over font sizes so that they're grouped together, so only have to select font twice at most - for (current_fsize = fsize; current_fsize; current_fsize = fsize2) { + for (i = 0, current_fsize = fsize; i < 2 && current_fsize; i++, current_fsize = fsize2) { str = symbol->vector->strings; current_halign = -1; while (str) { + int utfle_len; + int bumped_len; if (str->fsize != current_fsize) { str = str->next; continue; @@ -654,9 +641,6 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { this_text++; str = str->next; } - if (current_fsize == fsize2) { - break; - } } /* Create EOF record */ @@ -678,14 +662,19 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { emr_header.emf_header.records = recordcount; /* Send EMF data to file */ - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { +#ifdef _MSC_VER + if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { + sprintf(symbol->errtxt, "642: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); + return ZINT_ERROR_FILE_ACCESS; + } +#endif emf_file = stdout; } else { - emf_file = fopen(symbol->outfile, "wb"); - } - if (emf_file == NULL) { - sprintf(symbol->errtxt, "640: Could not open output file (%d: %.30s)", errno, strerror(errno)); - return ZINT_ERROR_FILE_ACCESS; + if (!(emf_file = fopen(symbol->outfile, "wb"))) { + sprintf(symbol->errtxt, "640: Could not open output file (%d: %.30s)", errno, strerror(errno)); + return ZINT_ERROR_FILE_ACCESS; + } } fwrite(&emr_header, sizeof(emr_header_t), 1, emf_file); @@ -699,8 +688,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { fwrite(&emr_createbrushindirect_bg, sizeof(emr_createbrushindirect_t), 1, emf_file); if (symbol->symbology == BARCODE_ULTRA) { - for (i = 0; i < 8; i++) { - if (rectangle_count_bycolour[i + 1]) { + for (i = 0; i < 9; i++) { + if (rectangle_bycolour[i]) { fwrite(&emr_createbrushindirect_colour[i], sizeof(emr_createbrushindirect_t), 1, emf_file); } } @@ -724,14 +713,14 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { } if (symbol->symbology == BARCODE_ULTRA) { - for(i = 0; i < 8; i++) { - if (rectangle_count_bycolour[i + 1]) { + for (i = 0; i < 9; i++) { + if (rectangle_bycolour[i]) { fwrite(&emr_selectobject_colour[i], sizeof(emr_selectobject_t), 1, emf_file); rect = symbol->vector->rectangles; this_rectangle = 0; while (rect) { - if (rect->colour == i + 1) { + if ((i == 0 && rect->colour == -1) || rect->colour == i) { fwrite(&rectangle[this_rectangle], sizeof(emr_rectangle_t), 1, emf_file); } this_rectangle++; @@ -802,7 +791,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) { fwrite(&emr_eof, sizeof(emr_eof_t), 1, emf_file); - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { fflush(emf_file); } else { fclose(emf_file); diff --git a/backend/gb18030.c b/backend/gb18030.c index a6059966..72372f67 100644 --- a/backend/gb18030.c +++ b/backend/gb18030.c @@ -2888,8 +2888,8 @@ INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source gbdata[j] = utfdata[i]; } else { ret = gb18030_wctomb_zint(gbdata + j, gbdata + j + 1, utfdata[i]); - if (ret == 0) { - strcpy(symbol->errtxt, "820: Invalid character in input data"); + if (ret == 0) { /* Should never happen, as GB 18030 is a UTF i.e. maps all Unicode codepoints */ + strcpy(symbol->errtxt, "820: Invalid character in input data"); /* Not reached */ return ZINT_ERROR_INVALID_DATA; } if (ret == 4) { diff --git a/backend/gif.c b/backend/gif.c index 214e5ac0..f341f188 100644 --- a/backend/gif.c +++ b/backend/gif.c @@ -44,7 +44,7 @@ #define SSET "0123456789ABCDEF" typedef struct s_statestruct { - unsigned char * pOut; + unsigned char *pOut; unsigned char *pIn; unsigned int InLen; unsigned int OutLength; @@ -81,7 +81,7 @@ static unsigned char NextPaletteIndex(statestruct *pState) } -static char BufferNextByte(statestruct *pState) { +static int BufferNextByte(statestruct *pState) { (pState->OutPosCur)++; /* Check if this position is a byte count position * fg_f_bytecountbyte_set indicates, if byte count position bytes should be @@ -102,11 +102,10 @@ static char BufferNextByte(statestruct *pState) { return 0; } -static char AddCodeToBuffer(statestruct *pState, unsigned short CodeIn, unsigned char CodeBits) { +static int AddCodeToBuffer(statestruct *pState, unsigned short CodeIn, unsigned char CodeBits) { /* Check, if we may fill up the current byte completely */ if (CodeBits >= pState->OutBitsFree) { - (pState->pOut)[pState->OutPosCur] |= (unsigned char) - (CodeIn << (8 - pState->OutBitsFree)); + (pState->pOut)[pState->OutPosCur] |= (unsigned char) (CodeIn << (8 - pState->OutBitsFree)); if (BufferNextByte(pState)) return -1; CodeIn = (unsigned short) (CodeIn >> pState->OutBitsFree); @@ -123,8 +122,7 @@ static char AddCodeToBuffer(statestruct *pState, unsigned short CodeIn, unsigned } /* The remaining bits of CodeIn fit in the current byte. */ if (CodeBits > 0) { - (pState->pOut)[pState->OutPosCur] |= (unsigned char) - (CodeIn << (8 - pState->OutBitsFree)); + (pState->pOut)[pState->OutPosCur] |= (unsigned char) (CodeIn << (8 - pState->OutBitsFree)); pState->OutBitsFree -= CodeBits; } return 0; @@ -149,7 +147,7 @@ static unsigned short FindPixelOutlet(statestruct *pState, unsigned short HeadNo return 0; } -static char NextCode(statestruct *pState, unsigned char * pPixelValueCur, unsigned char CodeBits) { +static int NextCode(statestruct *pState, unsigned char *pPixelValueCur, unsigned char CodeBits) { unsigned short UpNode; unsigned short DownNode; /* start with the root node for last pixel chain */ @@ -203,9 +201,9 @@ static int gif_lzw(statestruct *pState, int paletteBitSize) { paletteBitSize = 2; /* initial size of compression codes */ - CodeBits = paletteBitSize+1; + CodeBits = paletteBitSize + 1; pState->ClearCode = (1 << paletteBitSize); - pState->FreeCode = pState->ClearCode+2; + pState->FreeCode = pState->ClearCode + 2; pState->OutBitsFree = 8; pState->OutPosCur = -1; pState->fByteCountByteSet = 0; @@ -232,7 +230,7 @@ static int gif_lzw(statestruct *pState, int paletteBitSize) { return 0; for (;;) { - char Res; + int Res; /* generate and save the next code, which may consist of multiple input pixels. */ Res = NextCode(pState, &PixelValueCur, CodeBits); if (Res < 0) @@ -249,7 +247,8 @@ static int gif_lzw(statestruct *pState, int paletteBitSize) { } // > Update last bytecount byte; if (pState->OutByteCountPos < pState->OutPosCur) { - (pState->pOut)[pState->OutByteCountPos] = (unsigned char) (pState->OutPosCur - pState->OutByteCountPos - 1); + (pState->pOut)[pState->OutByteCountPos] + = (unsigned char) (pState->OutPosCur - pState->OutByteCountPos - 1); } pState->OutPosCur++; return pState->OutPosCur; @@ -281,12 +280,13 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) int colourCount; unsigned char paletteRGB[10][3]; int paletteCount, paletteCountCur, paletteIndex; - int pixelIndex; + unsigned int pixelIndex; int paletteBitSize; int paletteSize; statestruct State; int transparent_index; int bgindex = -1, fgindex = -1; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; unsigned char backgroundColourIndex; unsigned char RGBCur[3]; @@ -297,11 +297,12 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) int fFound; unsigned char pixelColour; + unsigned int bitmapSize = symbol->bitmap_height * symbol->bitmap_width; /* Allow for overhead of 4 == code size + byte count + overflow byte + zero terminator */ - unsigned int lzoutbufSize = symbol->bitmap_height * symbol->bitmap_width + 4; + unsigned int lzoutbufSize = bitmapSize + 4; #ifdef _MSC_VER - char * lzwoutbuf; + char *lzwoutbuf; #endif #ifndef _MSC_VER @@ -344,8 +345,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) colourCount = 0; paletteCount = 0; /* loop over all pixels */ - for ( pixelIndex = 0; pixelIndex < (symbol->bitmap_height * symbol->bitmap_width); pixelIndex++) - { + for (pixelIndex = 0; pixelIndex < bitmapSize; pixelIndex++) { fFound = 0; /* get pixel colour code */ pixelColour = pixelbuf[pixelIndex]; @@ -434,7 +434,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* Set transparency */ /* Note: does not allow both transparent foreground and background - - * background takes prioroty */ + * background takes priority */ transparent_index = -1; if (strlen(symbol->fgcolour) > 6) { if ((symbol->fgcolour[6] == '0') && (symbol->fgcolour[7] == '0')) { @@ -453,7 +453,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* 1,2 -> 1, 3,4 ->2, 5,6,7,8->3 */ paletteBitSize = 0; - paletteCountCur = paletteCount-1; + paletteCountCur = paletteCount - 1; while (paletteCountCur != 0) { paletteBitSize++; paletteCountCur >>= 1; @@ -463,20 +463,20 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) paletteBitSize = 1; /* palette size 2 ^ bit size */ - paletteSize = 1<output_options & BARCODE_STDOUT) != 0) { + if (output_to_stdout) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { - sprintf(symbol->errtxt, "610: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "610: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } #endif gif_file = stdout; } else { if (!(gif_file = fopen(symbol->outfile, "wb"))) { - sprintf(symbol->errtxt, "611: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "611: Could not open output file (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } } @@ -581,21 +581,28 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* prepare state array */ State.pIn = pixelbuf; - State.InLen = symbol->bitmap_height * symbol->bitmap_width; + State.InLen = bitmapSize; State.pOut = (unsigned char *) lzwoutbuf; State.OutLength = lzoutbufSize; /* call lzw encoding */ byte_out = gif_lzw(&State, paletteBitSize); if (byte_out <= 0) { - fclose(gif_file); + if (!output_to_stdout) { + fclose(gif_file); + } + strcpy(symbol->errtxt, "613: Insufficient memory for LZW buffer"); return ZINT_ERROR_MEMORY; } fwrite(lzwoutbuf, byte_out, 1, gif_file); /* GIF terminator */ fputc('\x3b', gif_file); - fclose(gif_file); + if (output_to_stdout) { + fflush(gif_file); + } else { + fclose(gif_file); + } return 0; } diff --git a/backend/library.c b/backend/library.c index 85821361..2cfec9a1 100644 --- a/backend/library.c +++ b/backend/library.c @@ -907,10 +907,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int if (symbol->debug & ZINT_DEBUG_PRINT) { printf("ZBarcode_Encode: symbology: %d, input_mode: 0x%X, ECI: %d, option_1: %d, option_2: %d," " option_3: %d, scale: %g\n output_options: 0x%X, fg: %s, bg: %s," - " length: %d, First 10 source: \"%.10s\", First 10 primary: \"%.10s\"\n", + " length: %d, First 10 source: \"%.*s\", First 10 primary: \"%.10s\"\n", symbol->symbology, symbol->input_mode, symbol->eci, symbol->option_1, symbol->option_2, symbol->option_3, symbol->scale, symbol->output_options, symbol->fgcolour, symbol->bgcolour, - length, source ? (const char *) source : "", symbol->primary); + length, length < 10 ? length : 10, source ? (const char *) source : "", symbol->primary); } warn_number = 0; diff --git a/backend/pcx.c b/backend/pcx.c index e0ba07b6..742250c0 100644 --- a/backend/pcx.c +++ b/backend/pcx.c @@ -51,6 +51,7 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) pcx_header_t header; int bytes_per_line = symbol->bitmap_width + (symbol->bitmap_width & 1); // Must be even unsigned char previous; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; /* Suppress gcc -fanalyzer warning */ #ifdef _MSC_VER unsigned char *rle_row; #endif @@ -99,17 +100,17 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } /* Open output file in binary mode */ - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { - sprintf(symbol->errtxt, "620: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "620: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } #endif pcx_file = stdout; } else { if (!(pcx_file = fopen(symbol->outfile, "wb"))) { - sprintf(symbol->errtxt, "621: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "621: Could not open output file (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } } @@ -215,7 +216,11 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } } - fclose(pcx_file); + if (output_to_stdout) { + fflush(pcx_file); + } else { + fclose(pcx_file); + } return 0; } diff --git a/backend/png.c b/backend/png.c index 578e8f6d..58556682 100644 --- a/backend/png.c +++ b/backend/png.c @@ -48,28 +48,25 @@ #define SSET "0123456789ABCDEF" -struct mainprog_info_type { - long width; - long height; - FILE *outfile; +/* Note if change this need to change "backend/tests/test_png.c" definition also */ +struct wpng_error_type { + struct zint_symbol *symbol; jmp_buf jmpbuf; }; -static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) { - struct mainprog_info_type *graphic; +STATIC_UNLESS_ZINT_TEST void wpng_error_handler(png_structp png_ptr, png_const_charp msg) { + struct wpng_error_type *wpng_error_ptr; - fprintf(stderr, "writepng libpng error: %s (F30)\n", msg); - fflush(stderr); - - graphic = (struct mainprog_info_type*) png_get_error_ptr(png_ptr); - if (graphic == NULL) { + wpng_error_ptr = (struct wpng_error_type *) png_get_error_ptr(png_ptr); + if (wpng_error_ptr == NULL) { /* we are completely hosed now */ - fprintf(stderr, - "writepng severe error: jmpbuf not recoverable; terminating. (F31)\n"); + fprintf(stderr, "Error 636: libpng error: %s\n", msg ? msg : ""); + fprintf(stderr, "Error 637: jmpbuf not recoverable, terminating\n"); fflush(stderr); - return; + return; /* libpng will call abort() */ } - longjmp(graphic->jmpbuf, 1); + sprintf(wpng_error_ptr->symbol->errtxt, "635: libpng error: %.60s", msg ? msg : ""); + longjmp(wpng_error_ptr->jmpbuf, 1); } /* Guestimate best compression strategy */ @@ -93,8 +90,8 @@ static int guess_compression_strategy(struct zint_symbol *symbol, unsigned char } INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) { - struct mainprog_info_type wpng_info; - struct mainprog_info_type *graphic; + struct wpng_error_type wpng_error; + FILE *outfile; png_structp png_ptr; png_infop info_ptr; int i; @@ -109,6 +106,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) int bit_depth; int compression_strategy; unsigned char *pb; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; #ifndef _MSC_VER unsigned char outdata[symbol->bitmap_width]; @@ -116,10 +114,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) unsigned char* outdata = (unsigned char*) _alloca(symbol->bitmap_width); #endif - graphic = &wpng_info; - - graphic->width = symbol->bitmap_width; - graphic->height = symbol->bitmap_height; + wpng_error.symbol = symbol; fg.red = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fg.green = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); @@ -143,7 +138,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) num_trans = 0; if (symbol->symbology == BARCODE_ULTRA) { static const int ultra_chars[8] = { 'W', 'C', 'B', 'M', 'R', 'Y', 'G', 'K' }; - static png_color ultra_colours[8] = { + static const png_color ultra_colours[8] = { { 0xff, 0xff, 0xff, }, /* White */ { 0, 0xff, 0xff, }, /* Cyan */ { 0, 0, 0xff, }, /* Blue */ @@ -225,51 +220,57 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) if (num_palette <= 2) { bit_depth = 1; - } else if (num_palette <= 16) { - bit_depth = 4; } else { - bit_depth = 8; + bit_depth = 4; } /* Open output file in binary mode */ - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { - sprintf(symbol->errtxt, "631: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "631: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } #endif - graphic->outfile = stdout; + outfile = stdout; } else { - if (!(graphic->outfile = fopen(symbol->outfile, "wb"))) { - sprintf(symbol->errtxt, "632: Can't open output file (%d: %.30s)", errno, strerror(errno)); + if (!(outfile = fopen(symbol->outfile, "wb"))) { + sprintf(symbol->errtxt, "632: Could not open output file (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } } /* Set up error handling routine as proc() above */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, graphic, writepng_error_handler, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler, NULL); if (!png_ptr) { - strcpy(symbol->errtxt, "633: Out of memory"); + strcpy(symbol->errtxt, "633: Insufficient memory for PNG write structure buffer"); + if (!output_to_stdout) { + fclose(outfile); + } return ZINT_ERROR_MEMORY; } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_write_struct(&png_ptr, NULL); - strcpy(symbol->errtxt, "634: Out of memory"); + strcpy(symbol->errtxt, "634: Insufficient memory for PNG info structure buffer"); + if (!output_to_stdout) { + fclose(outfile); + } return ZINT_ERROR_MEMORY; } /* catch jumping here */ - if (setjmp(graphic->jmpbuf)) { + if (setjmp(wpng_error.jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); - strcpy(symbol->errtxt, "635: libpng error occurred"); + if (!output_to_stdout) { + fclose(outfile); + } return ZINT_ERROR_MEMORY; } /* open output file with libpng */ - png_init_io(png_ptr, graphic->outfile); + png_init_io(png_ptr, outfile); /* set compression */ png_set_compression_level(png_ptr, 9); @@ -281,7 +282,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } /* set Header block */ - png_set_IHDR(png_ptr, info_ptr, graphic->width, graphic->height, + png_set_IHDR(png_ptr, info_ptr, symbol->bitmap_width, symbol->bitmap_height, bit_depth, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -308,7 +309,7 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* write row contents to file */ png_write_row(png_ptr, outdata); } - } else if (bit_depth == 4) { + } else { /* Bit depth 4 */ for (row = 0; row < symbol->bitmap_height; row++) { unsigned char *image_data = outdata; for (column = 0; column < symbol->bitmap_width; column += 2, image_data++) { @@ -321,26 +322,18 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) /* write row contents to file */ png_write_row(png_ptr, outdata); } - } else { /* Bit depth 8 */ - for (row = 0; row < symbol->bitmap_height; row++) { - unsigned char *image_data = outdata; - for (column = 0; column < symbol->bitmap_width; column++, pb++, image_data++) { - *image_data = map[*pb]; - } - /* write row contents to file */ - png_write_row(png_ptr, outdata); - } } /* End the file */ png_write_end(png_ptr, NULL); /* make sure we have disengaged */ - if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr); - if (symbol->output_options & BARCODE_STDOUT) { - fflush(wpng_info.outfile); + png_destroy_write_struct(&png_ptr, &info_ptr); + + if (output_to_stdout) { + fflush(outfile); } else { - fclose(wpng_info.outfile); + fclose(outfile); } return 0; diff --git a/backend/ps.c b/backend/ps.c index c2a9ab9c..b8c204a6 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -40,8 +40,8 @@ #endif #include "common.h" -static void colour_to_pscolor(int option, int colour, char* output) { - strcpy(output, ""); +static void colour_to_pscolor(int option, int colour, char *output) { + *output = '\0'; if ((option & CMYK_COLOUR) == 0) { // Use RGB colour space switch (colour) { @@ -142,8 +142,8 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy; float previous_diameter; float radius, half_radius, half_sqrt3_radius; - int colour_index, colour_rect_counter; - char ps_color[30]; + int colour_index, colour_rect_flag; + char ps_color[33]; /* max "1.00 0.00 0.00 0.00 setcmykcolor" = 32 + 1 */ int draw_background = 1; struct zint_vector_rect *rect; struct zint_vector_hexagon *hex; @@ -154,24 +154,29 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { int i, len; int ps_len = 0; int iso_latin1 = 0; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; #ifdef _MSC_VER unsigned char *ps_string; #endif + if (symbol->vector == NULL) { + strcpy(symbol->errtxt, "646: Vector header NULL"); + return ZINT_ERROR_INVALID_DATA; + } + if (strlen(symbol->bgcolour) > 6) { if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) { draw_background = 0; } } - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { feps = stdout; } else { - feps = fopen(symbol->outfile, "w"); - } - if (feps == NULL) { - sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", errno, strerror(errno)); - return ZINT_ERROR_FILE_ACCESS; + if (!(feps = fopen(symbol->outfile, "w"))) { + sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", errno, strerror(errno)); + return ZINT_ERROR_FILE_ACCESS; + } } locale = setlocale(LC_ALL, "C"); @@ -269,7 +274,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { fprintf(feps, "%%%%Title: Zint Generated Symbol\n"); fprintf(feps, "%%%%Pages: 0\n"); fprintf(feps, "%%%%BoundingBox: 0 0 %d %d\n", - (int) ceil(symbol->vector->width), (int) ceil(symbol->vector->height)); + (int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height)); fprintf(feps, "%%%%EndComments\n"); /* Definitions */ @@ -283,15 +288,15 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { fprintf(feps, "newpath\n"); /* Now the actual representation */ - - //Background + + // Background if (draw_background) { if ((symbol->output_options & CMYK_COLOUR) == 0) { fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); } else { fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_paper, magenta_paper, yellow_paper, black_paper); } - + fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width); fprintf(feps, "TE\n"); } @@ -306,17 +311,37 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { // Rectangles if (symbol->symbology == BARCODE_ULTRA) { - for (colour_index = 0; colour_index <= 8; colour_index++) { - colour_rect_counter = 0; + colour_rect_flag = 0; + rect = symbol->vector->rectangles; + while (rect) { + if (rect->colour == -1) { // Foreground + if (colour_rect_flag == 0) { + // Set foreground colour + if ((symbol->output_options & CMYK_COLOUR) == 0) { + fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); + } else { + fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", + cyan_ink, magenta_ink, yellow_ink, black_ink); + } + colour_rect_flag = 1; + } + fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", + rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width); + fprintf(feps, "TE\n"); + } + rect = rect->next; + } + for (colour_index = 1; colour_index <= 8; colour_index++) { + colour_rect_flag = 0; rect = symbol->vector->rectangles; while (rect) { if (rect->colour == colour_index) { - if (colour_rect_counter == 0) { - //Set new colour + if (colour_rect_flag == 0) { + // Set new colour colour_to_pscolor(symbol->output_options, colour_index, ps_color); fprintf(feps, "%s\n", ps_color); + colour_rect_flag = 1; } - colour_rect_counter++; fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width); fprintf(feps, "TE\n"); @@ -456,9 +481,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) { } while (string); } - //fprintf(feps, "\nshowpage\n"); - - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { fflush(feps); } else { fclose(feps); diff --git a/backend/reedsol.c b/backend/reedsol.c index 78126849..331c65da 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -127,7 +127,6 @@ INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index) { /* rs_encode(&rs, datalen, data, res) generates nsym Reed-Solomon codes (nsym as given in rs_init_code()) * and places them in reverse order in res */ - INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res) { int i, k; const unsigned char *logt = rs->logt; @@ -200,10 +199,10 @@ INTERNAL int rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, rs_uint->logt = NULL; rs_uint->alog = NULL; - if (!(logt = (unsigned int *) malloc(sizeof(unsigned int) * b))) { + if (!(logt = (unsigned int *) calloc(b, sizeof(unsigned int)))) { return 0; } - if (!(alog = (unsigned int *) malloc(sizeof(unsigned int) * b * 2))) { + if (!(alog = (unsigned int *) calloc(b * 2, sizeof(unsigned int)))) { free(logt); return 0; } diff --git a/backend/rss.c b/backend/rss.c index 57d99930..17a33653 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -1071,7 +1071,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char if (debug) printf("General field data = %s\n", general_field); if (j != 0) { /* If general field not empty */ - if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) { /* Failure should never happen */ + if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) { /* Should not happen */ /* Not reachable */ strcpy(symbol->errtxt, "386: Invalid character in General Field data"); return ZINT_ERROR_INVALID_DATA; diff --git a/backend/svg.c b/backend/svg.c index 78894a90..5953c45c 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -187,16 +187,16 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) { /* Check for no created vector set */ /* E-Mail Christian Schmitz 2019-09-10: reason unknown Ticket #164*/ if (symbol->vector == NULL) { + strcpy(symbol->errtxt, "681: Vector header NULL"); return ZINT_ERROR_INVALID_DATA; } if (symbol->output_options & BARCODE_STDOUT) { fsvg = stdout; } else { - fsvg = fopen(symbol->outfile, "w"); - } - if (fsvg == NULL) { - sprintf(symbol->errtxt, "680: Could not open output file (%d: %.30s)", errno, strerror(errno)); - return ZINT_ERROR_FILE_ACCESS; + if (!(fsvg = fopen(symbol->outfile, "w"))) { + sprintf(symbol->errtxt, "680: Could not open output file (%d: %.30s)", errno, strerror(errno)); + return ZINT_ERROR_FILE_ACCESS; + } } locale = setlocale(LC_ALL, "C"); @@ -206,7 +206,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) { fprintf(fsvg, "\n"); fprintf(fsvg, "vector->width), (int) ceil(symbol->vector->height)); + (int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height)); fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n"); fprintf(fsvg, " Zint Generated Symbol\n"); fprintf(fsvg, " \n"); @@ -214,7 +214,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) { if (bg_alpha != 0) { fprintf(fsvg, " vector->width), (int) ceil(symbol->vector->height), bgcolour_string); + (int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height), bgcolour_string); if (bg_alpha != 0xff) { fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity); } diff --git a/backend/telepen.c b/backend/telepen.c index 8dc9d17c..3d3d28cc 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -90,6 +90,8 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src } strcat(dest, TeleTable[check_digit]); + if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit); + /* Stop character */ strcat(dest, TeleTable['z']); @@ -169,6 +171,8 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int } strcat(dest, TeleTable[check_digit]); + if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit); + /* Stop character */ strcat(dest, TeleTable['z']); diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index c2043fda..68bc659b 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -3,7 +3,7 @@ # Copyright (C) 2006-2017 Kentaro Fukuchi # vim: set ts=4 sw=4 et : -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.5) project(zint_backend_tests) enable_testing() diff --git a/backend/tests/data/bmp/ultracode_fg_bg.bmp b/backend/tests/data/bmp/ultracode_fg_bg.bmp index 7275fd6fa69954a4494633234c8e3be36fcf37fd..c204e25264222240b44245d673dbe1459a6844de 100644 GIT binary patch delta 39 qcmX@bdXAOb$@d%+0~o|jdMghk)c@7?wWSf7Hlh6*{^X^( z-S=DS?16ZJpW!F?hIWW^JK(kW_4T2)CBhB=#R>|;$M^Gyr*+mWjA(%xF!GrJ{A0l$ z(wV9Ec^Px_U}iH@9`Z64>Y*m8%%fhyywpXOh)LB;Sd_ZPkmFi6V;+-hIB&v2prnx!*OlYOIVp7dc*W4dI?+ie;3P<@5{RFBl-d) Cir#Jj literal 0 HcmV?d00001 diff --git a/backend/tests/data/emf/code128_egrave_bold.emf b/backend/tests/data/emf/code128_egrave_bold.emf index 1979555bff2b464b130b4b1073860f12462f8525..d27b93092a7f4cb0a99152d8ba63fb383a4f4fe8 100644 GIT binary patch delta 29 lcmaFB`G9l621f3Q8>Ja}CY~*3Ad2 delta 29 lcmaFB`G9l621c%l8>Jb!C!Q^4R}3Y7o= delta 29 lcmeys@quH)1xBuk7o{1wC%!FaRR3XuQ+ diff --git a/backend/tests/data/emf/code39_rotate_270.emf b/backend/tests/data/emf/code39_rotate_270.emf index a474087fcd371432d0d7d61cc699fc2fbd70720c..7e416a7e9863647a2ce736080c6c7e8aea3c9f42 100644 GIT binary patch delta 29 lcmeys@quH)1xD_P7o{0_CcZ6ZR}3Y7o= delta 29 lcmeys@quH)1xBuk7o{1wC%!FaRR3XuQ+ diff --git a/backend/tests/data/emf/code39_rotate_90.emf b/backend/tests/data/emf/code39_rotate_90.emf index a735b78cf88af8d5287e2816162dbb79bf3dbdbb..6e3bcf0378605cc561445c6e1e22ddc2038c56d9 100644 GIT binary patch delta 29 lcmeys@quH)1xD_P7o{0_CcZ6ZR}3Y7o= delta 29 lcmeys@quH)1xBuk7o{1wC%!FaRR3XuQ+ diff --git a/backend/tests/data/emf/ean13_5addon_#185.emf b/backend/tests/data/emf/ean13_5addon_#185.emf index 2898e10419c1116686beddd4a9774466f1164c48..27ad3a1c3273c9d05bed64f62a206bbda6e457a7 100644 GIT binary patch delta 30 mcmcb@cZF}l21f3Q8>Ja}CY~*3Jb!C!Q^4Ja}CY~*3Jb!C!Q^4Ja}CY~*3Jb!C!Q^4!KwNPt7Sm-E;1El(UR*%@_&WJk@KEHreOb+&>LCm52R&&xSG=MS0t`keEe=Xtt& z@ArM*^L@X!4Xf4a^*Q>#w;ixreLP41x9y#))s8<|tu~)^-r1|whSf`6w_3e%!)i4o zi}c~|S*;u=Wajv8|9yYRgK`-ESdPs(p8jw9&#qS6|6!>wz2Qvw6FH8^(NRx5_0($9 z;GdDY|HD5o$B{X{FUQ6l?Mu1ZlB56cc1_o{tbFUMb8{SD^?AXc%pv=fs&Pl>fCuNm z^YQ4Rd1qZv^|isyTB{mI3wiN;JbE~@u1jzJ=Q%nnzm}!O(L!E4Esq|~to8KfyK{8b z9aZCKAupbmM-OM#XVaVS%h6f?RyB?m^5SWE^l)Z9cf-^3Q-hu5wWP)!UC4`<#iNJj zIKRgi=9j8|Rj{+ptQtoPdGWM7dN{L=$)x7wJ=j@a zs2WELdGYyL@#x{qdTCBV^H&Eu>)fhww2&81%cF-g>$Nq1d$6;9vuYeI`ju!IbX?gT;X8l3UcLw|W zdSBHzTF8r+#iNHaYfsG|3wG8+RpV$OFJ2ap9?q;MYJOB+aGiBf)i_$ni!{!MPT7)|27XI9kYym&K!pGt0Hn+_kf_TtC$~TF8s1 z<Dym(nWdN{M*U-P?zopn>y zI9kYym&K!pGwYE2;LKkT?5xdI<7go-o|Z=sXO`dX^*PM$%;ERARyFRgbHESez|->R zp?M;g-{X4F+;zCKT#MB>TF8s1<n}`Kw$!COKoM`wMyY8)-(#nbZW;mo=)=al(x2RrM^s&TZC7f;KhhcoN!oKxnn3wG8; zRpV$OFP@f14`-I^thwuOXSo)uakP*ZPs^i+Gwbhb{?%Y-eZFcOE#$?^;?cvIWk)x+ z%XgMNUX7!Lym(q3J)Buzs`=x=&U(0N94+L<%i__)nf0BTAD#1|vkt8qM+&9a_Tvv|D_v~ly z+M>q&K;cux)AHz{dHzon}*C2D(sLpboQsZbLFP@f14`-I^hPmrXXSueh zakP*ZPs^i+Gwb%6KM?G!T~*^~AunDQj~>n}*C2D(sLpboQsZbLFP@f14`-HZkhyDA zXSq(PakP*ZPs^i+Gs`u|+%>ART&L7HTF8s1<o#p+78b=Fx@w7a8IJ3^lFVy_%U}s%YHI5eY z;%RyGaAtY$VD7y|XL*02#?eAvJS~qN&MfccUz)>v{nzI3T9u>5T~v5x5Kqgahvtb~ zUaJ?THn&H1mR(YfqlLV9S{^-|S+3dUuIZh1SJgOL$cv}t(ZiYL8H2fJ5S{g4)i_$n zi>Kw$!Sna3wiOfc=T{)xi*@+c6OHQ zry55KdGWM7dN{LO8_iuiJInP`jiZIUcv>DkoLM;yR<924y7%^AUklZ^-zognplcy5 zj~<%m+gn~=u0iImQJu9`HI5eY;%RyGaAsXsbDx=Yme0-9I9kYym&K!pGi$x(u6Lc~ zny1FmLSDQq9zC2{u4m@1cb(;$r^eAjUOX+29?q;!hBN<4j?VgA)i_$ni>Kw$!u#`U5%rKym(q3J)BvdqnLZn(pjFh zsByHA7f;KhhcnA_6m!p6I?J;bHI5eY;%RyGaAsYR*W32+o@d+?bZ)=7YTRGc>|H@T zEsq|W=byTq+wZQq&+@w7a8Xr3S2az3ut+n^_ch&(_<7go-o|Z=sXV#va2j-6j zJL{pUakP*ZPs^i+GwVb7!I|F^?5ta>#?eAvJS~qN&aAyPKRCbN&U!MO8b=Fx@v?aI zaArL_I`bEgtRJr$M+#Vu!aA&y|t8uiD7f;KhhcnAAY;ITXEc>z=M+B8b=Fx@v?aIaAvs%nY%`Hmg|%nM+O?Jd8@)5Doxo};r~Sv8Ip^5SWE^l)Z*7HRHTWoLO_sm9Sl zUOX+29?mTLn7Mtev+QhY94+L<)AH!y%yJ%>J5M^xxuV9=LS8&Aj~>n}uU-4F*S2Q_ ze)eA9YTU7fhXwJpJbGxJZ*Te8Z%V%Taly_yqG}v1Kw$!Ee=+=J!8ZlHzRs^2cXiD!4&rHf^w2y%w&nG8Ma{h@ z>n!ib)Hqtmi#CYxAM7ljS*mfgkQXnDM-OL~bIRN~*ICXxHI5eY;%RyGaAw(G z&F#0HWye+HXdy42mPZd~mi^V-e%o1gTs4js^5SWE^l)Z5r_7ymo#nh!<7go-o|Z=s zXV&5Qecl-U_vX%We^%pYAupbmM-OM#H^P}8n16Id@oF3`I?LXm#?eAvJS~qN&MZ5+xgEZKw$!abmUOX+29?mS+MswHB&T{=! z<7go-o|Z=sXVw$p%)PhhEblMWI9kYyr{&SZndRDO?%LT|uAgcgE#$@1^625rI;ZBI z6L;1nRpV$OFJ2ap9?mR#kGZ|5v+PD{94+L<)AH!y%<@dx+%xCS^4wXCqlLV9S{^-| zSyQ-YF9>$l=BjbDkQYzOqlYugeqnC^ z=qx*k8b=Fx@w7a8II}{n{xARIeZiK@{2RR|P~(2M@Oy)JS{^+#&)4#AbWWK&_d08> zY8)-(#nbZW;mlgE`R-t6-BC4;7V_d{@#x{q@|@1xbG**-EKiN2g}iuL9zC2{&QEja zZ)Z7&)i_$ni>Kw$!GMpMm3wiOfc=T{)*~iT7Yn^3hQ{!kMFP@f14`-Hr>_@}f+g=fL zKHAyTxKj&{3*u>c^w2zC%lT-BGPh%OmOV?2qlLV9S{^-|S^r-14SB6}mcPwY<7go- zUKWoY&MeP&%sv0pfvup0}mOJaBs&TZC7cYxP4`-IY zB{u(Ru(Lj2HI5eY;%RyGaAvv3nID*=v)o(MI9kYyr{&SZnRQY)^NVwI*4C?vpmaF z<7go-o|Z=sXO?Gcr-%3K?W&;bgy(N++@*!*2Jy5!dT5@n{r7Ei_vX%8s~SfOdGWOF z*LrB4uO(}}=I+g%<^HV3(L!FlEFL{H&)1T*Ew2&tw+1`Q-(0A1w2&81%cFDkG|$(P^+e5&3ei~yRgI&Cym(nWdT5@nCF__J=4a*TEW5WF zM+Dk zG|$(PWk)x+!*`ZFUX7!Lym(q3Jv7hPlI6Lkx#ymp<=LkiM+hJIPp=O;x7}0K zxVIJlMi5WSqlf1CTC&_P&D~Es%RN<%qlLV9S{^-|S?-tS?x&sQo~p*tLS8&Aj~>n} z_e*p4)6Q~FRpV$OFP@f14`HGd@7Sr1l?qlLV9Sv-0;v)p^l-J3hh{aKBpg}iuL z9zC2{{vO}_<-yK6v1%MG>!zx4w2&81%cF-g%YI>Q|L80`h#E%=dGWM7dN{M}7v=}% z=qx*k8b=Fx@w7a8IJ3O}HuwI#vo=?aqlLV9S{^-|S#}k3yG&=OwOkAR9g(@eH|i{ZYox}}LS8&A zj~>pf^_tsdI?Fzz#?eAvyeu9)oLP_7+~+r)<+B?#ju!IbW%20Y%<@@^xzAcU%jYd> z94+L<)AH!y%<_!E+%t&I@*F~qqlLV9S{^-|S^j3%{42rE`drmGTF8s1<{uAupbmM-OM# zF*QFc*je^JHI5eY;$`vZp?SWR*ZtlU=JvJDva_jiw2&81%cF-g%RXjqU+XM8n;J(8 zdGWM7dN{M}W9Ig?&a$(qakP*ZPs^i+Gt0A&Tf%!rvM1QjP1Lwg7v2%{+=P}#56$zn z{Jc)9`DMY*I=^ZhE#$?^;?cvIabmUc4+GJ)Bu~J9E2VXW9SMI9kYyr{&SZnPpco zx65>veMXI=g}iuL9zC2{b`^8GOlR3=)Hqtmi>Kw$!kn*4C-O~K59H{qT~*^~AupbmM-OL~{leV-(OGs7HI5eY;%RyGaAw&r%?17yB4*x%Rts>abmUOX+29?mTLg}MEsv+N*h94+L<)AH!y z%sQv$R|h-mlB#jEkQXnDM-OM#HR;W7%+Xn%O{sCTkQYzOqlYugXFTTjn}yUKrux6}Mk zX1(XAarQX)cr^ALS{^+#Pq}~3F~2N*XW3`eI9kYyr?ubc;mo?C=KeOQv;2LK8b=Fx z@v?aIaAtY#WbV0CXL&ZI#?eAvJS~qN&Mf>z3!E#$@1^625rvJ;rw89K|} zpvKWcUOX+29?mS!u*^N<>MYN>)Hqtmi>Kw$!FmU}xP_HI5eY;%RyGaAw&r%rDN-SzD{d(L!E4Esq|~ ztkg%ze()Sw8Dh<7go-o|Z=sXOX^* z_AE7y7V_e0dGv5**`dtsSe<3hQsZbLFP@f14`)_hZp(FhOVBmfb@i~SaVLg@M+Wh( z@jQBHp4jEO>baA-=Tn`vRyB?m^5SWE^l)Z*?qu${RA+fMrN+@hUOX+29?q=wn(q#F zmS)i_$ni>Kw$!N7j*5<7go-o|Z=sXO{id+%q?YLe)50$cvZ7qlYtVZ_QoPI_t@BY8)-(#mnN+!(w*MXPda&a&*>*tH#knUOX+29?mR#;)}xBBQFWMM%yLTxC;tT z3*u>c^w2#2)a4rO8J78moDZGlIhPto3wiOhJbE~@?40Iy($2D%s&TZC7f;KhhcoNK zntR68S)OyLakP*ZFN;SHXO^AQ+)mnA_EI&D7V_e0dGv5***VSaq@86iRpV$OFP@f1 z4`-I0)7(zlS@u#jju!IbX?gT;X4yH-?WCP$FID4cAupbmM-OM#*){h$YG++kHI5eY z;$`vZ;mq<#6`M-wV1Hu2qe@wq}veMXI=g}iuL9zC2{ zb`^8GOlR3=)Hqtmi>Kw$!zc1KXpQ;*13wiOf zc=T{)?Wy@=!OnW9Y8)-(#mnN+!ZNx5I+o@8hDEaMYH z6KcQaztVg&#|Jb2z|f@JuQ@o4*V=VC-jw6JeLp9JKR(B=Ja}CY~*3Jb!C!Q^4jD&d5DklTjT=1~Mu$GH)(r>}F(S-OR{b%s4rLjc0QM%LB&AZ`gSz3ox;4E?}!+ TWaQlZmi;m#BiH7GoaT%GGd>+C delta 151 zcmew%`a^Vr1ta%F%Xmp91}OOdpMed?R0m=SAZD4kQCt!v00KZc6iN1p55*@w;1mE# zA?x9sEXXL%$TeA$Q5{GIGAc7NZ7yZ(W@Kd9%*b5K$jG+2l;t%eBm3q=wr^v#(#1PAPcbBMK)f6Go|L)oXkRPDNjc(&I1 zIhN1Yd3=sD-xud={kgN&{`TYhT4(FmqqTkwe_S!1zi(gL*R!?Q|31$K%Jbt-W3P_) ze9h-_-JO5KZ(T8T-QZK^`g3_Re%ieHT%PFM3m>7@zkhHAnm-7i@8%Ex>0HPaExKi)x+sG*C#(c zMJM_4Sh&6L_n3FMe)#gt629k+tJ_@N%)IBFTb$23x%zbrn!R&xre~ITJ>YiIJo)-) zo;Y=S=kevyjJ~jXab8lQ;^L=o;ZLa_1=r#S*r@{7E zcJA*&V$5RaX7LW!6HdE1eVk@>Wb4(-xTNTr*De$ z#rI8dzWBZ!&KJMOG8fLbXFJbL#U;j@(PZKFirdW|3&-3-teECvaXSc)FQ<1UhGEU^ m1JCbtbj*#Lv*Y){&DUI?eD!8h* literal 0 HcmV?d00001 diff --git a/backend/tests/data/emf/upca_2addon_ggs_5.2.6.6-5.emf b/backend/tests/data/emf/upca_2addon_ggs_5.2.6.6-5.emf index 9d29c327b7be6c0642f41d0910d8712c9368c305..9ba4b41bc62aef28e979e8635bd69e05c56257c6 100644 GIT binary patch delta 49 zcmV-10M7r!4#W&jAgy HAqFD>hBgi( delta 49 zcmV-10M7r!4#Wg`y4} diff --git a/backend/tests/data/emf/upce_2addon.emf b/backend/tests/data/emf/upce_2addon.emf index 73848ceab0290f2da7cba6bc7e10586fce95bfda..23a1fd89773fdeb1ac3105cc7b6458387d2d0c08 100644 GIT binary patch delta 48 zcmV-00MGxl3$zQ6umKB^u^Rylk*Geeh%0G delta 48 zcmV-00MGxl3$zQ6umK8@u^Rykk*Gd@D9=d diff --git a/backend/tests/data/emf/upce_2addon_small_bold.emf b/backend/tests/data/emf/upce_2addon_small_bold.emf index b9e699081e5685cde5986f1faef3c86ba162683e..c1100b7405cbe9db4d3da8ba02320b74f23157fe 100644 GIT binary patch delta 48 zcmV-00MGxl3$zQ6umKB^u^Rylk*Gd+z!$J delta 48 zcmV-00MGxl3$zQ6umK8@u^Rykk*GdP7cff diff --git a/backend/tests/data/eps/code128_egrave_bold_rotate_90.eps b/backend/tests/data/eps/code128_egrave_bold_rotate_90.eps new file mode 100644 index 00000000..6d59260a --- /dev/null +++ b/backend/tests/data/eps/code128_egrave_bold_rotate_90.eps @@ -0,0 +1,98 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 119 224 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 1.00 1.00 setrgbcolor +224.00 0.00 TB 0.00 118.90 TR +TE +0.00 0.00 0.00 setrgbcolor +4.00 220.00 TB 18.90 100.00 TR +TE +2.00 216.00 TB 18.90 100.00 TR +TE +2.00 210.00 TB 18.90 100.00 TR +TE +2.00 200.00 TB 18.90 100.00 TR +TE +8.00 190.00 TB 18.90 100.00 TR +TE +6.00 182.00 TB 18.90 100.00 TR +TE +4.00 176.00 TB 18.90 100.00 TR +TE +2.00 168.00 TB 18.90 100.00 TR +TE +2.00 160.00 TB 18.90 100.00 TR +TE +2.00 156.00 TB 18.90 100.00 TR +TE +4.00 148.00 TB 18.90 100.00 TR +TE +2.00 144.00 TB 18.90 100.00 TR +TE +2.00 134.00 TB 18.90 100.00 TR +TE +4.00 122.00 TB 18.90 100.00 TR +TE +2.00 116.00 TB 18.90 100.00 TR +TE +2.00 112.00 TB 18.90 100.00 TR +TE +2.00 108.00 TB 18.90 100.00 TR +TE +8.00 96.00 TB 18.90 100.00 TR +TE +2.00 90.00 TB 18.90 100.00 TR +TE +2.00 84.00 TB 18.90 100.00 TR +TE +8.00 74.00 TB 18.90 100.00 TR +TE +4.00 66.00 TB 18.90 100.00 TR +TE +4.00 60.00 TB 18.90 100.00 TR +TE +8.00 50.00 TB 18.90 100.00 TR +TE +2.00 46.00 TB 18.90 100.00 TR +TE +4.00 36.00 TB 18.90 100.00 TR +TE +2.00 28.00 TB 18.90 100.00 TR +TE +4.00 22.00 TB 18.90 100.00 TR +TE +6.00 10.00 TB 18.90 100.00 TR +TE +2.00 6.00 TB 18.90 100.00 TR +TE +4.00 0.00 TB 18.90 100.00 TR +TE +/Helvetica-Bold findfont +dup length dict begin +{1 index /FID ne {def} {pop pop} ifelse} forall +/Encoding ISOLatin1Encoding def +currentdict +end +/Helvetica-ISOLatin1 exch definefont pop +matrix currentmatrix +/Helvetica-ISOLatin1 findfont +14.00 scalefont setfont + 0 0 moveto 3.50 112.00 translate 0.00 rotate 0 0 moveto + (gjpqy) stringwidth +gsave +270 rotate +pop +-2 div 0 rmoveto + (gjpqy) show +grestore +setmatrix diff --git a/backend/tests/data/eps/code39_fgalpha_bg_cmyk.eps b/backend/tests/data/eps/code39_fgalpha_bg_cmyk.eps new file mode 100644 index 00000000..ed4fbeda --- /dev/null +++ b/backend/tests/data/eps/code39_fgalpha_bg_cmyk.eps @@ -0,0 +1,76 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 128 119 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +0.00 0.40 0.81 0.02 setcmykcolor +118.90 0.00 TB 0.00 128.00 TR +TE +0.90 0.41 0.00 0.19 setcmykcolor +100.00 18.90 TB 0.00 2.00 TR +TE +100.00 18.90 TB 6.00 2.00 TR +TE +100.00 18.90 TB 10.00 4.00 TR +TE +100.00 18.90 TB 16.00 4.00 TR +TE +100.00 18.90 TB 22.00 2.00 TR +TE +100.00 18.90 TB 26.00 4.00 TR +TE +100.00 18.90 TB 32.00 2.00 TR +TE +100.00 18.90 TB 38.00 2.00 TR +TE +100.00 18.90 TB 42.00 2.00 TR +TE +100.00 18.90 TB 46.00 4.00 TR +TE +100.00 18.90 TB 52.00 2.00 TR +TE +100.00 18.90 TB 56.00 4.00 TR +TE +100.00 18.90 TB 64.00 2.00 TR +TE +100.00 18.90 TB 68.00 2.00 TR +TE +100.00 18.90 TB 72.00 4.00 TR +TE +100.00 18.90 TB 78.00 4.00 TR +TE +100.00 18.90 TB 84.00 4.00 TR +TE +100.00 18.90 TB 92.00 2.00 TR +TE +100.00 18.90 TB 96.00 2.00 TR +TE +100.00 18.90 TB 100.00 2.00 TR +TE +100.00 18.90 TB 104.00 2.00 TR +TE +100.00 18.90 TB 110.00 2.00 TR +TE +100.00 18.90 TB 114.00 4.00 TR +TE +100.00 18.90 TB 120.00 4.00 TR +TE +100.00 18.90 TB 126.00 2.00 TR +TE +matrix currentmatrix +/Helvetica findfont +14.00 scalefont setfont + 0 0 moveto 64.00 3.50 translate 0.00 rotate 0 0 moveto + (*123*) stringwidth +pop +-2 div 0 rmoveto + (*123*) show +setmatrix diff --git a/backend/tests/data/eps/dotcode_no_bg.eps b/backend/tests/data/eps/dotcode_no_bg.eps new file mode 100644 index 00000000..87ec0e98 --- /dev/null +++ b/backend/tests/data/eps/dotcode_no_bg.eps @@ -0,0 +1,42 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 22 16 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 0.00 0.00 setrgbcolor +1.00 15.00 0.80 TD +9.00 15.00 0.80 TD +13.00 15.00 0.80 TD +17.00 15.00 0.80 TD +21.00 15.00 0.80 TD +7.00 13.00 0.80 TD +11.00 13.00 0.80 TD +15.00 13.00 0.80 TD +1.00 11.00 0.80 TD +5.00 11.00 0.80 TD +13.00 11.00 0.80 TD +17.00 11.00 0.80 TD +21.00 11.00 0.80 TD +3.00 9.00 0.80 TD +1.00 7.00 0.80 TD +21.00 7.00 0.80 TD +3.00 5.00 0.80 TD +7.00 5.00 0.80 TD +11.00 5.00 0.80 TD +15.00 5.00 0.80 TD +1.00 3.00 0.80 TD +5.00 3.00 0.80 TD +17.00 3.00 0.80 TD +21.00 3.00 0.80 TD +3.00 1.00 0.80 TD +7.00 1.00 0.80 TD +15.00 1.00 0.80 TD +19.00 1.00 0.80 TD diff --git a/backend/tests/data/eps/maxicode_rotate_270_cmyk.eps b/backend/tests/data/eps/maxicode_rotate_270_cmyk.eps new file mode 100644 index 00000000..e6273cd2 --- /dev/null +++ b/backend/tests/data/eps/maxicode_rotate_270_cmyk.eps @@ -0,0 +1,382 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 58 60 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +0.00 0.00 0.00 0.00 setcmykcolor +60.00 0.00 TB 0.00 57.73 TR +TE +0.00 0.00 0.00 1.00 setcmykcolor +0.15 3.00 0.65 3.87 1.65 3.87 2.15 3.00 1.65 2.13 0.65 2.13 TH +0.15 7.00 0.65 7.87 1.65 7.87 2.15 7.00 1.65 6.13 0.65 6.13 TH +0.15 11.00 0.65 11.87 1.65 11.87 2.15 11.00 1.65 10.13 0.65 10.13 TH +0.15 15.00 0.65 15.87 1.65 15.87 2.15 15.00 1.65 14.13 0.65 14.13 TH +0.15 19.00 0.65 19.87 1.65 19.87 2.15 19.00 1.65 18.13 0.65 18.13 TH +0.15 23.00 0.65 23.87 1.65 23.87 2.15 23.00 1.65 22.13 0.65 22.13 TH +0.15 27.00 0.65 27.87 1.65 27.87 2.15 27.00 1.65 26.13 0.65 26.13 TH +0.15 31.00 0.65 31.87 1.65 31.87 2.15 31.00 1.65 30.13 0.65 30.13 TH +0.15 35.00 0.65 35.87 1.65 35.87 2.15 35.00 1.65 34.13 0.65 34.13 TH +0.15 39.00 0.65 39.87 1.65 39.87 2.15 39.00 1.65 38.13 0.65 38.13 TH +0.15 43.00 0.65 43.87 1.65 43.87 2.15 43.00 1.65 42.13 0.65 42.13 TH +0.15 47.00 0.65 47.87 1.65 47.87 2.15 47.00 1.65 46.13 0.65 46.13 TH +0.15 51.00 0.65 51.87 1.65 51.87 2.15 51.00 1.65 50.13 0.65 50.13 TH +0.15 55.00 0.65 55.87 1.65 55.87 2.15 55.00 1.65 54.13 0.65 54.13 TH +0.15 57.00 0.65 57.87 1.65 57.87 2.15 57.00 1.65 56.13 0.65 56.13 TH +0.15 59.00 0.65 59.87 1.65 59.87 2.15 59.00 1.65 58.13 0.65 58.13 TH +3.62 1.00 4.12 1.87 5.12 1.87 5.62 1.00 5.12 0.13 4.12 0.13 TH +3.62 5.00 4.12 5.87 5.12 5.87 5.62 5.00 5.12 4.13 4.12 4.13 TH +3.62 9.00 4.12 9.87 5.12 9.87 5.62 9.00 5.12 8.13 4.12 8.13 TH +3.62 13.00 4.12 13.87 5.12 13.87 5.62 13.00 5.12 12.13 4.12 12.13 TH +3.62 17.00 4.12 17.87 5.12 17.87 5.62 17.00 5.12 16.13 4.12 16.13 TH +3.62 21.00 4.12 21.87 5.12 21.87 5.62 21.00 5.12 20.13 4.12 20.13 TH +3.62 25.00 4.12 25.87 5.12 25.87 5.62 25.00 5.12 24.13 4.12 24.13 TH +3.62 29.00 4.12 29.87 5.12 29.87 5.62 29.00 5.12 28.13 4.12 28.13 TH +3.62 33.00 4.12 33.87 5.12 33.87 5.62 33.00 5.12 32.13 4.12 32.13 TH +3.62 37.00 4.12 37.87 5.12 37.87 5.62 37.00 5.12 36.13 4.12 36.13 TH +3.62 41.00 4.12 41.87 5.12 41.87 5.62 41.00 5.12 40.13 4.12 40.13 TH +3.62 45.00 4.12 45.87 5.12 45.87 5.62 45.00 5.12 44.13 4.12 44.13 TH +3.62 49.00 4.12 49.87 5.12 49.87 5.62 49.00 5.12 48.13 4.12 48.13 TH +3.62 53.00 4.12 53.87 5.12 53.87 5.62 53.00 5.12 52.13 4.12 52.13 TH +3.62 57.00 4.12 57.87 5.12 57.87 5.62 57.00 5.12 56.13 4.12 56.13 TH +5.35 4.00 5.85 4.87 6.85 4.87 7.35 4.00 6.85 3.13 5.85 3.13 TH +5.35 8.00 5.85 8.87 6.85 8.87 7.35 8.00 6.85 7.13 5.85 7.13 TH +5.35 12.00 5.85 12.87 6.85 12.87 7.35 12.00 6.85 11.13 5.85 11.13 TH +5.35 16.00 5.85 16.87 6.85 16.87 7.35 16.00 6.85 15.13 5.85 15.13 TH +5.35 20.00 5.85 20.87 6.85 20.87 7.35 20.00 6.85 19.13 5.85 19.13 TH +5.35 24.00 5.85 24.87 6.85 24.87 7.35 24.00 6.85 23.13 5.85 23.13 TH +5.35 28.00 5.85 28.87 6.85 28.87 7.35 28.00 6.85 27.13 5.85 27.13 TH +5.35 32.00 5.85 32.87 6.85 32.87 7.35 32.00 6.85 31.13 5.85 31.13 TH +5.35 36.00 5.85 36.87 6.85 36.87 7.35 36.00 6.85 35.13 5.85 35.13 TH +5.35 40.00 5.85 40.87 6.85 40.87 7.35 40.00 6.85 39.13 5.85 39.13 TH +5.35 44.00 5.85 44.87 6.85 44.87 7.35 44.00 6.85 43.13 5.85 43.13 TH +5.35 48.00 5.85 48.87 6.85 48.87 7.35 48.00 6.85 47.13 5.85 47.13 TH +5.35 52.00 5.85 52.87 6.85 52.87 7.35 52.00 6.85 51.13 5.85 51.13 TH +5.35 56.00 5.85 56.87 6.85 56.87 7.35 56.00 6.85 55.13 5.85 55.13 TH +5.35 58.00 5.85 58.87 6.85 58.87 7.35 58.00 6.85 57.13 5.85 57.13 TH +7.08 59.00 7.58 59.87 8.58 59.87 9.08 59.00 8.58 58.13 7.58 58.13 TH +8.81 2.00 9.31 2.87 10.31 2.87 10.81 2.00 10.31 1.13 9.31 1.13 TH +8.81 6.00 9.31 6.87 10.31 6.87 10.81 6.00 10.31 5.13 9.31 5.13 TH +8.81 10.00 9.31 10.87 10.31 10.87 10.81 10.00 10.31 9.13 9.31 9.13 TH +8.81 14.00 9.31 14.87 10.31 14.87 10.81 14.00 10.31 13.13 9.31 13.13 TH +8.81 18.00 9.31 18.87 10.31 18.87 10.81 18.00 10.31 17.13 9.31 17.13 TH +8.81 22.00 9.31 22.87 10.31 22.87 10.81 22.00 10.31 21.13 9.31 21.13 TH +8.81 26.00 9.31 26.87 10.31 26.87 10.81 26.00 10.31 25.13 9.31 25.13 TH +8.81 30.00 9.31 30.87 10.31 30.87 10.81 30.00 10.31 29.13 9.31 29.13 TH +8.81 34.00 9.31 34.87 10.31 34.87 10.81 34.00 10.31 33.13 9.31 33.13 TH +8.81 38.00 9.31 38.87 10.31 38.87 10.81 38.00 10.31 37.13 9.31 37.13 TH +8.81 42.00 9.31 42.87 10.31 42.87 10.81 42.00 10.31 41.13 9.31 41.13 TH +8.81 46.00 9.31 46.87 10.31 46.87 10.81 46.00 10.31 45.13 9.31 45.13 TH +8.81 50.00 9.31 50.87 10.31 50.87 10.81 50.00 10.31 49.13 9.31 49.13 TH +8.81 54.00 9.31 54.87 10.31 54.87 10.81 54.00 10.31 53.13 9.31 53.13 TH +10.55 3.00 11.05 3.87 12.05 3.87 12.55 3.00 12.05 2.13 11.05 2.13 TH +10.55 7.00 11.05 7.87 12.05 7.87 12.55 7.00 12.05 6.13 11.05 6.13 TH +10.55 11.00 11.05 11.87 12.05 11.87 12.55 11.00 12.05 10.13 11.05 10.13 TH +10.55 15.00 11.05 15.87 12.05 15.87 12.55 15.00 12.05 14.13 11.05 14.13 TH +10.55 19.00 11.05 19.87 12.05 19.87 12.55 19.00 12.05 18.13 11.05 18.13 TH +10.55 23.00 11.05 23.87 12.05 23.87 12.55 23.00 12.05 22.13 11.05 22.13 TH +10.55 27.00 11.05 27.87 12.05 27.87 12.55 27.00 12.05 26.13 11.05 26.13 TH +10.55 31.00 11.05 31.87 12.05 31.87 12.55 31.00 12.05 30.13 11.05 30.13 TH +10.55 35.00 11.05 35.87 12.05 35.87 12.55 35.00 12.05 34.13 11.05 34.13 TH +10.55 39.00 11.05 39.87 12.05 39.87 12.55 39.00 12.05 38.13 11.05 38.13 TH +10.55 43.00 11.05 43.87 12.05 43.87 12.55 43.00 12.05 42.13 11.05 42.13 TH +10.55 47.00 11.05 47.87 12.05 47.87 12.55 47.00 12.05 46.13 11.05 46.13 TH +10.55 51.00 11.05 51.87 12.05 51.87 12.55 51.00 12.05 50.13 11.05 50.13 TH +10.55 55.00 11.05 55.87 12.05 55.87 12.55 55.00 12.05 54.13 11.05 54.13 TH +10.55 57.00 11.05 57.87 12.05 57.87 12.55 57.00 12.05 56.13 11.05 56.13 TH +12.28 58.00 12.78 58.87 13.78 58.87 14.28 58.00 13.78 57.13 12.78 57.13 TH +14.01 1.00 14.51 1.87 15.51 1.87 16.01 1.00 15.51 0.13 14.51 0.13 TH +14.01 5.00 14.51 5.87 15.51 5.87 16.01 5.00 15.51 4.13 14.51 4.13 TH +14.01 9.00 14.51 9.87 15.51 9.87 16.01 9.00 15.51 8.13 14.51 8.13 TH +14.01 13.00 14.51 13.87 15.51 13.87 16.01 13.00 15.51 12.13 14.51 12.13 TH +14.01 17.00 14.51 17.87 15.51 17.87 16.01 17.00 15.51 16.13 14.51 16.13 TH +14.01 21.00 14.51 21.87 15.51 21.87 16.01 21.00 15.51 20.13 14.51 20.13 TH +14.01 25.00 14.51 25.87 15.51 25.87 16.01 25.00 15.51 24.13 14.51 24.13 TH +14.01 29.00 14.51 29.87 15.51 29.87 16.01 29.00 15.51 28.13 14.51 28.13 TH +14.01 33.00 14.51 33.87 15.51 33.87 16.01 33.00 15.51 32.13 14.51 32.13 TH +14.01 37.00 14.51 37.87 15.51 37.87 16.01 37.00 15.51 36.13 14.51 36.13 TH +14.01 41.00 14.51 41.87 15.51 41.87 16.01 41.00 15.51 40.13 14.51 40.13 TH +14.01 45.00 14.51 45.87 15.51 45.87 16.01 45.00 15.51 44.13 14.51 44.13 TH +14.01 49.00 14.51 49.87 15.51 49.87 16.01 49.00 15.51 48.13 14.51 48.13 TH +14.01 53.00 14.51 53.87 15.51 53.87 16.01 53.00 15.51 52.13 14.51 52.13 TH +14.01 59.00 14.51 59.87 15.51 59.87 16.01 59.00 15.51 58.13 14.51 58.13 TH +15.74 4.00 16.24 4.87 17.24 4.87 17.74 4.00 17.24 3.13 16.24 3.13 TH +15.74 8.00 16.24 8.87 17.24 8.87 17.74 8.00 17.24 7.13 16.24 7.13 TH +15.74 12.00 16.24 12.87 17.24 12.87 17.74 12.00 17.24 11.13 16.24 11.13 TH +15.74 16.00 16.24 16.87 17.24 16.87 17.74 16.00 17.24 15.13 16.24 15.13 TH +15.74 20.00 16.24 20.87 17.24 20.87 17.74 20.00 17.24 19.13 16.24 19.13 TH +15.74 22.00 16.24 22.87 17.24 22.87 17.74 22.00 17.24 21.13 16.24 21.13 TH +15.74 24.00 16.24 24.87 17.24 24.87 17.74 24.00 17.24 23.13 16.24 23.13 TH +15.74 26.00 16.24 26.87 17.24 26.87 17.74 26.00 17.24 25.13 16.24 25.13 TH +15.74 28.00 16.24 28.87 17.24 28.87 17.74 28.00 17.24 27.13 16.24 27.13 TH +15.74 32.00 16.24 32.87 17.24 32.87 17.74 32.00 17.24 31.13 16.24 31.13 TH +15.74 42.00 16.24 42.87 17.24 42.87 17.74 42.00 17.24 41.13 16.24 41.13 TH +15.74 48.00 16.24 48.87 17.24 48.87 17.74 48.00 17.24 47.13 16.24 47.13 TH +15.74 52.00 16.24 52.87 17.24 52.87 17.74 52.00 17.24 51.13 16.24 51.13 TH +15.74 56.00 16.24 56.87 17.24 56.87 17.74 56.00 17.24 55.13 16.24 55.13 TH +17.47 23.00 17.97 23.87 18.97 23.87 19.47 23.00 18.97 22.13 17.97 22.13 TH +17.47 33.00 17.97 33.87 18.97 33.87 19.47 33.00 18.97 32.13 17.97 32.13 TH +17.47 43.00 17.97 43.87 18.97 43.87 19.47 43.00 18.97 42.13 17.97 42.13 TH +19.21 2.00 19.71 2.87 20.71 2.87 21.21 2.00 20.71 1.13 19.71 1.13 TH +19.21 6.00 19.71 6.87 20.71 6.87 21.21 6.00 20.71 5.13 19.71 5.13 TH +19.21 10.00 19.71 10.87 20.71 10.87 21.21 10.00 20.71 9.13 19.71 9.13 TH +19.21 14.00 19.71 14.87 20.71 14.87 21.21 14.00 20.71 13.13 19.71 13.13 TH +19.21 20.00 19.71 20.87 20.71 20.87 21.21 20.00 20.71 19.13 19.71 19.13 TH +19.21 22.00 19.71 22.87 20.71 22.87 21.21 22.00 20.71 21.13 19.71 21.13 TH +19.21 38.00 19.71 38.87 20.71 38.87 21.21 38.00 20.71 37.13 19.71 37.13 TH +19.21 44.00 19.71 44.87 20.71 44.87 21.21 44.00 20.71 43.13 19.71 43.13 TH +19.21 46.00 19.71 46.87 20.71 46.87 21.21 46.00 20.71 45.13 19.71 45.13 TH +19.21 50.00 19.71 50.87 20.71 50.87 21.21 50.00 20.71 49.13 19.71 49.13 TH +19.21 54.00 19.71 54.87 20.71 54.87 21.21 54.00 20.71 53.13 19.71 53.13 TH +19.21 58.00 19.71 58.87 20.71 58.87 21.21 58.00 20.71 57.13 19.71 57.13 TH +20.94 3.00 21.44 3.87 22.44 3.87 22.94 3.00 22.44 2.13 21.44 2.13 TH +20.94 7.00 21.44 7.87 22.44 7.87 22.94 7.00 22.44 6.13 21.44 6.13 TH +20.94 11.00 21.44 11.87 22.44 11.87 22.94 11.00 22.44 10.13 21.44 10.13 TH +20.94 15.00 21.44 15.87 22.44 15.87 22.94 15.00 22.44 14.13 21.44 14.13 TH +20.94 19.00 21.44 19.87 22.44 19.87 22.94 19.00 22.44 18.13 21.44 18.13 TH +20.94 21.00 21.44 21.87 22.44 21.87 22.94 21.00 22.44 20.13 21.44 20.13 TH +20.94 43.00 21.44 43.87 22.44 43.87 22.94 43.00 22.44 42.13 21.44 42.13 TH +20.94 47.00 21.44 47.87 22.44 47.87 22.94 47.00 22.44 46.13 21.44 46.13 TH +20.94 51.00 21.44 51.87 22.44 51.87 22.94 51.00 22.44 50.13 21.44 50.13 TH +20.94 55.00 21.44 55.87 22.44 55.87 22.94 55.00 22.44 54.13 21.44 54.13 TH +20.94 57.00 21.44 57.87 22.44 57.87 22.94 57.00 22.44 56.13 21.44 56.13 TH +22.67 16.00 23.17 16.87 24.17 16.87 24.67 16.00 24.17 15.13 23.17 15.13 TH +22.67 44.00 23.17 44.87 24.17 44.87 24.67 44.00 24.17 43.13 23.17 43.13 TH +24.40 1.00 24.90 1.87 25.90 1.87 26.40 1.00 25.90 0.13 24.90 0.13 TH +24.40 5.00 24.90 5.87 25.90 5.87 26.40 5.00 25.90 4.13 24.90 4.13 TH +24.40 9.00 24.90 9.87 25.90 9.87 26.40 9.00 25.90 8.13 24.90 8.13 TH +24.40 17.00 24.90 17.87 25.90 17.87 26.40 17.00 25.90 16.13 24.90 16.13 TH +24.40 39.00 24.90 39.87 25.90 39.87 26.40 39.00 25.90 38.13 24.90 38.13 TH +24.40 41.00 24.90 41.87 25.90 41.87 26.40 41.00 25.90 40.13 24.90 40.13 TH +24.40 45.00 24.90 45.87 25.90 45.87 26.40 45.00 25.90 44.13 24.90 44.13 TH +24.40 49.00 24.90 49.87 25.90 49.87 26.40 49.00 25.90 48.13 24.90 48.13 TH +24.40 53.00 24.90 53.87 25.90 53.87 26.40 53.00 25.90 52.13 24.90 52.13 TH +26.13 4.00 26.63 4.87 27.63 4.87 28.13 4.00 27.63 3.13 26.63 3.13 TH +26.13 8.00 26.63 8.87 27.63 8.87 28.13 8.00 27.63 7.13 26.63 7.13 TH +26.13 12.00 26.63 12.87 27.63 12.87 28.13 12.00 27.63 11.13 26.63 11.13 TH +26.13 14.00 26.63 14.87 27.63 14.87 28.13 14.00 27.63 13.13 26.63 13.13 TH +26.13 16.00 26.63 16.87 27.63 16.87 28.13 16.00 27.63 15.13 26.63 15.13 TH +26.13 18.00 26.63 18.87 27.63 18.87 28.13 18.00 27.63 17.13 26.63 17.13 TH +26.13 42.00 26.63 42.87 27.63 42.87 28.13 42.00 27.63 41.13 26.63 41.13 TH +26.13 48.00 26.63 48.87 27.63 48.87 28.13 48.00 27.63 47.13 26.63 47.13 TH +26.13 52.00 26.63 52.87 27.63 52.87 28.13 52.00 27.63 51.13 26.63 51.13 TH +26.13 56.00 26.63 56.87 27.63 56.87 28.13 56.00 27.63 55.13 26.63 55.13 TH +26.13 58.00 26.63 58.87 27.63 58.87 28.13 58.00 27.63 57.13 26.63 57.13 TH +27.87 17.00 28.37 17.87 29.37 17.87 29.87 17.00 29.37 16.13 28.37 16.13 TH +27.87 41.00 28.37 41.87 29.37 41.87 29.87 41.00 29.37 40.13 28.37 40.13 TH +27.87 57.00 28.37 57.87 29.37 57.87 29.87 57.00 29.37 56.13 28.37 56.13 TH +29.60 2.00 30.10 2.87 31.10 2.87 31.60 2.00 31.10 1.13 30.10 1.13 TH +29.60 6.00 30.10 6.87 31.10 6.87 31.60 6.00 31.10 5.13 30.10 5.13 TH +29.60 10.00 30.10 10.87 31.10 10.87 31.60 10.00 31.10 9.13 30.10 9.13 TH +29.60 42.00 30.10 42.87 31.10 42.87 31.60 42.00 31.10 41.13 30.10 41.13 TH +29.60 44.00 30.10 44.87 31.10 44.87 31.60 44.00 31.10 43.13 30.10 43.13 TH +29.60 46.00 30.10 46.87 31.10 46.87 31.60 46.00 31.10 45.13 30.10 45.13 TH +29.60 50.00 30.10 50.87 31.10 50.87 31.60 50.00 31.10 49.13 30.10 49.13 TH +29.60 54.00 30.10 54.87 31.10 54.87 31.60 54.00 31.10 53.13 30.10 53.13 TH +31.33 3.00 31.83 3.87 32.83 3.87 33.33 3.00 32.83 2.13 31.83 2.13 TH +31.33 7.00 31.83 7.87 32.83 7.87 33.33 7.00 32.83 6.13 31.83 6.13 TH +31.33 11.00 31.83 11.87 32.83 11.87 33.33 11.00 32.83 10.13 31.83 10.13 TH +31.33 15.00 31.83 15.87 32.83 15.87 33.33 15.00 32.83 14.13 31.83 14.13 TH +31.33 17.00 31.83 17.87 32.83 17.87 33.33 17.00 32.83 16.13 31.83 16.13 TH +31.33 19.00 31.83 19.87 32.83 19.87 33.33 19.00 32.83 18.13 31.83 18.13 TH +31.33 43.00 31.83 43.87 32.83 43.87 33.33 43.00 32.83 42.13 31.83 42.13 TH +31.33 47.00 31.83 47.87 32.83 47.87 33.33 47.00 32.83 46.13 31.83 46.13 TH +31.33 51.00 31.83 51.87 32.83 51.87 33.33 51.00 32.83 50.13 31.83 50.13 TH +31.33 55.00 31.83 55.87 32.83 55.87 33.33 55.00 32.83 54.13 31.83 54.13 TH +31.33 57.00 31.83 57.87 32.83 57.87 33.33 57.00 32.83 56.13 31.83 56.13 TH +31.33 59.00 31.83 59.87 32.83 59.87 33.33 59.00 32.83 58.13 31.83 58.13 TH +33.06 18.00 33.56 18.87 34.56 18.87 35.06 18.00 34.56 17.13 33.56 17.13 TH +33.06 58.00 33.56 58.87 34.56 58.87 35.06 58.00 34.56 57.13 33.56 57.13 TH +34.79 1.00 35.29 1.87 36.29 1.87 36.79 1.00 36.29 0.13 35.29 0.13 TH +34.79 5.00 35.29 5.87 36.29 5.87 36.79 5.00 36.29 4.13 35.29 4.13 TH +34.79 9.00 35.29 9.87 36.29 9.87 36.79 9.00 36.29 8.13 35.29 8.13 TH +34.79 13.00 35.29 13.87 36.29 13.87 36.79 13.00 36.29 12.13 35.29 12.13 TH +34.79 15.00 35.29 15.87 36.29 15.87 36.79 15.00 36.29 14.13 35.29 14.13 TH +34.79 37.00 35.29 37.87 36.29 37.87 36.79 37.00 36.29 36.13 35.29 36.13 TH +34.79 39.00 35.29 39.87 36.29 39.87 36.79 39.00 36.29 38.13 35.29 38.13 TH +34.79 41.00 35.29 41.87 36.29 41.87 36.79 41.00 36.29 40.13 35.29 40.13 TH +34.79 43.00 35.29 43.87 36.29 43.87 36.79 43.00 36.29 42.13 35.29 42.13 TH +34.79 45.00 35.29 45.87 36.29 45.87 36.79 45.00 36.29 44.13 35.29 44.13 TH +34.79 49.00 35.29 49.87 36.29 49.87 36.79 49.00 36.29 48.13 35.29 48.13 TH +34.79 53.00 35.29 53.87 36.29 53.87 36.79 53.00 36.29 52.13 35.29 52.13 TH +34.79 57.00 35.29 57.87 36.29 57.87 36.79 57.00 36.29 56.13 35.29 56.13 TH +34.79 59.00 35.29 59.87 36.29 59.87 36.79 59.00 36.29 58.13 35.29 58.13 TH +36.53 4.00 37.03 4.87 38.03 4.87 38.53 4.00 38.03 3.13 37.03 3.13 TH +36.53 8.00 37.03 8.87 38.03 8.87 38.53 8.00 38.03 7.13 37.03 7.13 TH +36.53 12.00 37.03 12.87 38.03 12.87 38.53 12.00 38.03 11.13 37.03 11.13 TH +36.53 16.00 37.03 16.87 38.03 16.87 38.53 16.00 38.03 15.13 37.03 15.13 TH +36.53 20.00 37.03 20.87 38.03 20.87 38.53 20.00 38.03 19.13 37.03 19.13 TH +36.53 40.00 37.03 40.87 38.03 40.87 38.53 40.00 38.03 39.13 37.03 39.13 TH +36.53 42.00 37.03 42.87 38.03 42.87 38.53 42.00 38.03 41.13 37.03 41.13 TH +36.53 44.00 37.03 44.87 38.03 44.87 38.53 44.00 38.03 43.13 37.03 43.13 TH +36.53 48.00 37.03 48.87 38.03 48.87 38.53 48.00 38.03 47.13 37.03 47.13 TH +36.53 52.00 37.03 52.87 38.03 52.87 38.53 52.00 38.03 51.13 37.03 51.13 TH +36.53 56.00 37.03 56.87 38.03 56.87 38.53 56.00 38.03 55.13 37.03 55.13 TH +38.26 19.00 38.76 19.87 39.76 19.87 40.26 19.00 39.76 18.13 38.76 18.13 TH +38.26 21.00 38.76 21.87 39.76 21.87 40.26 21.00 39.76 20.13 38.76 20.13 TH +38.26 25.00 38.76 25.87 39.76 25.87 40.26 25.00 39.76 24.13 38.76 24.13 TH +38.26 27.00 38.76 27.87 39.76 27.87 40.26 27.00 39.76 26.13 38.76 26.13 TH +38.26 29.00 38.76 29.87 39.76 29.87 40.26 29.00 39.76 28.13 38.76 28.13 TH +38.26 33.00 38.76 33.87 39.76 33.87 40.26 33.00 39.76 32.13 38.76 32.13 TH +38.26 35.00 38.76 35.87 39.76 35.87 40.26 35.00 39.76 34.13 38.76 34.13 TH +38.26 37.00 38.76 37.87 39.76 37.87 40.26 37.00 39.76 36.13 38.76 36.13 TH +38.26 41.00 38.76 41.87 39.76 41.87 40.26 41.00 39.76 40.13 38.76 40.13 TH +38.26 57.00 38.76 57.87 39.76 57.87 40.26 57.00 39.76 56.13 38.76 56.13 TH +38.26 59.00 38.76 59.87 39.76 59.87 40.26 59.00 39.76 58.13 38.76 58.13 TH +39.99 2.00 40.49 2.87 41.49 2.87 41.99 2.00 41.49 1.13 40.49 1.13 TH +39.99 6.00 40.49 6.87 41.49 6.87 41.99 6.00 41.49 5.13 40.49 5.13 TH +39.99 10.00 40.49 10.87 41.49 10.87 41.99 10.00 41.49 9.13 40.49 9.13 TH +39.99 14.00 40.49 14.87 41.49 14.87 41.99 14.00 41.49 13.13 40.49 13.13 TH +39.99 20.00 40.49 20.87 41.49 20.87 41.99 20.00 41.49 19.13 40.49 19.13 TH +39.99 22.00 40.49 22.87 41.49 22.87 41.99 22.00 41.49 21.13 40.49 21.13 TH +39.99 32.00 40.49 32.87 41.49 32.87 41.99 32.00 41.49 31.13 40.49 31.13 TH +39.99 36.00 40.49 36.87 41.49 36.87 41.99 36.00 41.49 35.13 40.49 35.13 TH +39.99 38.00 40.49 38.87 41.49 38.87 41.99 38.00 41.49 37.13 40.49 37.13 TH +39.99 46.00 40.49 46.87 41.49 46.87 41.99 46.00 41.49 45.13 40.49 45.13 TH +39.99 50.00 40.49 50.87 41.49 50.87 41.99 50.00 41.49 49.13 40.49 49.13 TH +39.99 54.00 40.49 54.87 41.49 54.87 41.99 54.00 41.49 53.13 40.49 53.13 TH +39.99 58.00 40.49 58.87 41.49 58.87 41.99 58.00 41.49 57.13 40.49 57.13 TH +41.72 3.00 42.22 3.87 43.22 3.87 43.72 3.00 43.22 2.13 42.22 2.13 TH +41.72 7.00 42.22 7.87 43.22 7.87 43.72 7.00 43.22 6.13 42.22 6.13 TH +41.72 11.00 42.22 11.87 43.22 11.87 43.72 11.00 43.22 10.13 42.22 10.13 TH +41.72 15.00 42.22 15.87 43.22 15.87 43.72 15.00 43.22 14.13 42.22 14.13 TH +41.72 19.00 42.22 19.87 43.22 19.87 43.72 19.00 43.22 18.13 42.22 18.13 TH +41.72 23.00 42.22 23.87 43.22 23.87 43.72 23.00 43.22 22.13 42.22 22.13 TH +41.72 27.00 42.22 27.87 43.22 27.87 43.72 27.00 43.22 26.13 42.22 26.13 TH +41.72 31.00 42.22 31.87 43.22 31.87 43.72 31.00 43.22 30.13 42.22 30.13 TH +41.72 35.00 42.22 35.87 43.22 35.87 43.72 35.00 43.22 34.13 42.22 34.13 TH +41.72 39.00 42.22 39.87 43.22 39.87 43.72 39.00 43.22 38.13 42.22 38.13 TH +41.72 41.00 42.22 41.87 43.22 41.87 43.72 41.00 43.22 40.13 42.22 40.13 TH +41.72 43.00 42.22 43.87 43.22 43.87 43.72 43.00 43.22 42.13 42.22 42.13 TH +41.72 45.00 42.22 45.87 43.22 45.87 43.72 45.00 43.22 44.13 42.22 44.13 TH +41.72 47.00 42.22 47.87 43.22 47.87 43.72 47.00 43.22 46.13 42.22 46.13 TH +41.72 51.00 42.22 51.87 43.22 51.87 43.72 51.00 43.22 50.13 42.22 50.13 TH +41.72 55.00 42.22 55.87 43.22 55.87 43.72 55.00 43.22 54.13 42.22 54.13 TH +41.72 57.00 42.22 57.87 43.22 57.87 43.72 57.00 43.22 56.13 42.22 56.13 TH +41.72 59.00 42.22 59.87 43.22 59.87 43.72 59.00 43.22 58.13 42.22 58.13 TH +43.45 42.00 43.95 42.87 44.95 42.87 45.45 42.00 44.95 41.13 43.95 41.13 TH +43.45 44.00 43.95 44.87 44.95 44.87 45.45 44.00 44.95 43.13 43.95 43.13 TH +43.45 46.00 43.95 46.87 44.95 46.87 45.45 46.00 44.95 45.13 43.95 45.13 TH +43.45 48.00 43.95 48.87 44.95 48.87 45.45 48.00 44.95 47.13 43.95 47.13 TH +43.45 52.00 43.95 52.87 44.95 52.87 45.45 52.00 44.95 51.13 43.95 51.13 TH +43.45 56.00 43.95 56.87 44.95 56.87 45.45 56.00 44.95 55.13 43.95 55.13 TH +43.45 58.00 43.95 58.87 44.95 58.87 45.45 58.00 44.95 57.13 43.95 57.13 TH +45.19 1.00 45.69 1.87 46.69 1.87 47.19 1.00 46.69 0.13 45.69 0.13 TH +45.19 5.00 45.69 5.87 46.69 5.87 47.19 5.00 46.69 4.13 45.69 4.13 TH +45.19 9.00 45.69 9.87 46.69 9.87 47.19 9.00 46.69 8.13 45.69 8.13 TH +45.19 13.00 45.69 13.87 46.69 13.87 47.19 13.00 46.69 12.13 45.69 12.13 TH +45.19 17.00 45.69 17.87 46.69 17.87 47.19 17.00 46.69 16.13 45.69 16.13 TH +45.19 21.00 45.69 21.87 46.69 21.87 47.19 21.00 46.69 20.13 45.69 20.13 TH +45.19 25.00 45.69 25.87 46.69 25.87 47.19 25.00 46.69 24.13 45.69 24.13 TH +45.19 29.00 45.69 29.87 46.69 29.87 47.19 29.00 46.69 28.13 45.69 28.13 TH +45.19 33.00 45.69 33.87 46.69 33.87 47.19 33.00 46.69 32.13 45.69 32.13 TH +45.19 37.00 45.69 37.87 46.69 37.87 47.19 37.00 46.69 36.13 45.69 36.13 TH +45.19 57.00 45.69 57.87 46.69 57.87 47.19 57.00 46.69 56.13 45.69 56.13 TH +46.92 2.00 47.42 2.87 48.42 2.87 48.92 2.00 48.42 1.13 47.42 1.13 TH +46.92 4.00 47.42 4.87 48.42 4.87 48.92 4.00 48.42 3.13 47.42 3.13 TH +46.92 6.00 47.42 6.87 48.42 6.87 48.92 6.00 48.42 5.13 47.42 5.13 TH +46.92 8.00 47.42 8.87 48.42 8.87 48.92 8.00 48.42 7.13 47.42 7.13 TH +46.92 10.00 47.42 10.87 48.42 10.87 48.92 10.00 48.42 9.13 47.42 9.13 TH +46.92 12.00 47.42 12.87 48.42 12.87 48.92 12.00 48.42 11.13 47.42 11.13 TH +46.92 14.00 47.42 14.87 48.42 14.87 48.92 14.00 48.42 13.13 47.42 13.13 TH +46.92 16.00 47.42 16.87 48.42 16.87 48.92 16.00 48.42 15.13 47.42 15.13 TH +46.92 26.00 47.42 26.87 48.42 26.87 48.92 26.00 48.42 25.13 47.42 25.13 TH +46.92 28.00 47.42 28.87 48.42 28.87 48.92 28.00 48.42 27.13 47.42 27.13 TH +46.92 30.00 47.42 30.87 48.42 30.87 48.92 30.00 48.42 29.13 47.42 29.13 TH +46.92 32.00 47.42 32.87 48.42 32.87 48.92 32.00 48.42 31.13 47.42 31.13 TH +46.92 44.00 47.42 44.87 48.42 44.87 48.92 44.00 48.42 43.13 47.42 43.13 TH +46.92 48.00 47.42 48.87 48.42 48.87 48.92 48.00 48.42 47.13 47.42 47.13 TH +48.65 3.00 49.15 3.87 50.15 3.87 50.65 3.00 50.15 2.13 49.15 2.13 TH +48.65 7.00 49.15 7.87 50.15 7.87 50.65 7.00 50.15 6.13 49.15 6.13 TH +48.65 9.00 49.15 9.87 50.15 9.87 50.65 9.00 50.15 8.13 49.15 8.13 TH +48.65 13.00 49.15 13.87 50.15 13.87 50.65 13.00 50.15 12.13 49.15 12.13 TH +48.65 17.00 49.15 17.87 50.15 17.87 50.65 17.00 50.15 16.13 49.15 16.13 TH +48.65 19.00 49.15 19.87 50.15 19.87 50.65 19.00 50.15 18.13 49.15 18.13 TH +48.65 21.00 49.15 21.87 50.15 21.87 50.65 21.00 50.15 20.13 49.15 20.13 TH +48.65 23.00 49.15 23.87 50.15 23.87 50.65 23.00 50.15 22.13 49.15 22.13 TH +48.65 33.00 49.15 33.87 50.15 33.87 50.65 33.00 50.15 32.13 49.15 32.13 TH +48.65 35.00 49.15 35.87 50.15 35.87 50.65 35.00 50.15 34.13 49.15 34.13 TH +48.65 37.00 49.15 37.87 50.15 37.87 50.65 37.00 50.15 36.13 49.15 36.13 TH +48.65 39.00 49.15 39.87 50.15 39.87 50.65 39.00 50.15 38.13 49.15 38.13 TH +48.65 43.00 49.15 43.87 50.15 43.87 50.65 43.00 50.15 42.13 49.15 42.13 TH +48.65 47.00 49.15 47.87 50.15 47.87 50.65 47.00 50.15 46.13 49.15 46.13 TH +48.65 51.00 49.15 51.87 50.15 51.87 50.65 51.00 50.15 50.13 49.15 50.13 TH +48.65 55.00 49.15 55.87 50.15 55.87 50.65 55.00 50.15 54.13 49.15 54.13 TH +50.38 2.00 50.88 2.87 51.88 2.87 52.38 2.00 51.88 1.13 50.88 1.13 TH +50.38 6.00 50.88 6.87 51.88 6.87 52.38 6.00 51.88 5.13 50.88 5.13 TH +50.38 10.00 50.88 10.87 51.88 10.87 52.38 10.00 51.88 9.13 50.88 9.13 TH +50.38 14.00 50.88 14.87 51.88 14.87 52.38 14.00 51.88 13.13 50.88 13.13 TH +50.38 28.00 50.88 28.87 51.88 28.87 52.38 28.00 51.88 27.13 50.88 27.13 TH +50.38 32.00 50.88 32.87 51.88 32.87 52.38 32.00 51.88 31.13 50.88 31.13 TH +50.38 36.00 50.88 36.87 51.88 36.87 52.38 36.00 51.88 35.13 50.88 35.13 TH +50.38 40.00 50.88 40.87 51.88 40.87 52.38 40.00 51.88 39.13 50.88 39.13 TH +50.38 42.00 50.88 42.87 51.88 42.87 52.38 42.00 51.88 41.13 50.88 41.13 TH +50.38 44.00 50.88 44.87 51.88 44.87 52.38 44.00 51.88 43.13 50.88 43.13 TH +50.38 46.00 50.88 46.87 51.88 46.87 52.38 46.00 51.88 45.13 50.88 45.13 TH +50.38 48.00 50.88 48.87 51.88 48.87 52.38 48.00 51.88 47.13 50.88 47.13 TH +50.38 50.00 50.88 50.87 51.88 50.87 52.38 50.00 51.88 49.13 50.88 49.13 TH +50.38 54.00 50.88 54.87 51.88 54.87 52.38 54.00 51.88 53.13 50.88 53.13 TH +50.38 58.00 50.88 58.87 51.88 58.87 52.38 58.00 51.88 57.13 50.88 57.13 TH +52.11 1.00 52.61 1.87 53.61 1.87 54.11 1.00 53.61 0.13 52.61 0.13 TH +52.11 3.00 52.61 3.87 53.61 3.87 54.11 3.00 53.61 2.13 52.61 2.13 TH +52.11 5.00 52.61 5.87 53.61 5.87 54.11 5.00 53.61 4.13 52.61 4.13 TH +52.11 7.00 52.61 7.87 53.61 7.87 54.11 7.00 53.61 6.13 52.61 6.13 TH +52.11 11.00 52.61 11.87 53.61 11.87 54.11 11.00 53.61 10.13 52.61 10.13 TH +52.11 15.00 52.61 15.87 53.61 15.87 54.11 15.00 53.61 14.13 52.61 14.13 TH +52.11 17.00 52.61 17.87 53.61 17.87 54.11 17.00 53.61 16.13 52.61 16.13 TH +52.11 21.00 52.61 21.87 53.61 21.87 54.11 21.00 53.61 20.13 52.61 20.13 TH +52.11 33.00 52.61 33.87 53.61 33.87 54.11 33.00 53.61 32.13 52.61 32.13 TH +52.11 35.00 52.61 35.87 53.61 35.87 54.11 35.00 53.61 34.13 52.61 34.13 TH +52.11 37.00 52.61 37.87 53.61 37.87 54.11 37.00 53.61 36.13 52.61 36.13 TH +52.11 39.00 52.61 39.87 53.61 39.87 54.11 39.00 53.61 38.13 52.61 38.13 TH +52.11 43.00 52.61 43.87 53.61 43.87 54.11 43.00 53.61 42.13 52.61 42.13 TH +52.11 47.00 52.61 47.87 53.61 47.87 54.11 47.00 53.61 46.13 52.61 46.13 TH +52.11 49.00 52.61 49.87 53.61 49.87 54.11 49.00 53.61 48.13 52.61 48.13 TH +52.11 53.00 52.61 53.87 53.61 53.87 54.11 53.00 53.61 52.13 52.61 52.13 TH +52.11 57.00 52.61 57.87 53.61 57.87 54.11 57.00 53.61 56.13 52.61 56.13 TH +53.85 4.00 54.35 4.87 55.35 4.87 55.85 4.00 55.35 3.13 54.35 3.13 TH +53.85 8.00 54.35 8.87 55.35 8.87 55.85 8.00 55.35 7.13 54.35 7.13 TH +53.85 10.00 54.35 10.87 55.35 10.87 55.85 10.00 55.35 9.13 54.35 9.13 TH +53.85 14.00 54.35 14.87 55.35 14.87 55.85 14.00 55.35 13.13 54.35 13.13 TH +53.85 18.00 54.35 18.87 55.35 18.87 55.85 18.00 55.35 17.13 54.35 17.13 TH +53.85 20.00 54.35 20.87 55.35 20.87 55.85 20.00 55.35 19.13 54.35 19.13 TH +53.85 22.00 54.35 22.87 55.35 22.87 55.85 22.00 55.35 21.13 54.35 21.13 TH +53.85 24.00 54.35 24.87 55.35 24.87 55.85 24.00 55.35 23.13 54.35 23.13 TH +53.85 28.00 54.35 28.87 55.35 28.87 55.85 28.00 55.35 27.13 54.35 27.13 TH +53.85 32.00 54.35 32.87 55.35 32.87 55.85 32.00 55.35 31.13 54.35 31.13 TH +53.85 34.00 54.35 34.87 55.35 34.87 55.85 34.00 55.35 33.13 54.35 33.13 TH +53.85 38.00 54.35 38.87 55.35 38.87 55.85 38.00 55.35 37.13 54.35 37.13 TH +53.85 42.00 54.35 42.87 55.35 42.87 55.85 42.00 55.35 41.13 54.35 41.13 TH +53.85 46.00 54.35 46.87 55.35 46.87 55.85 46.00 55.35 45.13 54.35 45.13 TH +53.85 50.00 54.35 50.87 55.35 50.87 55.85 50.00 55.35 49.13 54.35 49.13 TH +53.85 52.00 54.35 52.87 55.35 52.87 55.85 52.00 55.35 51.13 54.35 51.13 TH +53.85 54.00 54.35 54.87 55.35 54.87 55.85 54.00 55.35 53.13 54.35 53.13 TH +53.85 56.00 54.35 56.87 55.35 56.87 55.85 56.00 55.35 55.13 54.35 55.13 TH +55.58 3.00 56.08 3.87 57.08 3.87 57.58 3.00 57.08 2.13 56.08 2.13 TH +55.58 7.00 56.08 7.87 57.08 7.87 57.58 7.00 57.08 6.13 56.08 6.13 TH +55.58 27.00 56.08 27.87 57.08 27.87 57.58 27.00 57.08 26.13 56.08 26.13 TH +55.58 31.00 56.08 31.87 57.08 31.87 57.58 31.00 57.08 30.13 56.08 30.13 TH +55.58 33.00 56.08 33.87 57.08 33.87 57.58 33.00 57.08 32.13 56.08 32.13 TH +55.58 37.00 56.08 37.87 57.08 37.87 57.58 37.00 57.08 36.13 56.08 36.13 TH +55.58 41.00 56.08 41.87 57.08 41.87 57.58 41.00 57.08 40.13 56.08 40.13 TH +55.58 45.00 56.08 45.87 57.08 45.87 57.58 45.00 57.08 44.13 56.08 44.13 TH +55.58 51.00 56.08 51.87 57.08 51.87 57.58 51.00 57.08 50.13 56.08 50.13 TH +55.58 55.00 56.08 55.87 57.08 55.87 57.58 55.00 57.08 54.13 56.08 54.13 TH +28.87 29.00 9.00 TD +0.00 0.00 0.00 0.00 setcmykcolor +28.87 29.00 7.43 TD +0.00 0.00 0.00 1.00 setcmykcolor +28.87 29.00 5.86 TD +0.00 0.00 0.00 0.00 setcmykcolor +28.87 29.00 4.29 TD +0.00 0.00 0.00 1.00 setcmykcolor +28.87 29.00 2.72 TD +0.00 0.00 0.00 0.00 setcmykcolor +28.87 29.00 1.15 TD diff --git a/backend/tests/data/eps/ultra_fg_bg_box.eps b/backend/tests/data/eps/ultra_fg_bg_box.eps new file mode 100644 index 00000000..7dcdfad0 --- /dev/null +++ b/backend/tests/data/eps/ultra_fg_bg_box.eps @@ -0,0 +1,227 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 40 30 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +1.00 0.00 0.00 setrgbcolor +30.00 0.00 TB 0.00 40.00 TR +TE +0.00 0.00 1.00 setrgbcolor +2.00 28.00 TB 0.00 40.00 TR +TE +2.00 0.00 TB 0.00 40.00 TR +TE +26.00 2.00 TB 0.00 2.00 TR +TE +26.00 2.00 TB 38.00 2.00 TR +TE +0.00 1.00 1.00 setrgbcolor +2.00 24.00 TB 22.00 4.00 TR +TE +2.00 24.00 TB 28.00 4.00 TR +TE +2.00 22.00 TB 18.00 2.00 TR +TE +2.00 20.00 TB 10.00 2.00 TR +TE +2.00 20.00 TB 22.00 2.00 TR +TE +2.00 20.00 TB 28.00 4.00 TR +TE +2.00 16.00 TB 16.00 2.00 TR +TE +2.00 12.00 TB 16.00 2.00 TR +TE +2.00 12.00 TB 20.00 2.00 TR +TE +2.00 12.00 TB 24.00 8.00 TR +TE +2.00 10.00 TB 10.00 2.00 TR +TE +2.00 10.00 TB 22.00 2.00 TR +TE +2.00 8.00 TB 26.00 4.00 TR +TE +2.00 6.00 TB 16.00 6.00 TR +TE +2.00 6.00 TB 30.00 2.00 TR +TE +2.00 4.00 TB 10.00 2.00 TR +TE +1.00 0.00 1.00 setrgbcolor +2.00 24.00 TB 20.00 2.00 TR +TE +2.00 22.00 TB 10.00 2.00 TR +TE +2.00 22.00 TB 16.00 2.00 TR +TE +2.00 22.00 TB 22.00 4.00 TR +TE +2.00 20.00 TB 18.00 2.00 TR +TE +2.00 18.00 TB 20.00 2.00 TR +TE +2.00 18.00 TB 24.00 2.00 TR +TE +2.00 16.00 TB 10.00 2.00 TR +TE +2.00 16.00 TB 22.00 2.00 TR +TE +2.00 16.00 TB 28.00 2.00 TR +TE +2.00 10.00 TB 16.00 2.00 TR +TE +2.00 10.00 TB 24.00 4.00 TR +TE +2.00 10.00 TB 30.00 2.00 TR +TE +2.00 8.00 TB 20.00 2.00 TR +TE +2.00 4.00 TB 16.00 12.00 TR +TE +1.00 1.00 0.00 setrgbcolor +2.00 24.00 TB 10.00 2.00 TR +TE +2.00 24.00 TB 18.00 2.00 TR +TE +2.00 24.00 TB 26.00 2.00 TR +TE +2.00 20.00 TB 20.00 2.00 TR +TE +2.00 20.00 TB 26.00 2.00 TR +TE +2.00 18.00 TB 10.00 2.00 TR +TE +2.00 18.00 TB 16.00 2.00 TR +TE +2.00 18.00 TB 22.00 2.00 TR +TE +2.00 18.00 TB 28.00 2.00 TR +TE +2.00 16.00 TB 18.00 4.00 TR +TE +2.00 16.00 TB 26.00 2.00 TR +TE +2.00 16.00 TB 30.00 2.00 TR +TE +2.00 12.00 TB 22.00 2.00 TR +TE +2.00 10.00 TB 18.00 4.00 TR +TE +2.00 8.00 TB 10.00 2.00 TR +TE +2.00 8.00 TB 16.00 2.00 TR +TE +2.00 8.00 TB 22.00 4.00 TR +TE +2.00 8.00 TB 30.00 2.00 TR +TE +2.00 6.00 TB 28.00 2.00 TR +TE +2.00 4.00 TB 30.00 2.00 TR +TE +0.00 1.00 0.00 setrgbcolor +2.00 24.00 TB 16.00 2.00 TR +TE +2.00 22.00 TB 20.00 2.00 TR +TE +2.00 22.00 TB 26.00 6.00 TR +TE +2.00 20.00 TB 16.00 2.00 TR +TE +2.00 20.00 TB 24.00 2.00 TR +TE +2.00 18.00 TB 18.00 2.00 TR +TE +2.00 18.00 TB 26.00 2.00 TR +TE +2.00 18.00 TB 30.00 2.00 TR +TE +2.00 16.00 TB 24.00 2.00 TR +TE +2.00 12.00 TB 10.00 2.00 TR +TE +2.00 12.00 TB 18.00 2.00 TR +TE +2.00 10.00 TB 28.00 2.00 TR +TE +2.00 8.00 TB 18.00 2.00 TR +TE +2.00 6.00 TB 10.00 2.00 TR +TE +2.00 6.00 TB 22.00 6.00 TR +TE +2.00 4.00 TB 28.00 2.00 TR +TE +0.00 0.00 0.00 setrgbcolor +2.00 26.00 TB 6.00 28.00 TR +TE +2.00 24.00 TB 6.00 2.00 TR +TE +22.00 4.00 TB 12.00 2.00 TR +TE +22.00 4.00 TB 32.00 2.00 TR +TE +2.00 22.00 TB 6.00 4.00 TR +TE +2.00 20.00 TB 6.00 2.00 TR +TE +2.00 18.00 TB 6.00 4.00 TR +TE +2.00 16.00 TB 6.00 2.00 TR +TE +2.00 14.00 TB 6.00 4.00 TR +TE +2.00 14.00 TB 16.00 2.00 TR +TE +2.00 14.00 TB 20.00 2.00 TR +TE +2.00 14.00 TB 24.00 2.00 TR +TE +2.00 14.00 TB 28.00 2.00 TR +TE +2.00 12.00 TB 6.00 2.00 TR +TE +2.00 10.00 TB 6.00 4.00 TR +TE +2.00 8.00 TB 6.00 2.00 TR +TE +2.00 6.00 TB 6.00 4.00 TR +TE +2.00 4.00 TB 6.00 2.00 TR +TE +2.00 2.00 TB 6.00 28.00 TR +TE +1.00 1.00 1.00 setrgbcolor +2.00 24.00 TB 8.00 2.00 TR +TE +22.00 4.00 TB 14.00 2.00 TR +TE +2.00 20.00 TB 8.00 2.00 TR +TE +2.00 16.00 TB 8.00 2.00 TR +TE +2.00 14.00 TB 10.00 2.00 TR +TE +2.00 14.00 TB 18.00 2.00 TR +TE +2.00 14.00 TB 22.00 2.00 TR +TE +2.00 14.00 TB 26.00 2.00 TR +TE +2.00 14.00 TB 30.00 2.00 TR +TE +2.00 12.00 TB 8.00 2.00 TR +TE +2.00 8.00 TB 8.00 2.00 TR +TE +2.00 4.00 TB 8.00 2.00 TR +TE diff --git a/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps b/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps new file mode 100644 index 00000000..a945596e --- /dev/null +++ b/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps @@ -0,0 +1,227 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.9.1.9 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 40 38 +%%EndComments +/TL { setlinewidth moveto lineto stroke } bind def +/TD { newpath 0 360 arc fill } bind def +/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def +/TB { 2 copy } bind def +/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def +/TE { pop pop } bind def +newpath +0.00 1.00 1.00 0.00 setcmykcolor +38.00 0.00 TB 0.00 40.00 TR +TE +1.00 1.00 0.00 0.00 setcmykcolor +4.00 32.00 TB 0.00 40.00 TR +TE +4.00 2.00 TB 0.00 40.00 TR +TE +26.00 6.00 TB 0.00 4.00 TR +TE +26.00 6.00 TB 36.00 4.00 TR +TE +1.00 0.00 0.00 0.00 setcmykcolor +2.00 28.00 TB 22.00 4.00 TR +TE +2.00 28.00 TB 28.00 4.00 TR +TE +2.00 26.00 TB 18.00 2.00 TR +TE +2.00 24.00 TB 10.00 2.00 TR +TE +2.00 24.00 TB 22.00 2.00 TR +TE +2.00 24.00 TB 28.00 4.00 TR +TE +2.00 20.00 TB 16.00 2.00 TR +TE +2.00 16.00 TB 16.00 2.00 TR +TE +2.00 16.00 TB 20.00 2.00 TR +TE +2.00 16.00 TB 24.00 8.00 TR +TE +2.00 14.00 TB 10.00 2.00 TR +TE +2.00 14.00 TB 22.00 2.00 TR +TE +2.00 12.00 TB 26.00 4.00 TR +TE +2.00 10.00 TB 16.00 6.00 TR +TE +2.00 10.00 TB 30.00 2.00 TR +TE +2.00 8.00 TB 10.00 2.00 TR +TE +0.00 1.00 0.00 0.00 setcmykcolor +2.00 28.00 TB 20.00 2.00 TR +TE +2.00 26.00 TB 10.00 2.00 TR +TE +2.00 26.00 TB 16.00 2.00 TR +TE +2.00 26.00 TB 22.00 4.00 TR +TE +2.00 24.00 TB 18.00 2.00 TR +TE +2.00 22.00 TB 20.00 2.00 TR +TE +2.00 22.00 TB 24.00 2.00 TR +TE +2.00 20.00 TB 10.00 2.00 TR +TE +2.00 20.00 TB 22.00 2.00 TR +TE +2.00 20.00 TB 28.00 2.00 TR +TE +2.00 14.00 TB 16.00 2.00 TR +TE +2.00 14.00 TB 24.00 4.00 TR +TE +2.00 14.00 TB 30.00 2.00 TR +TE +2.00 12.00 TB 20.00 2.00 TR +TE +2.00 8.00 TB 16.00 12.00 TR +TE +0.00 0.00 1.00 0.00 setcmykcolor +2.00 28.00 TB 10.00 2.00 TR +TE +2.00 28.00 TB 18.00 2.00 TR +TE +2.00 28.00 TB 26.00 2.00 TR +TE +2.00 24.00 TB 20.00 2.00 TR +TE +2.00 24.00 TB 26.00 2.00 TR +TE +2.00 22.00 TB 10.00 2.00 TR +TE +2.00 22.00 TB 16.00 2.00 TR +TE +2.00 22.00 TB 22.00 2.00 TR +TE +2.00 22.00 TB 28.00 2.00 TR +TE +2.00 20.00 TB 18.00 4.00 TR +TE +2.00 20.00 TB 26.00 2.00 TR +TE +2.00 20.00 TB 30.00 2.00 TR +TE +2.00 16.00 TB 22.00 2.00 TR +TE +2.00 14.00 TB 18.00 4.00 TR +TE +2.00 12.00 TB 10.00 2.00 TR +TE +2.00 12.00 TB 16.00 2.00 TR +TE +2.00 12.00 TB 22.00 4.00 TR +TE +2.00 12.00 TB 30.00 2.00 TR +TE +2.00 10.00 TB 28.00 2.00 TR +TE +2.00 8.00 TB 30.00 2.00 TR +TE +1.00 0.00 1.00 0.00 setcmykcolor +2.00 28.00 TB 16.00 2.00 TR +TE +2.00 26.00 TB 20.00 2.00 TR +TE +2.00 26.00 TB 26.00 6.00 TR +TE +2.00 24.00 TB 16.00 2.00 TR +TE +2.00 24.00 TB 24.00 2.00 TR +TE +2.00 22.00 TB 18.00 2.00 TR +TE +2.00 22.00 TB 26.00 2.00 TR +TE +2.00 22.00 TB 30.00 2.00 TR +TE +2.00 20.00 TB 24.00 2.00 TR +TE +2.00 16.00 TB 10.00 2.00 TR +TE +2.00 16.00 TB 18.00 2.00 TR +TE +2.00 14.00 TB 28.00 2.00 TR +TE +2.00 12.00 TB 18.00 2.00 TR +TE +2.00 10.00 TB 10.00 2.00 TR +TE +2.00 10.00 TB 22.00 6.00 TR +TE +2.00 8.00 TB 28.00 2.00 TR +TE +0.00 0.00 0.00 1.00 setcmykcolor +2.00 30.00 TB 6.00 28.00 TR +TE +2.00 28.00 TB 6.00 2.00 TR +TE +22.00 8.00 TB 12.00 2.00 TR +TE +22.00 8.00 TB 32.00 2.00 TR +TE +2.00 26.00 TB 6.00 4.00 TR +TE +2.00 24.00 TB 6.00 2.00 TR +TE +2.00 22.00 TB 6.00 4.00 TR +TE +2.00 20.00 TB 6.00 2.00 TR +TE +2.00 18.00 TB 6.00 4.00 TR +TE +2.00 18.00 TB 16.00 2.00 TR +TE +2.00 18.00 TB 20.00 2.00 TR +TE +2.00 18.00 TB 24.00 2.00 TR +TE +2.00 18.00 TB 28.00 2.00 TR +TE +2.00 16.00 TB 6.00 2.00 TR +TE +2.00 14.00 TB 6.00 4.00 TR +TE +2.00 12.00 TB 6.00 2.00 TR +TE +2.00 10.00 TB 6.00 4.00 TR +TE +2.00 8.00 TB 6.00 2.00 TR +TE +2.00 6.00 TB 6.00 28.00 TR +TE +0.00 0.00 0.00 0.00 setcmykcolor +2.00 28.00 TB 8.00 2.00 TR +TE +22.00 8.00 TB 14.00 2.00 TR +TE +2.00 24.00 TB 8.00 2.00 TR +TE +2.00 20.00 TB 8.00 2.00 TR +TE +2.00 18.00 TB 10.00 2.00 TR +TE +2.00 18.00 TB 18.00 2.00 TR +TE +2.00 18.00 TB 22.00 2.00 TR +TE +2.00 18.00 TB 26.00 2.00 TR +TE +2.00 18.00 TB 30.00 2.00 TR +TE +2.00 16.00 TB 8.00 2.00 TR +TE +2.00 12.00 TB 8.00 2.00 TR +TE +2.00 8.00 TB 8.00 2.00 TR +TE diff --git a/backend/tests/data/gif/dotcode_bgfgalpha.gif b/backend/tests/data/gif/dotcode_bgfgalpha.gif new file mode 100644 index 0000000000000000000000000000000000000000..dedd7d88b9f922197acf633ee049ea72db31a6db GIT binary patch literal 70 zcmZ?wbh9u|6lV}*_`tyM_x~ZalEXR-KmZb9U{Y=AUnze3n?uj)D3hCa&9(Ill}x57 Yhc0@yeB!%PjZ=BlzpTFIz{p??04wtu%m4rY literal 0 HcmV?d00001 diff --git a/backend/tests/data/gif/dotcode_bgfgtrans.gif b/backend/tests/data/gif/dotcode_bgfgtrans.gif new file mode 100644 index 0000000000000000000000000000000000000000..4eb4f5c959bec307a65a41c1ee03d4858caf59f0 GIT binary patch literal 78 zcmZ?wbhEHb6lV}*_`tyM|Nnmm1_s5SEQ~;kK?g*DWEhxKTl!au-~Q&%vpUM;=3R4b e{X!*^Y09CCo-LpF?o{Jc9`!G)uQ@O>SOWlIaT(75 literal 0 HcmV?d00001 diff --git a/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif b/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif new file mode 100644 index 0000000000000000000000000000000000000000..25036164407644c97e7953549a2b7543e118d5ae GIT binary patch literal 324 zcmZ?wbh9u|RAEqJ_{6~Qp8*I!#D5R~F~RV^4oDoNhJpD%$F4j73{Jgl+H3Lp?C$?_ zlzLJ!=dEb!%y>QN)loiX$DWcviDQK?tY)7#>xxX%R?$m;)1dHn`c`X<*m+ zQ4Vp;lPP8;W);n|+*?iNGS6pO$g;R^nW{&TTokFq|$F_77IrX1b4cZl#VKOmKaIt%$f>W1_ Q=OvNW$r{0{d>9z40nbvEoB#j- literal 0 HcmV?d00001 diff --git a/backend/tests/data/pcx/codeblockf_reverse.pcx b/backend/tests/data/pcx/codeblockf_reverse.pcx new file mode 100644 index 0000000000000000000000000000000000000000..d3c29da40485d1ad8ba214cb6d48b55376c6c684 GIT binary patch literal 28664 zcmeI50cwLV7=LqEQ_2_1XFjEE%7)yhJ|D|El(kP|S&wB^`B2KVs$8Gr zv_1ZQAIo=d>*qR#j-`F-G4|VcoX$hnGnDhxXPk>_maA4>(AM;D?(2vOL^EPI%4Ln* zL+jCNC)6e5L4PH6XLZ$iE&m_YFZS^aI?o!@@mrLuC&m4w&-!%L$L~uUhU)k_ zmS~)-jvBas21koFb=zI{8QPj2?!Li&9d|0x>^ip)^)k;o5zUm{TtC)=7!IYh=mY3A zdW~M=K8ERiG~v?Z&@SH))EOI%rIkv+W^3Of z-a?lhlidoY9rPN#cHba_6kZX%Mz7IpD+PKTQGqc?{r}q3f=}h{dUh%kq@N#ar$|c@lP0-d`}sb67@h~;;W2Pt z^}Kyq{ZCtj+2=){Jv|Le@)2Ij2v22N#xs$_D*m=?AWm4th(ZKUyV2^zT=#hHs1wz7 zgI6fbixpHBXlKUTEFhbk2x+zN+rg2*;RJtaTWBrbnu->8_IU z>&NM5$LF2DkJHCV^Ie~}-`)P3T82wkrqZ3KGryOP)y!&UHG8$NT39V!{o|FT`}CE< zEymZHsIi65ilH^%&Y?W47+UlFGD4Yp=Z^DLE*T>~v*aN@!6{?#V3vHuE4XD0RAzZH zoiI+Bu|tppQ9Yp+HQS0DT-76X>p51=!Bss|J?}aHKjgt0dc=3Io*r=>tgS~pk3qBU z%qwcybXd$OYS?sG%qMEsbXZ=v7HJ??zHLvZx>xNp!>4qxC`9}B01A^}ik=PeCtK z&IR3c-A7iXCejTRJu~lr1263|o>}XlaoQ1ega%({!X9zWck!WGOHFk&=Y#lacCLq( vC*`!xHD>|W(v2EYC7I&lBJH?tF)Mf)W-yj$>m#4OEx$(&?_IuwkKV(dC%(Zy literal 0 HcmV?d00001 diff --git a/backend/tests/data/png/aztec.png b/backend/tests/data/png/aztec.png new file mode 100644 index 0000000000000000000000000000000000000000..5507506fc0e047650281dddaa4d79a9a39822c99 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^av;pe3?v!<**pYNYymzYuK)l42QotsU9JOC{+=$5 zAsp9rPZ@F@FyLUlz`w3BPW6G*hgVKv3&RC>acz52UU`|>hO6C#=Td~z1hrhEA|8ow%MQ(?jT`-lUyuo!gY&-R9TVFt)FpKKaO9pwSGTu6{1-oD!MS!VDx2Hf`$$QW60^A+G=b|7QRq5Qb6=Kpq3b zENj*IK&sNy#W6(VeD9@;oX&nIcit@t(&@U+d-FlJGSP>9@A(3pX1AJ zIon8U3PX3Vd)eb{u|7Rga~i~F_g%WMOh>K1W3ol$o4ZwF>cQ?yT95Bzmv&pXFJa}CY~*3Jb!C!Q^4M diff --git a/backend/tests/data/print/emf/dotcode_aim_fig7.emf b/backend/tests/data/print/emf/dotcode_aim_fig7.emf index 42b87b01693b56f2773d9bc00332d65626215c66..73c1d70efa9d664c0882873e49b63bffd1840c4f 100644 GIT binary patch delta 17 ZcmdnPxrcMY21f3Q8`T-PH{N{A3;;W?2D|_O delta 17 ZcmdnPxrcMY21c%l8`T-PHr{;93;;Wz2D$(M diff --git a/backend/tests/data/print/emf/maxicode_fig_2.emf b/backend/tests/data/print/emf/maxicode_fig_2.emf index db5bb7b85edce1f2606f625ec855f76a85d0a819..564059759d0136c437d4ae547f5490d17577783f 100644 GIT binary patch delta 19 bcmdmRiE+av#t9o3xhHN^XXM^^Gdu$TRj~*W delta 19 bcmdmRiE+av#t9o3xh8H@XXM&=Gdu$TRiX$F diff --git a/backend/tests/data/print/emf/qr_v1_m.emf b/backend/tests/data/print/emf/qr_v1_m.emf index 069c0641be77abaa05c601d6a3c35a61d4a73dc8..1fb8e5ec913283315bf8e863e0de9eeb3ddec702 100644 GIT binary patch delta 17 ZcmaDN@I+w321f3Q8`T-PH{R@K2LM3T2F3sY delta 17 ZcmaDN@I+w321c%l8`T-PHs0)J2LM3E2E+gW diff --git a/backend/tests/data/print/emf/ultracode_a.emf b/backend/tests/data/print/emf/ultracode_a.emf index 9cc2caa15a241900fbc477ac3503959392a234c4..7d7c28c4a8e45d1be3b7662d835bdfd100a10330 100644 GIT binary patch delta 160 zcmZn=Z4jMc!N@bwGG3CI0Sf;AXJ7*|)qz+7h*>9Y6qjU2$e~DbOnfLV$qAJNQOG*E zCJQo(GjdPXWK;)|fsD$G%$rLYyBQf-H#0JKGfraT**t?KgK=^Nkio;2!N|x7R3yH+ Phy4m8BiH6cPI*QEVk#OP delta 160 zcmZn=Z4jMc!N@()GG3C20Sf;AXJ7*|)qz+7h*>6X6qf`EfB;YqMUs8uL-C0ZI0b-G z$a**@3o?o`a!uA`R0ooQjLM8mn@btH87E7y@oeT{ZeV0&+uX}i%s9D+1;}U1V4TFp ZGg*LxWpV-|$L1dPD~ybsn-e+Z838^K9Pj`D diff --git a/backend/tests/data/svg/maxicode_fgbg_rotate_90.svg b/backend/tests/data/svg/maxicode_fgbg_rotate_90.svg new file mode 100644 index 00000000..350f363a --- /dev/null +++ b/backend/tests/data/svg/maxicode_fgbg_rotate_90.svg @@ -0,0 +1,380 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg b/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg new file mode 100644 index 00000000..2c4d23b2 --- /dev/null +++ b/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg @@ -0,0 +1,181 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/upce_cc_2addon_cca_5x2_fgbgalpha.svg b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_fgbgalpha.svg new file mode 100644 index 00000000..f35125df --- /dev/null +++ b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_fgbgalpha.svg @@ -0,0 +1,107 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 654321 + + + 7 + + + 89 + + + diff --git a/backend/tests/data/svg/upce_cc_2addon_cca_5x2_nobg.svg b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_nobg.svg new file mode 100644 index 00000000..ce003fcb --- /dev/null +++ b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_nobg.svg @@ -0,0 +1,106 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 654321 + + + 7 + + + 89 + + + diff --git a/backend/tests/data/svg/upce_cc_2addon_cca_5x2_rotate_270.svg b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_rotate_270.svg new file mode 100644 index 00000000..de36a106 --- /dev/null +++ b/backend/tests/data/svg/upce_cc_2addon_cca_5x2_rotate_270.svg @@ -0,0 +1,107 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 654321 + + + 7 + + + 89 + + + diff --git a/backend/tests/data/tif/code128_cmyk_fgbg.tif b/backend/tests/data/tif/code128_cmyk_fgbg.tif new file mode 100644 index 0000000000000000000000000000000000000000..09beab60336149106d57de52fd368ecdd3b9b3ef GIT binary patch literal 3718 zcmebD)M8k{%fQgU(WJo8!^O##=A;;4;lszx*V>@Cp`s;BQ>f$cqmL_|NLh<@9(nw+ zBc;k$Y~rychLR%l%=M>gp+0b9PNN+Zg!rTGZdL^Ksik-->zHF58^F#w`nhaPVzlU}FwxMcr>bvtFwNefO|m;QMdPaC`N z;(f0SX5~!F5AMJExIkjhys(4oZlu1iUL)4-yXfA_vRS^<*(KW_W`4KMGrK-{&ZEz} ztl#!4x9@&YwCnb1e&MBeuYdo2voCJ-)*WwC_sY&=3y$3Uy|QxOefilhw?Fw?RVSan z_{)#oz1j2bALv`d%52AX`pSm`?;gK9Yj2QzmTm8Z?pdE~1op7~Jv@O$lx5%f>c0O6 z^Cw>xaNe*)Rq&|58NXMDKeQw=9lWsFR@zxG#8lF4-R|cy_7g?&<()4^?`J5 zgrLbxC6|pgletdu9}$#2dhW}72K)D4dcGc;v}C8YPhm=>#HpY=7hd^n_GvZq@k_a@ zeXb~^+WK5@i?i05OH&rxpZ=76-h8)+POy=`5l_168G|{|rhx&x%x?aZ=E@qMxOi6H z$@9wN?FKHFdM5G&3I5gA4cv6p(?3AysJG4~6JK9zKNHhLze`i5{1);ry{hYcSv0gd zGN5>ApzC?jt?s;+zxEnOhi+cmDeHetRzLpQH{HyP;8NR}8Rx@9oyAUX5nWky-E6L4 z_8sG`2lMY1yq%s974|f?IL>VC)0zmgvn%z(%Ugek-}zR@Tot>0?(D*73)a^yks+e- zt%+Bz{*Fud{`GTf?AN*39pR$iggZlxPBD!p$k7Bjnjl9@$k7sVw1gb3vPY}z(Kh4| zZ$tXroF+QgK5|>@{J5yH-j$irVtcn{M^9V3H|O?t*8RD6%6U%~#){isEsmY8d$;87 z_SXBQ_sV-;R>q6({aPJAeeK_x`#V_w+a^@-es8*y!2xd{HXV3qP!Xae%iH0s6tH87 zow``pkz~V)D@nGp6Wmn-cdA6rlxOgKViXy(C{lU4PwHmNmP_&GGkw#8JGVTmw4NW3 zzQu~AE!1_&g_Xj;QnhBgEWh;fs#R;y($F=buS2D5{_PH1aU(~}>TK8Pl(n~XuFbaH z<{CdMMt8b(?6s@q+hf<8cQ5_)HNQFVLxha#d*0f^_dkZeNmG~ZIN|gz=+8WR@xC)D zMK|}Hi#N?Xb#e2|ziQRKi!VPfmDTLG9Te{n#p3b|OxaF?y z_2|}HkIQ$)>6On>ZH|cXGgqE|_Tk5p3vAPU zmtV;$joO>GhN@k?L)olAHXD=;QYXmB0#?rfWQ#%BAob!<_5&bWijftpCJm@T8p_TCvNfRQFagzo LfCmtR%!JVZ2{&=S literal 0 HcmV?d00001 diff --git a/backend/tests/data/tif/ultra_cmyk.tif b/backend/tests/data/tif/ultra_cmyk.tif new file mode 100644 index 0000000000000000000000000000000000000000..83fef86a286ed87e1b18d299fd141d69905c701c GIT binary patch literal 590 zcmebD)M8k`$iUFRpb%i8!1$lJ`M^Sh3>Py|zBcDaff7sfbOpMPJT{CtQfA6J!6SL% zPnAAj=_&3@KCSeb7OgbH?TNAG6d``|Hm`J{n@h~%xhI`mCT!6vr0z7^FEjAxovLd7 z`3EyUddV~`Hl1}T_3DaVzuECiBeYFtt<78Lx+GlnlhxO@yGcv0YM4cadR@%id`Ca* zw@cjOtOK!nS8Djg-c}!p-Z1@T8sEy4P3PZ;M{W5nU3x4ybNU(8$I3b-Ie>U-dpK3UL_VD=IBwD z3>9Yu^4XBsf{ZL+y&OPsQK&dbj~G-OWR5tLJsoI?6eBBGy&cd@X(-zb$ku@B1v0^a Og8>3PfIN`fU^DEDJQ9++Owgd^!oq@Av3iQU zbC0gvc&gQ@J*+cyaW|x^u^vUOs!eBofTddmh?^XZQIuJ_0jpp zr(`GnwcT>&#b+;`b*E#tURf_uefHhmj-%I%Lf*{1^}FHVvow<$o!OH4N8&$L>8kb1 zPq~u1E^5!5RfUaP(lsMi-uZQN&6PXfqkF@yeP6Kg@n*?=YFt-0?|8pc@b0_kmAkK< z*s_P?-1PWakIQm`V%GZo-2U?0JIViit508;R{CSNob4yiyB8|V|LJX;KYQ8lr_X-# zwy8b(ZFY81!DqX??3m*=eZoF}ck?GrdcQG%`Oim(p6)sKO$xj}Tt3(z{cH7-_mihx zIK=-)T}bVsh}RC|6|aA?9bL&1DssrsdasnrMVWkoV;h+)#rGC&p7-NGVE0Adz2_Fc zcxjP$#a?t(?;WNmCyS&HD|;HPzN+pf_(|@mmp}-^`EBb}PIB+OFvVKW!|0QwfjhtS zYZZgd(k?&jgo8TSPJZrLboEqW%8M(e7cSjZ^~+y#on7aX$Y;esZJkq>?23-4vYs#a zvRmhrPEM)Le%(W_l~0ANxvP7zN98W>#S5~Yfofm5Hfmq_lpA!@N57Qmgx?jFnU2@8 zzI=8zoD$Q>e*XN`VvjWwj#ekE`zEXDqjJqwI`q^Q*Nr;SAy2n;-?|#QxA69M-Oa_f z`-Pbr8h9BP7?~Lu85kIpfS3`=mIAVwfNWME{Rx=bn4#hzJ{uBSkdXzfmjfs+iX<)u x6$hCk4rO})&5>ec1*`u9WJ^QYEX)iH8c@AJVTK?m8{{Ss;DAF9AP*!8qX8$RFTnr+ literal 0 HcmV?d00001 diff --git a/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif b/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif new file mode 100644 index 0000000000000000000000000000000000000000..c2d02c46146dc75469656c2225f2f157aa72738c GIT binary patch literal 506 zcmebD)MEI;z`)R;q!3`CBF4+!;xO4@M~ay&e}_wANAsRAUGW|z#X^rGWx7&6M;Tay zcQBk0G!}JB4d`(5RG8?ga;Y<9Q%v~`SGS_TIqSmG7O{- z-l<<4Sgj_j&klLnUTiWg*M3RBa??{^wjK1E)1Y1&>6;WDH8JYhv`1?XX)#Q?moL6! zZQsxOJ(r$@-db}hy8WPM!K9mha?zdEmzOU#==s)Yz46KNoq_Y>h1J%3tCnSNYjR(- z{%+rQEncSF3D-Qo-uUfn^;&PLratIK305OOOqyPU0iT(!z5DUbH&=3+NfzCpg LN2o#9&A '9') { + symbol->symbology = BARCODE_ULTRA; + } + symbol->bitmap = (unsigned char *) data_buf; ret = bmp_pixel_plot(symbol, (unsigned char *) data_buf); - assert_zero(ret, "i:%d bmp_pixel_plot ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d bmp_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - ret = testUtilVerifyIdentify(symbol->outfile, debug); - assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); - - assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + if (ret < ZINT_ERROR) { + if (have_identify) { + ret = testUtilVerifyIdentify(symbol->outfile, debug); + assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); + } + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + } + } else { + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + (void) remove(symbol->outfile); + } + } symbol->bitmap = NULL; @@ -116,6 +127,8 @@ static void test_print(int index, int generate, int debug) { struct item { int symbology; + int border_width; + int output_options; int whitespace_width; int whitespace_height; int option_1; @@ -126,9 +139,10 @@ static void test_print(int index, int generate, int debug) { char *expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_PDF417, 5, -1, -1, -1, "147AD0", "FC9630", "123", "pdf417_fg_bg.bmp" }, - /* 1*/ { BARCODE_ULTRA, 5, -1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg.bmp" }, - /* 2*/ { BARCODE_PDF417COMP, 2, 2, -1, -1, "", "", "123", "pdf417comp_hvwsp2.bmp" }, + /* 0*/ { BARCODE_PDF417, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", "123", "pdf417_fg_bg.bmp" }, + /* 1*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg.bmp" }, + /* 2*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg_hvwsp1_box1.bmp" }, + /* 3*/ { BARCODE_PDF417COMP, -1, -1, 2, 2, -1, -1, "", "", "123", "pdf417comp_hvwsp2.bmp" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -160,7 +174,10 @@ static void test_print(int index, int generate, int debug) { 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, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } @@ -184,8 +201,9 @@ static void test_print(int index, int generate, int debug) { assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n", - i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].whitespace_height, + printf(" /*%3d*/ { %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), + data[i].whitespace_width, data[i].whitespace_height, data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = testUtilRename(symbol->outfile, expected_file); @@ -209,11 +227,37 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + unsigned char data[] = { "1" }; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.bitmap = data; + symbol.bitmap_width = symbol.bitmap_height = 1; + + strcpy(symbol.outfile, "nosuch_dir/out.bmp"); + + ret = bmp_pixel_plot(&symbol, data); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "bmp_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = bmp_pixel_plot(&symbol, data); + printf(" - ignore (BMP to stdout)\n"); fflush(stdout); + assert_zero(ret, "bmp_pixel_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_pixel_plot", test_pixel_plot, 1, 0, 1 }, { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_channel.c b/backend/tests/test_channel.c index 07776797..3e1bc881 100644 --- a/backend/tests/test_channel.c +++ b/backend/tests/test_channel.c @@ -55,40 +55,45 @@ static void test_input(int index, int debug) { /* 10*/ { 3, "000", 0, 1, 19, }, /* 11*/ { 3, "001", 0, 1, 19, }, /* 12*/ { 3, "026", 0, 1, 19, }, - /* 13*/ { -1, "026", 0, 1, 23, }, // Defaults to channel 4 due to length - /* 14*/ { 3, "0026", 0, 1, 19, }, - /* 15*/ { 3, "1234", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 16*/ { 4, "000", 0, 1, 23 }, - /* 17*/ { -1, "000", 0, 1, 23 }, // Defaults to channel 4 due to length - /* 18*/ { 4, "026", 0, 1, 23 }, - /* 19*/ { 4, "0000026", 0, 1, 23 }, - /* 20*/ { 4, "0000", 0, 1, 23 }, - /* 21*/ { 4, "292", 0, 1, 23 }, - /* 22*/ { 4, "293", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 23*/ { 5, "0000", 0, 1, 27 }, - /* 24*/ { -1, "0000", 0, 1, 27 }, // Defaults to channel 5 due to length - /* 25*/ { -1, "3493", 0, 1, 27 }, - /* 26*/ { 5, "3493", 0, 1, 27 }, - /* 27*/ { 5, "3494", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 28*/ { 6, "00000", 0, 1, 31 }, - /* 29*/ { -1, "00000", 0, 1, 31 }, // Defaults to channel 5 due to length - /* 30*/ { -1, "44072", 0, 1, 31 }, - /* 31*/ { 6, "44072", 0, 1, 31 }, - /* 32*/ { 6, "44073", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 33*/ { -1, "576688", 0, 1, 35 }, - /* 34*/ { 7, "000000", 0, 1, 35 }, - /* 35*/ { -1, "000000", 0, 1, 35 }, // Defaults to channel 7 due to length - /* 36*/ { 7, "576688", 0, 1, 35 }, - /* 37*/ { 7, "576689", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 38*/ { 7, "0576688", 0, 1, 35 }, - /* 39*/ { -1, "1234567", 0, 1, 39 }, - /* 40*/ { 8, "0000000", 0, 1, 39, }, - /* 41*/ { -1, "0000000", 0, 1, 39, }, // Defaults to channel 8 due to length - /* 42*/ { 8, "1234567", 0, 1, 39, }, - /* 43*/ { 8, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 44*/ { 8, "01234567", ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 45*/ { 8, "00000000", ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 46*/ { 9, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 13*/ { -1, "27", 0, 1, 23 }, // Channel 4 + /* 14*/ { -1, "026", 0, 1, 23, }, // Defaults to channel 4 due to length + /* 15*/ { 3, "0026", 0, 1, 19, }, + /* 16*/ { 3, "1234", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 17*/ { 4, "000", 0, 1, 23 }, + /* 18*/ { -1, "000", 0, 1, 23 }, // Defaults to channel 4 due to length + /* 19*/ { 4, "026", 0, 1, 23 }, + /* 20*/ { 4, "0000026", 0, 1, 23 }, + /* 21*/ { 4, "0000", 0, 1, 23 }, + /* 22*/ { 4, "292", 0, 1, 23 }, + /* 23*/ { 4, "293", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 24*/ { -1, "293", 0, 1, 27 }, // Channel 5 + /* 25*/ { 5, "0000", 0, 1, 27 }, + /* 26*/ { -1, "0000", 0, 1, 27 }, // Defaults to channel 5 due to length + /* 27*/ { -1, "3493", 0, 1, 27 }, + /* 28*/ { 5, "3493", 0, 1, 27 }, + /* 29*/ { 5, "3494", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 30*/ { -1, "3494", 0, 1, 31 }, // Channel 6 + /* 31*/ { 6, "00000", 0, 1, 31 }, + /* 32*/ { -1, "00000", 0, 1, 31 }, // Defaults to channel 5 due to length + /* 33*/ { -1, "44072", 0, 1, 31 }, + /* 34*/ { 6, "44072", 0, 1, 31 }, + /* 35*/ { 6, "44073", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 36*/ { -1, "44073", 0, 1, 35 }, // Channel 7 + /* 37*/ { 7, "000000", 0, 1, 35 }, + /* 38*/ { -1, "000000", 0, 1, 35 }, // Defaults to channel 7 due to length + /* 39*/ { 7, "576688", 0, 1, 35 }, + /* 40*/ { 7, "576689", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 41*/ { 7, "0576688", 0, 1, 35 }, + /* 42*/ { -1, "1234567", 0, 1, 39 }, + /* 43*/ { -1, "576689", 0, 1, 39 }, // Channel 8 + /* 44*/ { 8, "0000000", 0, 1, 39, }, + /* 45*/ { -1, "0000000", 0, 1, 39, }, // Defaults to channel 8 due to length + /* 46*/ { 8, "1234567", 0, 1, 39, }, + /* 47*/ { 8, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 48*/ { 8, "01234567", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 49*/ { 8, "00000000", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 50*/ { 9, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 51*/ { -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_code.c b/backend/tests/test_code.c index f5096d70..b48ea02b 100644 --- a/backend/tests/test_code.c +++ b/backend/tests/test_code.c @@ -116,21 +116,21 @@ static void test_hrt(int index, int debug) { // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { /* 0*/ { BARCODE_CODE11, -1, "123-45", -1, "123-4552" }, // 2 checksums - /* 1*/ { BARCODE_CODE11, 1, "123-45", -1, "123-455" }, // 1 checksum + /* 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 checksum 10 (A) goes to hyphen + /* 3*/ { BARCODE_CODE11, -1, "123456789012", -1, "123456789012-8" }, // First check digit 10 (A) goes to hyphen /* 4*/ { BARCODE_CODE39, -1, "ABC1234", -1, "*ABC1234*" }, /* 5*/ { BARCODE_CODE39, -1, "abc1234", -1, "*ABC1234*" }, // Converts to upper /* 6*/ { BARCODE_CODE39, -1, "123456789", -1, "*123456789*" }, - /* 7*/ { BARCODE_CODE39, 1, "123456789", -1, "*1234567892*" }, // With checksum + /* 7*/ { BARCODE_CODE39, 1, "123456789", -1, "*1234567892*" }, // With check digit /* 8*/ { BARCODE_EXCODE39, -1, "ABC1234", -1, "ABC1234" }, /* 9*/ { BARCODE_EXCODE39, -1, "abc1234", -1, "abc1234" }, - /* 10*/ { BARCODE_EXCODE39, 1, "abc1234", -1, "abc1234" }, // With checksum (not displayed) + /* 10*/ { BARCODE_EXCODE39, 1, "abc1234", -1, "abc1234" }, // With check digit (not displayed) /* 11*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% $ z !+/\\@A~" }, // NUL, ctrls and DEL replaced with spaces /* 12*/ { BARCODE_LOGMARS, -1, "ABC1234", -1, "ABC1234" }, /* 13*/ { BARCODE_LOGMARS, -1, "abc1234", -1, "ABC1234" }, // Converts to upper - /* 14*/ { BARCODE_LOGMARS, 1, "abc1234", -1, "ABC12340" }, // With checksum - /* 15*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, "12345/ABCDET" }, // With checksum + /* 14*/ { BARCODE_LOGMARS, 1, "abc1234", -1, "ABC12340" }, // With check digit + /* 15*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, "12345/ABCDET" }, // With check digit /* 16*/ { BARCODE_CODE93, -1, "ABC1234", -1, "ABC1234S5" }, // 2 checksums added (note check digits not shown by bwipp or tec-it) /* 17*/ { BARCODE_CODE93, -1, "abc1234", -1, "abc1234ZG" }, /* 18*/ { BARCODE_CODE93, -1, "A\001a\000b\177d\037e", 9, "A a b d e1R" }, // NUL, ctrls and DEL replaced with spaces @@ -184,33 +184,37 @@ static void test_input(int index, int debug) { struct item data[] = { /* 0*/ { BARCODE_CODE11, -1, "-", -1, 0, 1, 37 }, /* 1*/ { BARCODE_CODE11, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 2*/ { BARCODE_CODE39, -1, "a", -1, 0, 1, 38 }, // Converts to upper - /* 3*/ { BARCODE_CODE39, -1, ",", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 4*/ { BARCODE_CODE39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 5*/ { BARCODE_EXCODE39, -1, "A", -1, 0, 1, 38 }, - /* 6*/ { BARCODE_EXCODE39, -1, "a", -1, 0, 1, 51 }, - /* 7*/ { BARCODE_EXCODE39, -1, ",", -1, 0, 1, 51 }, - /* 8*/ { BARCODE_EXCODE39, -1, "\000", 1, 0, 1, 51 }, - /* 9*/ { BARCODE_EXCODE39, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, }, - /* 10*/ { BARCODE_LOGMARS, -1, "A", -1, 0, 1, 47 }, - /* 11*/ { BARCODE_LOGMARS, -1, "a", -1, 0, 1, 47 }, - /* 12*/ { BARCODE_LOGMARS, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, }, - /* 13*/ { BARCODE_LOGMARS, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, }, - /* 14*/ { BARCODE_CODE93, -1, "A", -1, 0, 1, 46 }, - /* 15*/ { BARCODE_CODE93, -1, "a", -1, 0, 1, 55 }, - /* 16*/ { BARCODE_CODE93, -1, ",", -1, 0, 1, 55 }, - /* 17*/ { BARCODE_CODE93, -1, "\000", 1, 0, 1, 55 }, - /* 18*/ { BARCODE_CODE93, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 19*/ { BARCODE_PZN, -1, "1", -1, 0, 1, 142 }, - /* 20*/ { BARCODE_PZN, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 21*/ { BARCODE_PZN, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // Check digit == 10 so can't be used - /* 22*/ { BARCODE_VIN, -1, "5GZCZ43D13S812715", -1, 0, 1, 246 }, - /* 23*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 }, // North American with invalid check character - /* 24*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246 }, // Not North American so no check - /* 25*/ { BARCODE_VIN, -1, "WPOZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // O not allowed - /* 26*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, // Converts to upper - /* 27*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 28*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 2*/ { BARCODE_CODE11, 3, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1 }, + /* 3*/ { BARCODE_CODE39, -1, "a", -1, 0, 1, 38 }, // Converts to upper + /* 4*/ { BARCODE_CODE39, -1, ",", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 5*/ { BARCODE_CODE39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 6*/ { BARCODE_CODE39, 0, "1", -1, 0, 1, 38 }, + /* 7*/ { BARCODE_CODE39, 1, "1", -1, 0, 1, 51 }, // Check digit + /* 8*/ { BARCODE_CODE39, 2, "1", -1, 0, 1, 38 }, // option_2 > 1 gnored + /* 9*/ { BARCODE_EXCODE39, -1, "A", -1, 0, 1, 38 }, + /* 10*/ { BARCODE_EXCODE39, -1, "a", -1, 0, 1, 51 }, + /* 11*/ { BARCODE_EXCODE39, -1, ",", -1, 0, 1, 51 }, + /* 12*/ { BARCODE_EXCODE39, -1, "\000", 1, 0, 1, 51 }, + /* 13*/ { BARCODE_EXCODE39, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, }, + /* 14*/ { BARCODE_LOGMARS, -1, "A", -1, 0, 1, 47 }, + /* 15*/ { BARCODE_LOGMARS, -1, "a", -1, 0, 1, 47 }, + /* 16*/ { BARCODE_LOGMARS, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, }, + /* 17*/ { BARCODE_LOGMARS, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, }, + /* 18*/ { BARCODE_CODE93, -1, "A", -1, 0, 1, 46 }, + /* 19*/ { BARCODE_CODE93, -1, "a", -1, 0, 1, 55 }, + /* 20*/ { BARCODE_CODE93, -1, ",", -1, 0, 1, 55 }, + /* 21*/ { BARCODE_CODE93, -1, "\000", 1, 0, 1, 55 }, + /* 22*/ { BARCODE_CODE93, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 23*/ { BARCODE_PZN, -1, "1", -1, 0, 1, 142 }, + /* 24*/ { BARCODE_PZN, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 25*/ { BARCODE_PZN, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // Check digit == 10 so can't be used + /* 26*/ { BARCODE_VIN, -1, "5GZCZ43D13S812715", -1, 0, 1, 246 }, + /* 27*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 }, // North American with invalid check character + /* 28*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246 }, // Not North American so no check + /* 29*/ { BARCODE_VIN, -1, "WPOZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // O not allowed + /* 30*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, // Converts to upper + /* 31*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 32*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -259,79 +263,106 @@ static void test_encode(int index, int generate, int debug) { /* 0*/ { BARCODE_CODE11, -1, "123-45", -1, 0, 1, 78, "2 check digits (52); verified manually against tec-it", "101100101101011010010110110010101011010101101101101101011011010100101101011001" }, - /* 1*/ { BARCODE_CODE11, 1, "123-455", -1, 0, 1, 78, "1 check digit (2); verified manually against tec-it", + /* 1*/ { BARCODE_CODE11, -1, "93", -1, 0, 1, 44, "2 check digits (--); verified manually against tec-it", + "10110010110101011001010101101010110101011001" + }, + /* 2*/ { BARCODE_CODE11, 1, "123-455", -1, 0, 1, 78, "1 check digit (2); verified manually against tec-it", "101100101101011010010110110010101011010101101101101101011011010100101101011001" }, - /* 2*/ { BARCODE_CODE11, 2, "123-4552", -1, 0, 1, 78, "0 check digits; verified manually against tec-it", + /* 3*/ { BARCODE_CODE11, 2, "123-4552", -1, 0, 1, 78, "0 check digits; verified manually against tec-it", "101100101101011010010110110010101011010101101101101101011011010100101101011001" }, - /* 3*/ { BARCODE_CODE11, 1, "123-45", -1, 0, 1, 70, "1 check digit; verified manually against tec-it", + /* 4*/ { BARCODE_CODE11, 1, "123-45", -1, 0, 1, 70, "1 check digit; verified manually against tec-it", "1011001011010110100101101100101010110101011011011011010110110101011001" }, - /* 4*/ { BARCODE_CODE11, 2, "123-45", -1, 0, 1, 62, "0 check digits; verified manually against tec-it", + /* 5*/ { BARCODE_CODE11, 2, "123-45", -1, 0, 1, 62, "0 check digits; verified manually against tec-it", "10110010110101101001011011001010101101010110110110110101011001" }, - /* 5*/ { BARCODE_CODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1", + /* 6*/ { BARCODE_CODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1", "100101101101011010010101101101010010110100101101101" }, - /* 6*/ { BARCODE_CODE39, 1, "1A", -1, 0, 1, 64, "With checksum", + /* 7*/ { BARCODE_CODE39, 1, "1A", -1, 0, 1, 64, "With check digit (B)", "1001011011010110100101011011010100101101011010010110100101101101" }, - /* 7*/ { BARCODE_CODE39, -1, "+A/E%U$A/D%T+Z", -1, 0, 1, 207, "Same as BARCODE_EXCODE39 'a%\000\001$\177z' below", + /* 8*/ { BARCODE_CODE39, 1, "Z1", -1, 0, 1, 64, "Check digit '-'", + "1001011011010100110110101011010010101101001010110110100101101101" + }, + /* 9*/ { BARCODE_CODE39, 1, "Z2", -1, 0, 1, 64, "Check digit '.'", + "1001011011010100110110101010110010101101100101011010100101101101" + }, + /* 10*/ { BARCODE_CODE39, 1, "Z3", -1, 0, 1, 64, "Check digit space, displayed as underscore", + "1001011011010100110110101011011001010101001101011010100101101101" + }, + /* 11*/ { BARCODE_CODE39, 1, "Z4", -1, 0, 1, 64, "Check digit '$'", + "1001011011010100110110101010100110101101001001001010100101101101" + }, + /* 12*/ { BARCODE_CODE39, 1, "Z5", -1, 0, 1, 64, "Check digit '/'", + "1001011011010100110110101011010011010101001001010010100101101101" + }, + /* 13*/ { BARCODE_CODE39, 1, "Z6", -1, 0, 1, 64, "Check digit '+'", + "1001011011010100110110101010110011010101001010010010100101101101" + }, + /* 14*/ { BARCODE_CODE39, 1, "Z7", -1, 0, 1, 64, "Check digit '%'", + "1001011011010100110110101010100101101101010010010010100101101101" + }, + /* 15*/ { BARCODE_CODE39, -1, "+A/E%U$A/D%T+Z", -1, 0, 1, 207, "Same as BARCODE_EXCODE39 'a%\000\001$\177z' below", "100101101101010010100100101101010010110100100101001011010110010101010010010010110010101011010010010010101101010010110100100101001010101100101101010010010010101011011001010010100100101001101101010100101101101" }, - /* 8*/ { BARCODE_EXCODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1", + /* 16*/ { BARCODE_EXCODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1", "100101101101011010010101101101010010110100101101101" }, - /* 9*/ { BARCODE_EXCODE39, 1, "1A", -1, 0, 1, 64, "With checksum", + /* 17*/ { BARCODE_EXCODE39, 1, "1A", -1, 0, 1, 64, "With check digit", "1001011011010110100101011011010100101101011010010110100101101101" }, - /* 10*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z", 7, 0, 1, 207, "Verified manually against tec-it", + /* 18*/ { BARCODE_EXCODE39, 1, "Z4", -1, 0, 1, 64, "Check digit $", + "1001011011010100110110101010100110101101001001001010100101101101" + }, + /* 19*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z", 7, 0, 1, 207, "Verified manually against tec-it", "100101101101010010100100101101010010110100100101001011010110010101010010010010110010101011010010010010101101010010110100100101001010101100101101010010010010101011011001010010100100101001101101010100101101101" }, - /* 11*/ { BARCODE_EXCODE39, -1, "\033\037!+/\\@A~", -1, 0, 1, 246, "Verified manually against tec-it", + /* 20*/ { BARCODE_EXCODE39, -1, "\033\037!+/\\@A~", -1, 0, 1, 246, "Verified manually against tec-it", "100101101101010100100100101101010010110101001001001011010110010101001001010010110101001011010010010100101101010100110100100101001011010110100101010010010010101101010011010100100100101001101010110110101001011010100100100101011010110010100101101101" }, - /* 12*/ { BARCODE_LOGMARS, -1, "1A", -1, 0, 1, 63, "Verified manually against tec-it", + /* 21*/ { BARCODE_LOGMARS, -1, "1A", -1, 0, 1, 63, "Verified manually against tec-it", "100010111011101011101000101011101110101000101110100010111011101" }, - /* 13*/ { BARCODE_LOGMARS, 1, "1A", -1, 0, 1, 79, "With checksum; verified manually against tec-it", + /* 22*/ { BARCODE_LOGMARS, 1, "1A", -1, 0, 1, 79, "With check digit; verified manually against tec-it", "1000101110111010111010001010111011101010001011101011101000101110100010111011101" }, - /* 14*/ { BARCODE_LOGMARS, -1, "ABC", -1, 0, 1, 79, "MIL-STD-1189 Rev. B Figure 1", + /* 23*/ { BARCODE_LOGMARS, -1, "ABC", -1, 0, 1, 79, "MIL-STD-1189 Rev. B Figure 1", "1000101110111010111010100010111010111010001011101110111010001010100010111011101" }, - /* 15*/ { BARCODE_LOGMARS, -1, "SAMPLE 1", -1, 0, 1, 159, "MIL-STD-1189 Rev. B Figure 2 top", + /* 24*/ { BARCODE_LOGMARS, -1, "SAMPLE 1", -1, 0, 1, 159, "MIL-STD-1189 Rev. B Figure 2 top", "100010111011101010111010111000101110101000101110111011101010001010111011101000101011101010001110111010111000101010001110101110101110100010101110100010111011101" }, - /* 16*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, 0, 1, 223, "MIL-STD-1189 Rev. B Section 6.2.1 check character example; verified manually against tec-it", + /* 25*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, 0, 1, 223, "MIL-STD-1189 Rev. B Section 6.2.1 check character example; verified manually against tec-it", "1000101110111010111010001010111010111000101011101110111000101010101000111010111011101000111010101000100010100010111010100010111010111010001011101110111010001010101011100010111011101011100010101010111011100010100010111011101" }, - /* 17*/ { BARCODE_CODE93, -1, "1A", -1, 0, 1, 55, "Verified manually against tec-it", + /* 26*/ { BARCODE_CODE93, -1, "1A", -1, 0, 1, 55, "Verified manually against tec-it", "1010111101010010001101010001101000101001110101010111101" }, - /* 18*/ { BARCODE_CODE93, -1, "TEST93", -1, 0, 1, 91, "Verified manually against tec-it", + /* 27*/ { BARCODE_CODE93, -1, "TEST93", -1, 0, 1, 91, "Verified manually against tec-it", "1010111101101001101100100101101011001101001101000010101010000101011101101001000101010111101" }, - /* 19*/ { BARCODE_CODE93, -1, "\000a\177", 3, 0, 1, 91, "Verified manually against tec-it", + /* 28*/ { BARCODE_CODE93, -1, "\000a\177", 3, 0, 1, 91, "Verified manually against tec-it", "1010111101110110101100101101001100101101010001110110101101001101011011101010010001010111101" }, - /* 20*/ { BARCODE_PZN, -1, "1234567", -1, 0, 1, 142, "Example from IFA Info Code 39 EN V2.1; verified manually against tec-it", + /* 29*/ { BARCODE_PZN, -1, "1234567", -1, 0, 1, 142, "Example from IFA Info Code 39 EN V2.1; verified manually against tec-it", "1001011011010100101011011011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010100101101101" }, - /* 21*/ { BARCODE_PZN, -1, "2758089", -1, 0, 1, 142, "Example from IFA Info Check Digit Calculations EN 15 July 2019; verified manually against tec-it", + /* 30*/ { BARCODE_PZN, -1, "2758089", -1, 0, 1, 142, "Example from IFA Info Check Digit Calculations EN 15 July 2019; verified manually against tec-it", "1001011011010100101011011010110010101101010010110110110100110101011010010110101010011011010110100101101010110010110101011001011010100101101101" }, - /* 22*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, 0, 1, 246, "https://www.vinquery.com/img/vinbarcode/vinbarcode4.jpg", + /* 31*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, 0, 1, 246, "https://www.vinquery.com/img/vinbarcode/vinbarcode4.jpg", "100101101101011010010101101011011001010101011011001011011010010101101010110010110100101011010100110110101100101010110100101101011010101101100101011011010010110101001011010100101101101101001011010110100101011011010010110101010011011010100101101101" }, - /* 23*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, 0, 1, 259, "With Import 'I' prefix; https://www.vinquery.com/img/vinbarcode/vinbarcode1.jpg", + /* 32*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, 0, 1, 259, "With Import 'I' prefix; https://www.vinquery.com/img/vinbarcode/vinbarcode1.jpg", "1001011011010101101001101010110010101101011011001010101011011001010110110100101001011010110101100101011011010010110101011010100110101001101101010010110101101101101001010110101001011011010010101101101001101010110100110101011010010101101101001010110100101101101" }, - /* 24*/ { BARCODE_HIBC_39, -1, "A123BJC5D6E71", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 2, same", + /* 33*/ { BARCODE_HIBC_39, -1, "A123BJC5D6E71", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 2, same", "1000101110111010100010100010001011101010001011101110100010101110101110001010111011101110001010101011101000101110101011100011101011101110100010101110100011101010101011100010111010111000111010101110101110001010101000101110111011101000101011101010100011101110100010111011101" }, - /* 25*/ { BARCODE_HIBC_39, -1, "$$52001510X3G", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 6, same", + /* 34*/ { BARCODE_HIBC_39, -1, "$$52001510X3G", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 6, same", "1000101110111010100010100010001010001000100010101000100010001010111010001110101010111000101011101010001110111010101000111011101011101000101011101110100011101010111010001010111010100011101110101000101110101110111011100010101010101000111011101010111000101110100010111011101" }, }; diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index a3cc6301..b2d6aaca 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -47,22 +47,24 @@ static void test_large(int index, int debug) { struct item data[] = { /* 0*/ { BARCODE_CODE128, "A", 60, 0, 695 }, /* 1*/ { BARCODE_CODE128, "A", 61, ZINT_ERROR_TOO_LONG, -1 }, - /* 2*/ { BARCODE_CODE128, "\351A", 40, 0, 695 }, - /* 3*/ { BARCODE_CODE128, "\351A", 41, ZINT_ERROR_TOO_LONG, -1 }, // 41 chars (+ 20 shifts) - /* 4*/ { BARCODE_CODE128, "0", 120, 0, 695 }, - /* 5*/ { BARCODE_CODE128, "0", 121, ZINT_ERROR_TOO_LONG, -1 }, - /* 6*/ { BARCODE_CODE128B, "A", 60, 0, 695 }, - /* 7*/ { BARCODE_CODE128B, "A", 61, ZINT_ERROR_TOO_LONG, -1 }, - /* 8*/ { BARCODE_CODE128B, "0", 60, 0, 695 }, - /* 9*/ { BARCODE_CODE128B, "0", 61, ZINT_ERROR_TOO_LONG, -1 }, - /* 10*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890", -1, 0, 706 }, // 116 nos + 3 FNC1s - /* 11*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234[93]1234", -1, ZINT_ERROR_TOO_LONG, -1 }, // 116 nos + 4 FNC1s - /* 12*/ { BARCODE_EAN14, "1234567890123", -1, 0, 134 }, - /* 13*/ { BARCODE_EAN14, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1 }, - /* 14*/ { BARCODE_NVE18, "12345678901234567", -1, 0, 156 }, - /* 15*/ { BARCODE_NVE18, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1 }, - /* 16*/ { BARCODE_HIBC_128, "1", 110, 0, 684 }, - /* 17*/ { BARCODE_HIBC_128, "1", 111, ZINT_ERROR_TOO_LONG, -1 }, + /* 2*/ { BARCODE_CODE128, "A", 161, ZINT_ERROR_TOO_LONG, -1 }, + /* 3*/ { BARCODE_CODE128, "\351A", 40, 0, 695 }, + /* 4*/ { BARCODE_CODE128, "\351A", 41, ZINT_ERROR_TOO_LONG, -1 }, // 41 chars (+ 20 shifts) + /* 5*/ { BARCODE_CODE128, "0", 120, 0, 695 }, + /* 6*/ { BARCODE_CODE128, "0", 121, ZINT_ERROR_TOO_LONG, -1 }, + /* 7*/ { BARCODE_CODE128B, "A", 60, 0, 695 }, + /* 8*/ { BARCODE_CODE128B, "A", 61, ZINT_ERROR_TOO_LONG, -1 }, + /* 9*/ { BARCODE_CODE128B, "0", 60, 0, 695 }, + /* 10*/ { BARCODE_CODE128B, "0", 61, ZINT_ERROR_TOO_LONG, -1 }, + /* 11*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890", -1, 0, 706 }, // 116 nos + 3 FNC1s + /* 12*/ { BARCODE_GS1_128, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234[93]1234", -1, ZINT_ERROR_TOO_LONG, -1 }, // 116 nos + 4 FNC1s + /* 13*/ { BARCODE_GS1_128, "A", 161, ZINT_ERROR_TOO_LONG, -1 }, + /* 14*/ { BARCODE_EAN14, "1234567890123", -1, 0, 134 }, + /* 15*/ { BARCODE_EAN14, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1 }, + /* 16*/ { BARCODE_NVE18, "12345678901234567", -1, 0, 156 }, + /* 17*/ { BARCODE_NVE18, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1 }, + /* 18*/ { BARCODE_HIBC_128, "1", 110, 0, 684 }, + /* 19*/ { BARCODE_HIBC_128, "1", 111, ZINT_ERROR_TOO_LONG, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -113,6 +115,7 @@ static void test_hrt_cpy_iso8859_1(int index, int debug) { char *comment; }; // NBSP U+00A0 (\240, 160), UTF-8 C2A0 (\302\240) + // ¡ U+00A1 (\241, 161), UTF-8 C2A1 (\302\241) // é U+00E9 (\351, 233), UTF-8 C3A9 // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { @@ -123,13 +126,21 @@ static void test_hrt_cpy_iso8859_1(int index, int debug) { /* 4*/ { "\241\242\243\244\257\260", -1, 12, "¡¢£¤¯°", "" }, /* 5*/ { "\276\277\300\337\377", -1, 10, "¾¿Àßÿ", "" }, /* 6*/ { "\351", -1, 2, "é", "" }, - /* 7*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\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, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "126 \351" }, - /* 8*/ { "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", -1, 127, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 126 \351" }, - /* 9*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\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, 127, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "126 \351 + a" }, - /* 10*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\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, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "127 \351 (truncated)" }, - /* 11*/ { "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", -1, 127, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 127 \351 (truncated)" }, - /* 12*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\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, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "127 \351 + a (truncated)" }, - /* 13*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\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, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 (truncated)" }, + /* 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", -1, 126, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "63 \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", -1, 127, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 63 \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\241a", -1, 127, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", "63 \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", -1, 126, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "64 \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", -1, 127, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 64 \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\241a", -1, 126, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "64 \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", -1, 126, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "65 \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", -1, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "63 \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", -1, 127, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 63 \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\351a", -1, 127, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "63 \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", -1, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "64 \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", -1, 127, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 64 \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\351a", -1, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "64 \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", -1, 126, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "65 \351 (truncated)" }, + /* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 127, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "128 A (truncated)" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -148,8 +159,10 @@ static void test_hrt_cpy_iso8859_1(int index, int debug) { length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; ret = hrt_cpy_iso8859_1(&symbol, (unsigned char *) data[i].data, length); - for (j = 0; j < ret; j++) { - //fprintf(stderr, "symbol.text[%d] %2X\n", j, symbol.text[j]); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { + for (j = 0; j < ret; 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_equal(ret, (int) ustrlen(symbol.text), "i:%d ret %d != strlen %d\n", i, ret, (int) ustrlen(symbol.text)); @@ -328,6 +341,7 @@ static void test_input(int index, int generate, int debug) { /* 31*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2)" }, /* 32*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" }, /* 33*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, + /* 34*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 222, "(20) 103 101 101 64 64 64 64 64 101 101 33 99 0 0 101 33 101 64 73 106", "StartA Latch PAD (4) Unlatch A CodeC 00 00 CodeA A FNC4 PAD" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -499,6 +513,58 @@ static void test_hibc_input(int index, int generate, int debug) { testFinish(); } +static void test_ean14_input(int index, int generate, int debug) { + + struct item { + char *data; + int ret; + int expected_width; + char *expected; + char *comment; + }; + struct item data[] = { + /* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 347: Input too long (13 character maximum)", "" }, + /* 1*/ { "A", ZINT_ERROR_INVALID_DATA, -1, "Error 348: Invalid character in data (digits only)", "" }, + }; + int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol; + + char escaped[1024]; + + testStart("test_ean14_input"); + + for (i = 0; i < data_size; i++) { + + if (index != -1 && i != index) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt + + length = testUtilSetSymbol(symbol, BARCODE_EAN14, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + + if (generate) { + printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n", + i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); + } else { + if (ret < ZINT_ERROR) { + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + } + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + } + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + static void test_dpd_input(int index, int generate, int debug) { struct item { @@ -584,118 +650,124 @@ static void test_encode(int index, int generate, int debug) { /* 3*/ { BARCODE_CODE128B, UNICODE_MODE, "1234567890", 0, 1, 145, 1, "", "1101001000010011100110110011100101100101110011001001110110111001001100111010011101101110111010011001110010110010011101100101000110001100011101011" }, - /* 4*/ { BARCODE_GS1_128, GS1_MODE, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1", + /* 4*/ { BARCODE_CODE128, DATA_MODE, "\101\102\103\104\105\106\200\200\200\200\200", 0, 1, 178, 1, "", + "1101000010010100011000100010110001000100011010110001000100011010001000110001011101011110111010111101010000110010100001100101000011001010000110010100001100110110110001100011101011" + }, + /* 5*/ { BARCODE_GS1_128, GS1_MODE, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1", "11010011100111101011101010011110011001110010101111010001100110110011001000100101110011001101100011011101101110101110110001000010110010010111100101111001001100011101011" }, - /* 5*/ { BARCODE_GS1_128, GS1_MODE, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top", + /* 6*/ { BARCODE_GS1_128, GS1_MODE, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top", "110100111001111010111011000100010111010001101100010001011101101110101110110001000010110011011011110100011001001101000100011000100100100110100001100110110011100101100100001001101100011101011" }, - /* 6*/ { BARCODE_GS1_128, GS1_MODE, "[12]010425[8020]ABC123", 0, 1, 189, 1, "GGS Figure 2.6.6-1 bottom", + /* 7*/ { BARCODE_GS1_128, GS1_MODE, "[12]010425[8020]ABC123", 0, 1, 189, 1, "GGS Figure 2.6.6-1 bottom", "110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101100111001011001011100110010111001100011101011" }, - /* 7*/ { BARCODE_GS1_128, GS1_MODE, "[253]950110153005812345678901", 0, 1, 211, 1, "GGS Figure 2.6.9-1", + /* 8*/ { BARCODE_GS1_128, GS1_MODE, "[253]950110153005812345678901", 0, 1, 211, 1, "GGS Figure 2.6.9-1", "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001110110001010110011100100010110001110001011011000010100110111101101011110111010011100110101110110001100011101011" }, - /* 8*/ { BARCODE_GS1_128, GS1_MODE, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2", + /* 9*/ { BARCODE_GS1_128, GS1_MODE, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2", "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001001011000010000101100110110111101000100110010110001110110111001001100100100011110010100101110011001100011101011" }, - /* 9*/ { BARCODE_GS1_128, GS1_MODE, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3", + /* 10*/ { BARCODE_GS1_128, GS1_MODE, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3", "110100111001111010111011100101100110100010001100010111011000100100110011011001101110111011011001100100101100001100101000011101011000110001101101011110111010011100110111001001101100011101011" }, - /* 10*/ { BARCODE_GS1_128, GS1_MODE, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4", + /* 11*/ { BARCODE_GS1_128, GS1_MODE, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4", "11010011100111101011101110010110011010001000110001011101100010010011001101100110111011101101100110010010110000101100111001000101100011100010110100011110101100011101011" }, - /* 11*/ { BARCODE_GS1_128, GS1_MODE, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1", + /* 12*/ { BARCODE_GS1_128, GS1_MODE, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1", "1101001110011110101110110011011001100100010010011110010110010100001000011001011011001100110010011101001110011011001000100110001001001101110001010111101110101100011101011101100010001011000100111001101100011101011" }, - /* 12*/ { BARCODE_GS1_128, GS1_MODE, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3", + /* 13*/ { BARCODE_GS1_128, GS1_MODE, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3", "11010011100111101011101100110110011001001000110001011101100010010011001101100110111011101101100110010010011000100110100001100011101011" }, - /* 13*/ { BARCODE_GS1_128, GS1_MODE, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1", + /* 14*/ { BARCODE_GS1_128, GS1_MODE, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1", "110100111001111010111011011001100110100010001101110100011101101110101110110001011001110010001011000111000101101100001010010111101000101111000101100011101011" }, - /* 14*/ { BARCODE_GS1_128, GS1_MODE, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)", + /* 15*/ { BARCODE_GS1_128, GS1_MODE, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)", "110100111001111010111011011001100110110011001100100001011000100010110001000101011001110010001011000111000101101100001010011011110110110110110001100011101011" }, - /* 15*/ { BARCODE_GS1_128, GS1_MODE, "[403]402621[401]950110153B01001", 0, 1, 266, 0, "GGS Figure 6.6.5-2 top **NOT SAME**, different encodation for zint, BWIPP & standard, same codeword count", + /* 16*/ { BARCODE_GS1_128, GS1_MODE, "[403]402621[401]950110153B01001", 0, 1, 266, 0, "GGS Figure 6.6.5-2 top **NOT SAME**, different encodation for zint, BWIPP & standard, same codeword count", "11010011100111101011101100010100010001011000110011001101111000101010111101110100111001101011101111011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100101001111001100011101011" }, - /* 16*/ { BARCODE_GS1_128, GS1_MODE, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom", + /* 17*/ { BARCODE_GS1_128, GS1_MODE, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom", "110100111001111010111011011001100110100010001100010111011000100100110011011001101110111011011001100110110011001101100110011000100100100011101101100011101011" }, - /* 17*/ { BARCODE_GS1_128, GS1_MODE, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top", + /* 18*/ { BARCODE_GS1_128, GS1_MODE, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top", "110100111001111010111010110111000100100011001110101100011101100010111100100101100011101011" }, - /* 18*/ { BARCODE_GS1_128, GS1_MODE, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top", + /* 19*/ { BARCODE_GS1_128, GS1_MODE, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top", "110100111001111010111011001100110110110011001100100001011000100010110001000101101100110010010001100110011100101011100110011011100100110011001101110011010011001000100101110110001011001110010011001110111101011101000110100011001001110100011110101100011101011" }, - /* 19*/ { BARCODE_GS1_128, GS1_MODE, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top", + /* 20*/ { BARCODE_GS1_128, GS1_MODE, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top", "110100111001111010111010110111000100011001001001101000011001001000111001001101100011101011" }, - /* 20*/ { BARCODE_GS1_128, GS1_MODE, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle", + /* 21*/ { BARCODE_GS1_128, GS1_MODE, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle", "1101001110011110101110110111101101011100110011100110100111001100101100011101011" }, - /* 21*/ { BARCODE_GS1_128, GS1_MODE, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom", + /* 22*/ { BARCODE_GS1_128, GS1_MODE, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom", "110100111001111010111011011001100110110011001000100110011011100100111101110101101110100010001100010101111010001001101000010011000010110011011001100011101011" }, - /* 22*/ { BARCODE_GS1_128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", - "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" - }, /* 23*/ { BARCODE_GS1_128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" }, - /* 24*/ { BARCODE_GS1_128, GS1_MODE, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top", + /* 24*/ { BARCODE_GS1_128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", + "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" + }, + /* 25*/ { BARCODE_GS1_128, GS1_MODE, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top", "11010011100111101011101100010100011001011100110110001101110110111010111011000110011100101011000111010111101110100111011001101000100011000101110100110111001100011101011" }, - /* 25*/ { BARCODE_GS1_128, GS1_MODE, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom", + /* 26*/ { BARCODE_GS1_128, GS1_MODE, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom", "110100111001111010111011011001100110010010001101100011011101101110101110110001101100110011011001100110110011001101100110010110011100110111010001100011101011" }, - /* 26*/ { BARCODE_GS1_128, GS1_MODE, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st", + /* 27*/ { BARCODE_GS1_128, GS1_MODE, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st", "11010011100111101011101100110110010111101000110011011001110110111010111011000100001011001101101111010010011000110110001101100011101011" }, - /* 27*/ { BARCODE_GS1_128, GS1_MODE, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd", + /* 28*/ { BARCODE_GS1_128, GS1_MODE, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd", "11010011100111101011101101100011011001100110110110011001001000110011011001100110110111101100011101011" }, - /* 28*/ { BARCODE_GS1_128, GS1_MODE, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2", + /* 29*/ { BARCODE_GS1_128, GS1_MODE, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2", "110100111001111010111011001101100101111010001100110110011101101110101110110001000010110011011011110100100110001101100011011001100110110110011001001000110011011001100100100110001100011101011" }, - /* 29*/ { BARCODE_GS1_128, GS1_MODE, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st", + /* 30*/ { BARCODE_GS1_128, GS1_MODE, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st", "11010011100111101011101010011110010001001100110110011001001001100010010110000100100001101100011101011" }, - /* 30*/ { BARCODE_GS1_128, GS1_MODE, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd", + /* 31*/ { BARCODE_GS1_128, GS1_MODE, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd", "110100111001111010111011001000100101100111001000101100011100010110110010000101100011101011" }, - /* 31*/ { BARCODE_GS1_128, GS1_MODE, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2", + /* 32*/ { BARCODE_GS1_128, GS1_MODE, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2", "110100111001111010111010100111100100010011001101100110010010011000100101100001111010111011001000100101100111001000101100011100010110101100001001100011101011" }, - /* 32*/ { BARCODE_GS1_128, GS1_MODE, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", + /* 33*/ { BARCODE_GS1_128, GS1_MODE, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", "110100111001111010111011000101000110001101101100101000011011101110110001001001011110111011001011100110001001001011101111010111011110110110011001100100100011011001100110010010001101100110011001000100110001000101100011101011" }, - /* 33*/ { BARCODE_GS1_128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", + /* 34*/ { BARCODE_GS1_128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", "110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011" }, - /* 34*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, 1, "Verified manually against tec-it", + /* 35*/ { BARCODE_GS1_128, GS1_MODE, "[90]ABCDEfGHI", 0, 1, 167, 0, "Shift A; BWIPP different encodation, same codeword count", + "11010010000111101011101110010110010011101100101000110001000101100010001000110101100010001000110100010110000100110100010001100010100011000100010110010011101100011101011" + }, + /* 36*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, 1, "Verified manually against tec-it", "11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011" }, - /* 35*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, 1, "Verified manually against tec-it", + /* 37*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, 1, "Verified manually against tec-it", "110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011" }, - /* 36*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, 1, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)", + /* 38*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, 1, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)", "1101001000011000100100111010011001011101111011000110110110000101001011110111010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100111101010001100011101011" }, - /* 37*/ { BARCODE_HIBC_128, UNICODE_MODE, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same", + /* 39*/ { BARCODE_HIBC_128, UNICODE_MODE, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same", "11010010000110001001001010001100010011100110110011100101100101110010001011000101101110001000100011011011100100101100010001100111010010001101000111011011101001110011011010001000110001101101100011101011" }, - /* 38*/ { BARCODE_HIBC_128, UNICODE_MODE, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same", + /* 40*/ { BARCODE_HIBC_128, UNICODE_MODE, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same", "1101001000011000100100100100011001001000110010111011110110111000101101100110010111001100110010001001011110111011100010110110010111001101000100010110001000100011110101100011101011" }, - /* 39*/ { BARCODE_DPD, UNICODE_MODE, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only", + /* 41*/ { BARCODE_DPD, UNICODE_MODE, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only", "1101001000010001001100100111011001011101111011011001100110100010001100011011010011001000110111001001011101111010110011100100010110001110001011011000010100110010001001100100010011000101000101011110001100011101011" }, - /* 40*/ { BARCODE_DPD, UNICODE_MODE, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against tec-it", + /* 42*/ { BARCODE_DPD, UNICODE_MODE, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against tec-it", "1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100110000101001110010110011000110110100010111101011110010011000010010110010001001011001110011001010000100010111101100011101011" }, - /* 41*/ { BARCODE_DPD, UNICODE_MODE, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)", + /* 43*/ { BARCODE_DPD, UNICODE_MODE, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)", "110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011" }, }; @@ -770,6 +842,7 @@ int main(int argc, char *argv[]) { { "test_input", test_input, 1, 1, 1 }, { "test_ean128_input", test_ean128_input, 1, 1, 1 }, { "test_hibc_input", test_hibc_input, 1, 1, 1 }, + { "test_ean14_input", test_ean14_input, 1, 1, 1 }, { "test_dpd_input", test_dpd_input, 1, 1, 1 }, { "test_encode", test_encode, 1, 1, 1 }, }; diff --git a/backend/tests/test_code16k.c b/backend/tests/test_code16k.c index 151836d2..a2f53bb4 100644 --- a/backend/tests/test_code16k.c +++ b/backend/tests/test_code16k.c @@ -46,6 +46,7 @@ static void test_large(int index, int debug) { /* 1*/ { "A", 78, ZINT_ERROR_TOO_LONG, -1, -1 }, /* 2*/ { "0", 154, 0, 16, 70 }, // BS EN 12323:2005 4.1 (l) /* 3*/ { "0", 155, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 4*/ { "0", 161, ZINT_ERROR_TOO_LONG, -1, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_eci.c b/backend/tests/test_eci.c index 403efa57..299deb11 100644 --- a/backend/tests/test_eci.c +++ b/backend/tests/test_eci.c @@ -804,6 +804,184 @@ static void test_utf8_to_eci_ucs2be(void) { } }; +static void test_utf8_to_eci_sjis(void) { + + struct item { + int eci; + char *data; + int length; + int ret; + int expected_length; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { 20, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 }, + /* 1*/ { 20, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\177", 95, 0, 95 + 1 }, // Backslash goes to 2 byte + /* 2*/ { 20, "~", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for tilde + /* 3*/ { 20, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080 + /* 4*/ { 20, "\302\241", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00A1 Inverted exclaimation mark + /* 5*/ { 20, "\302\245", -1, 0, 1 }, // U+00A5 Yen goes to backslash + /* 6*/ { 20, "\302\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00BF Inverted question mark + /* 7*/ { 20, "\303\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00C0 À + /* 8*/ { 20, "\303\251", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00E9 é + /* 9*/ { 20, "\312\262", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+03B2 β + /* 10*/ { 20, "\342\272\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+2E80 CJK RADICAL REPEAT + /* 11*/ { 20, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE + /* 12*/ { 20, "\343\200\204", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+3004 JAPANESE INDUSTRIAL STANDARD SYMBOL + /* 13*/ { 20, "\343\201\201", -1, 0, 2 }, //U+3041 HIRAGANA LETTER SMALL A + /* 14*/ { 20, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF + /* 15*/ { 20, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed + /* 16*/ { 20, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed + }; + int data_size = ARRAY_SIZE(data); + int i, length, ret; + + testStart("test_utf8_to_eci_sjis"); + + for (i = 0; i < data_size; i++) { + int out_length, eci_length; + char dest[1024]; + + length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data); + out_length = length; + eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length); + + assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length); + ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length); + assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret); + if (ret == 0) { + assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length); + assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length); + } + } +}; + +static void test_utf8_to_eci_big5(void) { + + struct item { + int eci; + char *data; + int length; + int ret; + int expected_length; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { 28, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 }, + /* 1*/ { 28, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 }, + /* 2*/ { 28, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080 + /* 3*/ { 28, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE + /* 4*/ { 28, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF + /* 5*/ { 28, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed + /* 6*/ { 28, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed + }; + int data_size = ARRAY_SIZE(data); + int i, length, ret; + + testStart("test_utf8_to_eci_big5"); + + for (i = 0; i < data_size; i++) { + int out_length, eci_length; + char dest[1024]; + + length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data); + out_length = length; + eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length); + + assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length); + ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length); + assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret); + if (ret == 0) { + assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length); + assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length); + } + } +}; + +static void test_utf8_to_eci_gb2312(void) { + + struct item { + int eci; + char *data; + int length; + int ret; + int expected_length; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { 29, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 }, + /* 1*/ { 29, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 }, + /* 2*/ { 29, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080 + /* 3*/ { 29, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE + /* 4*/ { 29, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF + /* 5*/ { 29, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed + /* 6*/ { 29, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed + }; + int data_size = ARRAY_SIZE(data); + int i, length, ret; + + testStart("test_utf8_to_eci_gb2312"); + + for (i = 0; i < data_size; i++) { + int out_length, eci_length; + char dest[1024]; + + length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data); + out_length = length; + eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length); + + assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length); + ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length); + assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret); + if (ret == 0) { + assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length); + assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length); + } + } +}; + +static void test_utf8_to_eci_euc_kr(void) { + + struct item { + int eci; + char *data; + int length; + int ret; + int expected_length; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { 30, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 }, + /* 1*/ { 30, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 }, + /* 2*/ { 30, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080 + /* 3*/ { 30, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE + /* 4*/ { 30, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF + /* 5*/ { 30, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed + /* 6*/ { 30, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed + }; + int data_size = ARRAY_SIZE(data); + int i, length, ret; + + testStart("test_utf8_to_eci_euc_kr"); + + for (i = 0; i < data_size; i++) { + int out_length, eci_length; + char dest[1024]; + + length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data); + out_length = length; + eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length); + + assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length); + ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length); + assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret); + if (ret == 0) { + assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length); + assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length); + } + } +}; + static void test_get_best_eci(int index) { struct item { @@ -849,6 +1027,10 @@ int main(int argc, char *argv[]) { { "test_utf8_to_eci_sb", test_utf8_to_eci_sb, 1, 0, 0 }, { "test_utf8_to_eci_ascii", test_utf8_to_eci_ascii, 0, 0, 0 }, { "test_utf8_to_eci_ucs2be", test_utf8_to_eci_ucs2be, 0, 0, 0 }, + { "test_utf8_to_eci_sjis", test_utf8_to_eci_sjis, 0, 0, 0 }, + { "test_utf8_to_eci_big5", test_utf8_to_eci_big5, 0, 0, 0 }, + { "test_utf8_to_eci_gb2312", test_utf8_to_eci_gb2312, 0, 0, 0 }, + { "test_utf8_to_eci_euc_kr", test_utf8_to_eci_euc_kr, 0, 0, 0 }, { "test_get_best_eci", test_get_best_eci, 1, 0, 0 }, }; diff --git a/backend/tests/test_emf.c b/backend/tests/test_emf.c index 754f9681..041380d2 100644 --- a/backend/tests/test_emf.c +++ b/backend/tests/test_emf.c @@ -37,8 +37,10 @@ static void test_print(int index, int generate, int debug) { struct item { int symbology; int input_mode; + int border_width; int output_options; int whitespace_width; + int whitespace_height; int option_1; int option_2; char *fgcolour; @@ -49,19 +51,21 @@ static void test_print(int index, int generate, int debug) { char *comment; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" }, - /* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" }, - /* 2*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" }, - /* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" }, - /* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" }, - /* 5*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" }, - /* 6*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon.emf", "" }, - /* 7*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" }, - /* 8*/ { BARCODE_ITF14, -1, BOLD_TEXT, -1, -1, -1, "", "", 0, "123", "itf14_bold.emf", "" }, - /* 9*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 90, "123", "code39_rotate_90.emf", "" }, - /* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 180, "123", "code39_rotate_180.emf", "" }, - /* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, "", "", 270, "123", "code39_rotate_270.emf", "" }, - /* 12*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185.emf", "#185 Maxicode scaling" }, + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" }, + /* 1*/ { BARCODE_TELEPEN, -1, -1, -1, -1, -1, -1, -1, "147AD0", "FC9630", 0, "123", "telenum_fg_bg.emf", "" }, + /* 2*/ { BARCODE_ULTRA, -1, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", 0, "123", "ultracode_fg_bg.emf", "" }, + /* 3*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX, 2, 2, -1, -1, "FF0000", "0000FF", 0, "123", "ultracode_fg_bg_box2.emf", "" }, + /* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "9780877799306+54321", "ean13_5addon_ggs_5.2.2.5.2-2.emf", "" }, + /* 5*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "210987654321+54321", "ean13_5addon_#185.emf", "#185 Byte count, font data, HeaderExtension1/2" }, + /* 6*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.emf", "" }, + /* 7*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon.emf", "" }, + /* 8*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "0123456+12", "upce_2addon_small_bold.emf", "" }, + /* 9*/ { BARCODE_ITF14, -1, -1, BOLD_TEXT, -1, -1, -1, -1, "", "", 0, "123", "itf14_bold.emf", "" }, + /* 10*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 90, "123", "code39_rotate_90.emf", "" }, + /* 11*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 180, "123", "code39_rotate_180.emf", "" }, + /* 12*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, "", "", 270, "123", "code39_rotate_270.emf", "" }, + /* 13*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, "E0E0E0", "700070", 0, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_#185.emf", "#185 Maxicode scaling" }, + /* 14*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg.emf", "" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -97,9 +101,15 @@ static void test_print(int index, int generate, int debug) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (*data[i].fgcolour) { strcpy(symbol->fgcolour, data[i].fgcolour); } @@ -117,9 +127,9 @@ static void test_print(int index, int generate, int debug) { assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\" \"%s\" },\n", - i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), - testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n", + i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, + testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file, data[i].comment); ret = testUtilRename(symbol->outfile, expected_file); @@ -145,10 +155,41 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle); + +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + struct zint_vector vector = {0}; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.vector = &vector; + + strcpy(symbol.outfile, "nosuch_dir/out.emf"); + + ret = emf_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = emf_plot(&symbol, 0); + printf(" - ignore (EMF to stdout)\n"); fflush(stdout); + assert_zero(ret, "emf_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + symbol.vector = NULL; + ret = emf_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_INVALID_DATA, "emf_plot ret %d != ZINT_ERROR_INVALID_DATA (%d) (%s)\n", ret, ZINT_ERROR_INVALID_DATA, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_gb18030.c b/backend/tests/test_gb18030.c index d31f1da0..1a5e7109 100644 --- a/backend/tests/test_gb18030.c +++ b/backend/tests/test_gb18030.c @@ -134,6 +134,13 @@ static void test_gb18030_wctomb_zint(void) { int ret, ret2; unsigned int val1_1, val1_2, val2_1, val2_2; unsigned int i; + /* See: https://file.allitebooks.com/20160708/CJKV%20Information%20Processing.pdf (table 3-37, p.109, 2nd ed.) */ + static int nonpua_nonbmp[] = { + 0x20087, 0x20089, 0x200CC, 0x215D7, 0x2298F, 0x241FE + }; + static unsigned int nonpua_nonbmp_vals[] = { + 0xFE51, 0xFE52, 0xFE53, 0xFE6C, 0xFE76, 0xFE91 + }; testStart("test_gb18030_wctomb_zint"); @@ -151,6 +158,18 @@ static void test_gb18030_wctomb_zint(void) { } } + val1_1 = val1_2 = 0; + ret = gb18030_wctomb_zint(&val1_1, &val1_2, 0x110000); /* Invalid Unicode codepoint */ + assert_zero(ret, "0x110000 ret %d != 0, val1_1 0x%04X, val1_2 0x%04X\n", ret, val1_1, val1_2); + + for (i = 0; i < ARRAY_SIZE(nonpua_nonbmp); i++) { + val1_1 = val1_2 = 0; + ret = gb18030_wctomb_zint(&val1_1, &val1_2, nonpua_nonbmp[i]); + assert_equal(ret, 2, "i:%d 0x%04X ret %d != 2, val1_1 0x%04X, val1_2 0x%04X\n", (int) i, nonpua_nonbmp[i], ret, val1_1, val1_2); + assert_equal(val1_1, nonpua_nonbmp_vals[i], "i:%d 0x%04X val1_1 0x%04X != 0x%04X\n", (int) i, nonpua_nonbmp[i], val1_1, nonpua_nonbmp_vals[i]); + assert_zero(val1_2, "i:%d 0x%04X val1_2 0x%04X != 0\n", (int) i, nonpua_nonbmp[i], val1_2); + } + testFinish(); } @@ -183,6 +202,9 @@ static void test_gb18030_utf8(int index) { /* 6*/ { "―", -1, 0, 1, { 0xA844 }, "GB18030.TXT mapping" }, /* 7*/ { "—", -1, 0, 1, { 0xA1AA }, "GB 18030 subset mapping" }, /* 8*/ { "aβc・·—é—Z", -1, 0, 10, { 'a', 0xA6C2, 'c', 0x8139, 0xA739, 0xA1A4, 0xA1AA, 0xA8A6, 0xA1AA, 'Z' }, "" }, + /* 9*/ { "\200", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Invalid UTF-8" }, + /* 10*/ { "\357\277\276", -1, 0, 2, { 0x8431, 0xA438 }, "U+FFFE (reversed BOM)" }, + /* 11*/ { "\357\277\277", -1, 0, 2, { 0x8431, 0xA439 }, "U+FFFF" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_gb2312.c b/backend/tests/test_gb2312.c index 12b367bb..c71a4892 100644 --- a/backend/tests/test_gb2312.c +++ b/backend/tests/test_gb2312.c @@ -121,6 +121,7 @@ static void test_gb2312_utf8(int index) { /* 6*/ { "―", -1, 0, 1, { 0xA1AA }, "GB2312.TXT mapping" }, /* 7*/ { "—", -1, 0, 1, { 0xA1AA }, "GB 18030 subset mapping" }, /* 8*/ { "aβc・·—é—Z", -1, 0, 9, { 'a', 0xA6C2, 'c', 0xA1A4, 0xA1A4, 0xA1AA, 0xA8A6, 0xA1AA, 'Z' }, "" }, + /* 9*/ { "\200", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Invalid UTF-8" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_gif.c b/backend/tests/test_gif.c index 1664a1fa..763cc69e 100644 --- a/backend/tests/test_gif.c +++ b/backend/tests/test_gif.c @@ -40,19 +40,21 @@ static void test_pixel_plot(int index, int debug) { int height; char *pattern; int repeat; + int ret; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { 1, 1, "1", 0 }, - /* 1*/ { 2, 1, "11", 0 }, - /* 2*/ { 3, 1, "101", 0 }, - /* 3*/ { 4, 1, "1010", 0 }, - /* 4*/ { 5, 1, "10101", 0 }, - /* 5*/ { 3, 2, "101010", 0 }, - /* 6*/ { 3, 3, "101010101", 0 }, - /* 7*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0 }, - /* 8*/ { 20, 30, "WWCWBWMWRWYWGWKCCWCMCRCYCGCKBWBCBBMBRBYBGBKMWMCMBMMRMYMGMKRWRCRBRMRRYRGRKYWYCYBYMYRYYGYKGWGCGBGMGRGYGGKKWKCKBKMKRKYKGKK", 1 }, // Single LZW block, size 255 - /* 9*/ { 19, 32, "WWCWBWMWRWYWGWKCCWCMCRCYCGCKBWBCBBMBRBYBGBKMWMCMBMMRMYMGMKRWRCRBRMRRYRGRKYWYCYBYMYRYYGYKGWGCGBGMGRGYGGKKWK", 1 }, // Two LZW blocks, last size 1 + /* 0*/ { 1, 1, "1", 0, 0 }, + /* 1*/ { 2, 1, "11", 0, 0 }, + /* 2*/ { 3, 1, "101", 0, 0 }, + /* 3*/ { 4, 1, "1010", 0, 0 }, + /* 4*/ { 5, 1, "10101", 0, 0 }, + /* 5*/ { 3, 2, "101010", 0, 0 }, + /* 6*/ { 3, 3, "101010101", 0, 0 }, + /* 7*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0, 0 }, + /* 8*/ { 20, 30, "WWCWBWMWRWYWGWKCCWCMCRCYCGCKBWBCBBMBRBYBGBKMWMCMBMMRMYMGMKRWRCRBRMRRYRGRKYWYCYBYMYRYYGYKGWGCGBGMGRGYGGKKWKCKBKMKRKYKGKK", 1, 0 }, // Single LZW block, size 255 + /* 9*/ { 19, 32, "WWCWBWMWRWYWGWKCCWCMCRCYCGCKBWBCBBMBRBYBGBKMWMCMBMMRMYMGMKRWRCRBRMRRYRGRKYWYCYBYMYRYYGYKGWGCGBGMGRGYGGKKWK", 1, 0 }, // Two LZW blocks, last size 1 + /* 10*/ { 1, 1, "D", 0, ZINT_ERROR_INVALID_DATA }, }; int data_size = ARRAY_SIZE(data); int i, ret; @@ -62,12 +64,9 @@ static void test_pixel_plot(int index, int debug) { char data_buf[19 * 32 + 1]; // 19 * 32 == 608 - testStart("test_pixel_plot"); + int have_identify = testUtilHaveIdentify(); - if (!testUtilHaveIdentify()) { - testSkip("ImageMagick identify not available"); - return; - } + testStart("test_pixel_plot"); for (i = 0; i < data_size; i++) { int size; @@ -96,12 +95,21 @@ static void test_pixel_plot(int index, int debug) { symbol->bitmap = (unsigned char *) data_buf; ret = gif_pixel_plot(symbol, (unsigned char *) data_buf); - assert_zero(ret, "i:%d gif_pixel_plot ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d gif_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - ret = testUtilVerifyIdentify(symbol->outfile, debug); - assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); - - assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + if (ret < ZINT_ERROR) { + if (have_identify) { + ret = testUtilVerifyIdentify(symbol->outfile, debug); + assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); + } + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + } + } else { + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + (void) remove(symbol->outfile); + } + } symbol->bitmap = NULL; @@ -115,6 +123,8 @@ static void test_print(int index, int generate, int debug) { struct item { int symbology; + int border_width; + int output_options; int whitespace_width; int whitespace_height; int option_1; @@ -127,26 +137,29 @@ static void test_print(int index, int generate, int debug) { char *expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 0, 0, "", "", "12", "dotcode_1.0.gif" }, - /* 1*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 0, 0.1, "", "", "12", "dotcode_1.0_ds0.1.gif" }, - /* 2*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 0, 1.1, "", "", "12", "dotcode_1.0_ds1.1.gif" }, - /* 3*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 1.5, 0, "", "", "12", "dotcode_1.5.gif" }, - /* 4*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 1.5, 0.4, "", "", "12", "dotcode_1.5_ds0.4.gif" }, - /* 5*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 1.5, 1.1, "", "", "12", "dotcode_1.5_ds1.1.gif" }, - /* 6*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 1.5, 2.1, "", "", "12", "dotcode_1.5_ds2.1.gif" }, - /* 7*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 2, 0, "", "", "12", "dotcode_2.0.gif" }, - /* 8*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 2, 0.9, "", "", "12", "dotcode_2.0_ds0.9.gif" }, - /* 9*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 2, 1.1, "", "", "12", "dotcode_2.0_ds1.1.gif" }, - /* 10*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3, 0, "", "", "12", "dotcode_3.0.gif" }, - /* 11*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3, 0.4, "", "", "12", "dotcode_3.0_ds0.4.gif" }, - /* 12*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3, 1.1, "", "", "12", "dotcode_3.0_ds1.1.gif" }, - /* 13*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3.5, 0, "", "", "12", "dotcode_3.5.gif" }, - /* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3.5, 0.4, "", "", "12", "dotcode_3.5_ds0.4.gif" }, - /* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 3.5, 1.1, "", "", "12", "dotcode_3.5_ds1.1.gif" }, - /* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 5, 0, "", "", "12", "dotcode_5.0.gif" }, - /* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 5, 0.2, "", "", "12", "dotcode_5.0_ds0.2.gif" }, - /* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 5, 1.1, "", "", "12", "dotcode_5.0_ds1.1.gif" }, - /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, 5, 1.7, "", "", "12", "dotcode_5.0_ds1.7.gif" }, + /* 0*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "dotcode_1.0.gif" }, + /* 1*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0.1, "", "", "12", "dotcode_1.0_ds0.1.gif" }, + /* 2*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 1.1, "", "", "12", "dotcode_1.0_ds1.1.gif" }, + /* 3*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 1.5, 0, "", "", "12", "dotcode_1.5.gif" }, + /* 4*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 1.5, 0.4, "", "", "12", "dotcode_1.5_ds0.4.gif" }, + /* 5*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 1.5, 1.1, "", "", "12", "dotcode_1.5_ds1.1.gif" }, + /* 6*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 1.5, 2.1, "", "", "12", "dotcode_1.5_ds2.1.gif" }, + /* 7*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 2, 0, "", "", "12", "dotcode_2.0.gif" }, + /* 8*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 2, 0.9, "", "", "12", "dotcode_2.0_ds0.9.gif" }, + /* 9*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 2, 1.1, "", "", "12", "dotcode_2.0_ds1.1.gif" }, + /* 10*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3, 0, "", "", "12", "dotcode_3.0.gif" }, + /* 11*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3, 0.4, "", "", "12", "dotcode_3.0_ds0.4.gif" }, + /* 12*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3, 1.1, "", "", "12", "dotcode_3.0_ds1.1.gif" }, + /* 13*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3.5, 0, "", "", "12", "dotcode_3.5.gif" }, + /* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3.5, 0.4, "", "", "12", "dotcode_3.5_ds0.4.gif" }, + /* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 3.5, 1.1, "", "", "12", "dotcode_3.5_ds1.1.gif" }, + /* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 5, 0, "", "", "12", "dotcode_5.0.gif" }, + /* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 5, 0.2, "", "", "12", "dotcode_5.0_ds0.2.gif" }, + /* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 5, 1.1, "", "", "12", "dotcode_5.0_ds1.1.gif" }, + /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 5, 1.7, "", "", "12", "dotcode_5.0_ds1.7.gif" }, + /* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, "2674C344", "FDFFC2CC", "12", "dotcode_bgfgalpha.gif" }, + /* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, "00000000", "FFFFFF00", "12", "dotcode_bgfgtrans.gif" }, + /* 22*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, 0, 0, "0000FF", "FF0000", "12", "ultra_fgbg_hvwsp1_box1.gif" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -178,7 +191,10 @@ static void test_print(int index, int generate, int debug) { 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, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } @@ -208,8 +224,9 @@ static void test_print(int index, int generate, int debug) { assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %d, %d, %d, %d, %.5g, %.5g, \"%s\", \"%s\", \"%s\", \"%s\" },\n", - i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].whitespace_height, + printf(" /*%3d*/ { %s, %d, %s, %d, %d, %d, %d, %.5g, %.5g, \"%s\", \"%s\", \"%s\", \"%s\" },\n", + i, testUtilBarcodeName(data[i].symbology), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), + data[i].whitespace_width, data[i].whitespace_height, data[i].option_1, data[i].option_2, data[i].scale, data[i].dot_size, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = testUtilRename(symbol->outfile, expected_file); @@ -233,11 +250,37 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + unsigned char data[] = { "1" }; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.bitmap = data; + symbol.bitmap_width = symbol.bitmap_height = 1; + + strcpy(symbol.outfile, "nosuch_dir/out.gif"); + + ret = gif_pixel_plot(&symbol, data); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "gif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = gif_pixel_plot(&symbol, data); + printf(" - ignore (GIF to stdout)\n"); fflush(stdout); + assert_zero(ret, "gif_pixel_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_pixel_plot", test_pixel_plot, 1, 0, 1 }, { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 5656ae8c..5d187580 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -357,6 +357,7 @@ static void test_escape_char_process(int index, int generate, int debug) { for (i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); diff --git a/backend/tests/test_pcx.c b/backend/tests/test_pcx.c index 63448986..2f995f95 100644 --- a/backend/tests/test_pcx.c +++ b/backend/tests/test_pcx.c @@ -31,41 +31,50 @@ #include "testcommon.h" -static void test_pcx(int index, int debug) { +static void test_print(int index, int generate, int debug) { struct item { int symbology; + int border_width; + int output_options; + int whitespace_width; + int whitespace_height; int option_1; int option_2; char *fgcolour; char *bgcolour; float scale; char *data; + char *expected_file; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, "", "", 0, "AIM" }, - /* 1*/ { BARCODE_QRCODE, 2, 1, "", "", 0, "1234567890" }, - /* 2*/ { BARCODE_DOTCODE, -1, -1, "", "", 0, "2741" }, - /* 3*/ { BARCODE_MAXICODE, -1, -1, "", "", 0, "1" }, - /* 4*/ { BARCODE_GRIDMATRIX, -1, -1, "", "", 0.75, "Grid Matrix" }, - /* 5*/ { BARCODE_CODABLOCKF, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890" }, - /* 6*/ { BARCODE_CODE128, -1, -1, "C3C3C3", "", 0, "AIM" }, - /* 7*/ { BARCODE_QRCODE, 2, 1, "", "D2E3F4", 0, "1234567890" }, - /* 8*/ { BARCODE_DOTCODE, -1, -1, "C2C100", "E0E1F2", 0, "2741" }, - /* 9*/ { BARCODE_ULTRA, -1, -1, "", "", 0, "ULTRACODE_123456789!" }, + /* 0*/ { BARCODE_GRIDMATRIX, -1, -1, -1, -1, -1, -1, "C3C3C3", "", 0.75, "Grid Matrix", "gridmatrix_fg_0.75.pcx" }, + /* 1*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890", "codeblockf_reverse.pcx" }, + /* 2*/ { BARCODE_QRCODE, -1, -1, -1, -1, 2, 1, "", "D2E3F4", 0, "1234567890", "qr_bg.pcx" }, + /* 3*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "FF0000", "0000FF", 0, "ULTRACODE_123456789!", "ultra_fg_bg_hvwsp1_box1.pcx" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol; - char *filename = "out.pcx"; + const char *data_dir = "/backend/tests/data/pcx"; + char *pcx = "out.pcx"; + char expected_file[4096]; + char escaped[1024]; + int escaped_size = 1024; + + int have_identify = testUtilHaveIdentify(); testStart("test_pcx"); - if (!testUtilHaveIdentify()) { - testSkip("ImageMagick identify not available"); - return; + if (generate) { + char data_dir_path[1024]; + assert_nonzero(testUtilDataPath(data_dir_path, sizeof(data_dir_path), data_dir, NULL), "testUtilDataPath(%s) == 0\n", data_dir); + if (!testUtilDirExists(data_dir_path)) { + ret = testUtilMkDir(data_dir_path); + assert_zero(ret, "testUtilMkDir(%s) ret %d != 0 (%d: %s)\n", data_dir_path, ret, errno, strerror(errno)); + } } for (i = 0; i < data_size; i++) { @@ -75,12 +84,15 @@ static void test_pcx(int index, int debug) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - symbol->symbology = data[i].symbology; - if (data[i].option_1 != -1) { - symbol->option_1 = data[i].option_1; + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; } - if (data[i].option_2 != -1) { - symbol->option_2 = data[i].option_2; + if (data[i].whitespace_width != -1) { + symbol->whitespace_width = data[i].whitespace_width; + } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; } if (*data[i].fgcolour) { strcpy(symbol->fgcolour, data[i].fgcolour); @@ -93,19 +105,35 @@ static void test_pcx(int index, int debug) { } symbol->debug |= debug; - length = (int) strlen(data[i].data); - ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); - strcpy(symbol->outfile, filename); + strcpy(symbol->outfile, pcx); ret = ZBarcode_Print(symbol, 0); assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); - ret = testUtilVerifyIdentify(symbol->outfile, debug); - assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); + assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); - assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + if (generate) { + printf(" /*%3d*/ { %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), + data[i].whitespace_width, data[i].whitespace_height, + data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, + testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + ret = testUtilRename(symbol->outfile, expected_file); + assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0 (%d: %s)\n", i, symbol->outfile, expected_file, ret, errno, strerror(errno)); + if (have_identify) { + ret = testUtilVerifyIdentify(expected_file, debug); + assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), expected_file, ret); + } + } else { + assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); + assert_nonzero(testUtilExists(expected_file), "i:%d testUtilExists(%s) == 0\n", i, expected_file); + + ret = testUtilCmpBins(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + } ZBarcode_Delete(symbol); } @@ -113,10 +141,38 @@ static void test_pcx(int index, int debug) { testFinish(); } +INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); + +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + unsigned char data[] = { "1" }; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.bitmap = data; + symbol.bitmap_width = symbol.bitmap_height = 1; + + strcpy(symbol.outfile, "nosuch_dir/out.pcx"); + + ret = pcx_pixel_plot(&symbol, data); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "pcx_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = pcx_pixel_plot(&symbol, data); + printf(" - ignore (PCX to stdout)\n"); fflush(stdout); + assert_zero(ret, "pcx_pixel_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ - { "test_pcx", test_pcx, 1, 0, 1 }, + { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index 102f3b74..86e8bd9c 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -30,6 +30,7 @@ /* vim: set ts=4 sw=4 et : */ #include "testcommon.h" +#include #include INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf); @@ -41,16 +42,17 @@ static void test_pixel_plot(int index, int debug) { int height; char *pattern; int repeat; + int ret; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { 1, 1, "1", 0 }, - /* 1*/ { 2, 1, "11", 0 }, - /* 2*/ { 2, 2, "10", 1 }, - /* 3*/ { 3, 1, "101", 0 }, - /* 4*/ { 3, 2, "101010", 0 }, - /* 5*/ { 3, 3, "101010101", 0 }, - /* 6*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0 }, + /* 0*/ { 1, 1, "1", 0, 0 }, + /* 1*/ { 2, 1, "11", 0, 0 }, + /* 2*/ { 2, 2, "10", 1, 0 }, + /* 3*/ { 3, 1, "101", 0, 0 }, + /* 4*/ { 3, 2, "101010", 0, 0 }, + /* 5*/ { 3, 3, "101010101", 0, 0 }, + /* 6*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0, 0 }, }; int data_size = ARRAY_SIZE(data); int i, ret; @@ -60,12 +62,9 @@ static void test_pixel_plot(int index, int debug) { char data_buf[8 * 2 + 1]; - testStart("test_pixel_plot"); + int have_identify = testUtilHaveIdentify(); - if (!testUtilHaveIdentify()) { - testSkip("ImageMagick identify not available"); - return; - } + testStart("test_pixel_plot"); for (i = 0; i < data_size; i++) { int size; @@ -94,12 +93,21 @@ static void test_pixel_plot(int index, int debug) { symbol->bitmap = (unsigned char *) data_buf; ret = png_pixel_plot(symbol, (unsigned char *) data_buf); - assert_zero(ret, "i:%d png_pixel_plot ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d png_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - ret = testUtilVerifyIdentify(symbol->outfile, debug); - assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); - - assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + if (ret < ZINT_ERROR) { + if (have_identify) { + ret = testUtilVerifyIdentify(symbol->outfile, debug); + assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); + } + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + } + } else { + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + (void) remove(symbol->outfile); + } + } symbol->bitmap = NULL; @@ -173,19 +181,21 @@ static void test_print(int index, int generate, int debug) { /* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", 0, "ultra_bgalpha.png", "" }, /* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", 0, "ultra_fgalpha.png", "" }, /* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", 0, "ultra_fgalpha_nobg.png", "" }, - /* 41*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "00FF007F", "BABDB6", "12345", "", 0, "ultra_fgalpha_hvwsp1_box1.png", "" }, - /* 42*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", 0, "ultra_odd.png", "" }, - /* 43*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.5.png", "6 dpmm, 150 dpi" }, - /* 44*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, - /* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, - /* 46*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_2.1.png", "24 dpmm, 600 dpi" }, - /* 47*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_hvwsp1_box2.png", "" }, - /* 48*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.png", "" }, - /* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", 0, "datamatrix_2.0_bind1_dotty.png", "" }, - /* 50*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", 0, "datamatrix_2.0_hvwsp1_bind1_dotty.png", "" }, - /* 51*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345678909", "", 0, "dbar_ltd.png", "" }, - /* 52*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5.0f, 0, "", "", "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.png", "" }, - /* 53*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75f, 0, "", "", "12345678901234567890", "", 0, "imail_height7.75.png", "" }, + /* 41*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "12345", "", 0, "ultra_hvwsp1_box1.png", "" }, + /* 42*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "00FF007F", "BABDB6", "12345", "", 0, "ultra_fgalpha_hvwsp1_box1.png", "" }, + /* 43*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5, "", "", "1", "", 0, "ultra_odd.png", "" }, + /* 44*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.5.png", "6 dpmm, 150 dpi" }, + /* 45*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, + /* 46*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, + /* 47*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_2.1.png", "24 dpmm, 600 dpi" }, + /* 48*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_hvwsp1_box2.png", "" }, + /* 49*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.png", "" }, + /* 50*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", 0, "datamatrix_2.0_bind1_dotty.png", "" }, + /* 51*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", 0, "datamatrix_2.0_hvwsp1_bind1_dotty.png", "" }, + /* 52*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345678909", "", 0, "dbar_ltd.png", "" }, + /* 53*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5.0, 0, "", "", "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.png", "" }, + /* 54*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75, 0, "", "", "12345678901234567890", "", 0, "imail_height7.75.png", "" }, + /* 55*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567890", "", 0, "aztec.png", "" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -262,10 +272,10 @@ static void test_print(int index, int generate, int debug) { assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, %.5g, \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, - testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment); + testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].ret, data[i].expected_file, data[i].comment); ret = testUtilRename(symbol->outfile, expected_file); assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); if (have_identify) { @@ -289,11 +299,95 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + unsigned char data[] = { "1" }; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.bitmap = data; + symbol.bitmap_width = symbol.bitmap_height = 1; + + strcpy(symbol.outfile, "nosuch_dir/out.png"); + + ret = png_pixel_plot(&symbol, data); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "png_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = png_pixel_plot(&symbol, data); + printf(" - ignore (PNG to stdout)\n"); fflush(stdout); + assert_zero(ret, "png_pixel_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + testFinish(); +} + +#include +#include + +struct wpng_error_type { + struct zint_symbol *symbol; + jmp_buf jmpbuf; +}; + +STATIC_UNLESS_ZINT_TEST void wpng_error_handler(png_structp png_ptr, png_const_charp msg); + +static void test_wpng_error_handler(void) { + int ret; + char filename[] = "out.png"; + FILE *fp; + struct wpng_error_type wpng_error; + struct zint_symbol symbol = {0}; + png_structp png_ptr; + png_infop info_ptr; + + testStart("test_wpng_error_handler"); + + wpng_error.symbol = &symbol; + + // Create empty file + (void) remove(filename); // In case junk hanging around + fp = fopen(filename, "w+"); + assert_nonnull(fp, "fopen(%s) failed\n", filename); + ret = fclose(fp); + assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret); + + // Re-open for read, which will cause libpng to error + fp = fopen(filename, "r"); + assert_nonnull(fp, "fopen(%s) for read failed\n", filename); + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler, NULL); + assert_nonnull(png_ptr, "png_create_write_struct failed\n"); + + info_ptr = png_create_info_struct(png_ptr); + assert_nonnull(info_ptr, "png_create_info_struct failed\n"); + + if (setjmp(wpng_error.jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + ret = fclose(fp); + assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret); + assert_nonnull(strstr(symbol.errtxt, "635: libpng error:"), "strstr(%s) NULL\n", symbol.errtxt); + assert_zero(remove(filename), "remove(%s) != 0 (%d: %s)\n", filename, errno, strerror(errno)); + } else { + png_init_io(png_ptr, fp); + + // This should fail and jmp to setjmp + png_write_info(png_ptr, info_ptr); + assert_zero(1, "libpng error setjmp failed\n"); + } + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_pixel_plot", test_pixel_plot, 1, 0, 1 }, { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, + { "test_wpng_error_handler", test_wpng_error_handler, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_ps.c b/backend/tests/test_ps.c index cf7f1a67..fd8992e8 100644 --- a/backend/tests/test_ps.c +++ b/backend/tests/test_ps.c @@ -37,47 +37,56 @@ static void test_print(int index, int generate, int debug) { struct item { int symbology; int input_mode; + int border_width; int output_options; int whitespace_width; + int whitespace_height; int option_1; int option_2; float scale; float dot_size; char *fgcolour; char *bgcolour; + int rotate_angle; char *data; char *expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, BOLD_TEXT, -1, -1, -1, 0, 0, "", "", "Égjpqy", "code128_egrave_bold.eps" }, - /* 1*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", "123", "code39_fg_bg.eps" }, - /* 2*/ { BARCODE_ULTRA, -1, 1, -1, -1, -1, 0, 0, "147AD0", "FC9630", "123", "ultra_fg_bg.eps" }, - /* 3*/ { BARCODE_EANX, -1, -1, -1, -1, -1, 0, 0, "", "", "9771384524017+12", "ean13_2addon_ggs_5.2.2.5.1-2.eps" }, - /* 4*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, 0, "", "", "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.eps" }, - /* 5*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, 0, "", "", "0123456+12345", "upce_5addon.eps" }, - /* 6*/ { BARCODE_UPCE, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, 0, 0, "", "", "0123456+12345", "upce_5addon_small_bold.eps" }, - /* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, 0, 0, "", "", "A\\B)ç(D", "code128_escape_latin1.eps" }, - /* 8*/ { BARCODE_DBAR_LTD, -1, BOLD_TEXT, -1, -1, -1, 0, 0, "", "", "1501234567890", "dbar_ltd_24724_fig7_bold.eps" }, - /* 9*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "dotcode_1.0.eps" }, - /* 10*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 0, 0.1, "", "", "12", "dotcode_1.0_ds0.1.eps" }, - /* 11*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 0, 1.1, "", "", "12", "dotcode_1.0_ds1.1.eps" }, - /* 12*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 1.5, 0, "", "", "12", "dotcode_1.5.eps" }, - /* 13*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 1.5, 0.4, "", "", "12", "dotcode_1.5_ds0.4.eps" }, - /* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 1.5, 1.1, "", "", "12", "dotcode_1.5_ds1.1.eps" }, - /* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 1.5, 2.1, "", "", "12", "dotcode_1.5_ds2.1.eps" }, - /* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 2, 0, "", "", "12", "dotcode_2.0.eps" }, - /* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 2, 0.9, "", "", "12", "dotcode_2.0_ds0.9.eps" }, - /* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 2, 1.1, "", "", "12", "dotcode_2.0_ds1.1.eps" }, - /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3, 0, "", "", "12", "dotcode_3.0.eps" }, - /* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3, 0.4, "", "", "12", "dotcode_3.0_ds0.4.eps" }, - /* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3, 1.1, "", "", "12", "dotcode_3.0_ds1.1.eps" }, - /* 22*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3.5, 0, "", "", "12", "dotcode_3.5.eps" }, - /* 23*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3.5, 0.4, "", "", "12", "dotcode_3.5_ds0.4.eps" }, - /* 24*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 3.5, 1.1, "", "", "12", "dotcode_3.5_ds1.1.eps" }, - /* 25*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 5, 0, "", "", "12", "dotcode_5.0.eps" }, - /* 26*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 5, 0.2, "", "", "12", "dotcode_5.0_ds0.2.eps" }, - /* 27*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 5, 1.1, "", "", "12", "dotcode_5.0_ds1.1.eps" }, - /* 28*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, 5, 1.7, "", "", "12", "dotcode_5.0_ds1.7.eps" }, + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.eps" }, + /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 90, "Égjpqy", "code128_egrave_bold_rotate_90.eps" }, + /* 2*/ { BARCODE_CODE39, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "code39_fg_bg.eps" }, + /* 3*/ { BARCODE_CODE39, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "147AD0EE", "FC9630", 0, "123", "code39_fgalpha_bg_cmyk.eps" }, + /* 4*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "147AD0", "FC9630", 0, "123", "ultra_fg_bg.eps" }, + /* 5*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 2, -1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box.eps" }, + /* 6*/ { BARCODE_ULTRA, -1, 2, BARCODE_BOX | CMYK_COLOUR, 1, 1, -1, -1, 0, 0, "0000FF", "FF0000", 0, "123", "ultra_fg_bg_box_cmyk.eps" }, + /* 7*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "9771384524017+12", "ean13_2addon_ggs_5.2.2.5.1-2.eps" }, + /* 8*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "012345678905+24", "upca_2addon_ggs_5.2.6.6-5.eps" }, + /* 9*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon.eps" }, + /* 10*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "0123456+12345", "upce_5addon_small_bold.eps" }, + /* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "A\\B)ç(D", "code128_escape_latin1.eps" }, + /* 12*/ { BARCODE_DBAR_LTD, -1, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "1501234567890", "dbar_ltd_24724_fig7_bold.eps" }, + /* 13*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", 0, "12", "dotcode_1.0.eps" }, + /* 14*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0.1, "", "", 0, "12", "dotcode_1.0_ds0.1.eps" }, + /* 15*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 1.1, "", "", 0, "12", "dotcode_1.0_ds1.1.eps" }, + /* 16*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0, "", "", 0, "12", "dotcode_1.5.eps" }, + /* 17*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 0.4, "", "", 0, "12", "dotcode_1.5_ds0.4.eps" }, + /* 18*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 1.1, "", "", 0, "12", "dotcode_1.5_ds1.1.eps" }, + /* 19*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 1.5, 2.1, "", "", 0, "12", "dotcode_1.5_ds2.1.eps" }, + /* 20*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0, "", "", 0, "12", "dotcode_2.0.eps" }, + /* 21*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 0.9, "", "", 0, "12", "dotcode_2.0_ds0.9.eps" }, + /* 22*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 2, 1.1, "", "", 0, "12", "dotcode_2.0_ds1.1.eps" }, + /* 23*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0, "", "", 0, "12", "dotcode_3.0.eps" }, + /* 24*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 0.4, "", "", 0, "12", "dotcode_3.0_ds0.4.eps" }, + /* 25*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3, 1.1, "", "", 0, "12", "dotcode_3.0_ds1.1.eps" }, + /* 26*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0, "", "", 0, "12", "dotcode_3.5.eps" }, + /* 27*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 0.4, "", "", 0, "12", "dotcode_3.5_ds0.4.eps" }, + /* 28*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 3.5, 1.1, "", "", 0, "12", "dotcode_3.5_ds1.1.eps" }, + /* 29*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0, "", "", 0, "12", "dotcode_5.0.eps" }, + /* 30*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 0.2, "", "", 0, "12", "dotcode_5.0_ds0.2.eps" }, + /* 31*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.1, "", "", 0, "12", "dotcode_5.0_ds1.1.eps" }, + /* 32*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 5, 1.7, "", "", 0, "12", "dotcode_5.0_ds1.7.eps" }, + /* 33*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "FF0000", "0000FF00", 0, "12", "dotcode_no_bg.eps" }, + /* 34*/ { BARCODE_MAXICODE, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0, 0, "", "", 270, "12", "maxicode_rotate_270_cmyk.eps" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -110,9 +119,15 @@ static void test_print(int index, int generate, int debug) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); + if (data[i].border_width != -1) { + symbol->border_width = data[i].border_width; + } if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (data[i].scale) { symbol->scale = data[i].scale; } @@ -130,15 +145,16 @@ static void test_print(int index, int generate, int debug) { assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); strcpy(symbol->outfile, eps); - ret = ZBarcode_Print(symbol, 0); + ret = ZBarcode_Print(symbol, data[i].rotate_angle); assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %s, %s, %d, %d, %d, %.5g, %.5g, \"%s\", \"%s\", \"%s\", \"%s\"},\n", - i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, - data[i].option_1, data[i].option_2, data[i].scale, data[i].dot_size, data[i].fgcolour, data[i].bgcolour, + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %.5g, %.5g, \"%s\", \"%s\", %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, + testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].option_1, data[i].option_2, + data[i].scale, data[i].dot_size, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = testUtilRename(symbol->outfile, expected_file); assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); @@ -170,7 +186,7 @@ static void test_ps_convert(int index) { char *expected; }; struct item data[] = { - /* 0*/ { "1\\(é)2€3", "1\\\\\\(\351\\)23" }, + /* 0*/ { "1\\(é)2€3¿", "1\\\\\\(\351\\)23\277" }, }; int data_size = ARRAY_SIZE(data); int i; @@ -190,11 +206,42 @@ static void test_ps_convert(int index) { testFinish(); } +INTERNAL int ps_plot(struct zint_symbol *symbol, int rotate_angle); + +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + struct zint_vector vector = {0}; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.vector = &vector; + + strcpy(symbol.outfile, "nosuch_dir/out.eps"); + + ret = ps_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ps_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = ps_plot(&symbol, 0); + printf(" - ignore (EPS to stdout)\n"); fflush(stdout); + assert_zero(ret, "ps_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + symbol.vector = NULL; + ret = ps_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_INVALID_DATA, "ps_plot ret %d != ZINT_ERROR_INVALID_DATA (%d) (%s)\n", ret, ZINT_ERROR_INVALID_DATA, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_print", test_print, 1, 1, 1 }, { "test_ps_convert", test_ps_convert, 1, 0, 0 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_reedsol.c b/backend/tests/test_reedsol.c index bce728c7..d0ef01fa 100644 --- a/backend/tests/test_reedsol.c +++ b/backend/tests/test_reedsol.c @@ -110,7 +110,7 @@ static void test_generate(int generate) { } } -static void test_encoding(int index) { +static void test_encoding(int index, int debug) { struct item { unsigned int prime_poly; @@ -141,6 +141,7 @@ static void test_encoding(int index) { /* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 1, 15, 22, 28, 39, 17, 60, 5, 35, 35, 4, 8, 0, 32, 51, 45, 63, 53, 61, 14 } }, // MAXICODE Annex H Secondary even /* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, 0x2C, 0x55 } }, // QRCODE Annex I.2 /* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x86, 0x0D, 0x22, 0xAE, 0x30 } }, // QRCODE Annex I.3 + /* 18*/ { 0x163, 256, 0, 1, { 0xFF }, { 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255 } }, }; int data_size = ARRAY_SIZE(data); int i; @@ -158,8 +159,10 @@ static void test_encoding(int index) { rs_init_code(&rs, data[i].nsym, data[i].index); rs_encode(&rs, data[i].datalen, data[i].data, res); - //fprintf(stderr, "res "); for (j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d ", res[j]); fprintf(stderr, "\n"); - //fprintf(stderr, "exp "); for (j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d ", data[i].expected[j]); fprintf(stderr, "\n"); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { + fprintf(stderr, "res "); for (j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d, ", res[j]); fprintf(stderr, "\n"); + fprintf(stderr, "exp "); for (j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d, ", data[i].expected[j]); fprintf(stderr, "\n"); + } for (j = 0; j < data[i].nsym; j++) { int k = data[i].nsym - 1 - j; assert_equal(res[k], data[i].expected[j], "i:%d res[%d] %d != expected[%d] %d\n", i, k, res[k], j, data[i].expected[j]); @@ -169,7 +172,69 @@ static void test_encoding(int index) { testFinish(); } -static void test_encoding_uint(int index) { +static void test_encoding_uint(int index, int debug) { + + struct item { + unsigned int prime_poly; + int nsym; + int index; + int datalen; + unsigned int data[256]; + + unsigned int expected[256]; + }; + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) + struct item data[] = { + /* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 54, 17, 53, 58 } }, // AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10 + /* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 38, 50, 8, 16, 10, 20, 40 } }, // AZTEC ISO/IEC 24778:2008 Section G.4 + /* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 12, 2, 3, 1, 9 } }, // AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message + /* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 114, 25, 5, 88, 102 } }, // DATAMATRIX ISO/IEC 16022:2006 Annex O + /* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 123, 47, 2, 20, 54, 112, 35, 23, 100, 89, 55, 17, 101, 4, 14, 33, 48, 62, 98, 52, 2, 79, 92, 70, 102 } }, // GRIDMATRIX AIMD014 Section 6.8 + /* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0xEB, 0xB4, 0x68, 0x1D } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.1 + /* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x08, 0x57, 0x0C, 0xE0, 0x7A, 0xA5, 0xDD, 0xA2, 0x99, 0xCF, 0xA4, 0x82, 0xAD, 0x11, 0xB0, 0x84, 0x74, 0x5D, 0x9A, 0x99, 0x0B, 0xCD, 0x49, 0x77 } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block + /* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0xA2, 0xA7, 0x68, 0x8A, 0x5F, 0xE6, 0xAA, 0x11, 0xA6, 0x69, 0x4A, 0xCF, 0xCF, 0x20, 0x5D, 0x00, 0x1B, 0x79, 0xA1, 0xFE, 0xB7, 0x94, 0x03, 0x9B } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block + /* 8*/ { 0x163, 24, 1, 29, { 0x00 }, { 0x00 } }, // HANXIN ISO/IEC DIS 20830:2019 Annex K.2 3rd block + /* 9*/ { 0x25, 6, 1, 16, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 14, 7, 23, 3, 23, 15 } }, // MAILMARK Royal Mail Mailmark barcode C encoding and decoding Example 2.3.1 + /* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 27, 22, 24, 16, 6, 24 } }, // MAILMARK Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2 + /* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 20, 1, 20, 7, 14, 11, 18 } }, // MAILMARK Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1 + /* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 19, 7, 9, 8, 6, 16, 16 } }, // MAILMARK Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2 + /* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 50, 2, 42, 51, 53, 34, 22, 20, 5, 16 } }, // MAXICODE Annex H Primary + /* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 31, 2, 58, 6, 6, 39, 13, 63, 2, 30, 19, 19, 14, 19, 23, 17, 62, 8, 2, 23 } }, // MAXICODE Annex H Secondary odd + /* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 1, 15, 22, 28, 39, 17, 60, 5, 35, 35, 4, 8, 0, 32, 51, 45, 63, 53, 61, 14 } }, // MAXICODE Annex H Secondary even + /* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, 0x2C, 0x55 } }, // QRCODE Annex I.2 + /* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x86, 0x0D, 0x22, 0xAE, 0x30 } }, // QRCODE Annex I.3 + /* 18*/ { 0x163, 256, 0, 1, { 0xFF }, { 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255 } }, + }; + int data_size = ARRAY_SIZE(data); + int i; + + testStart("test_encoding_uint"); + + for (i = 0; i < data_size; i++) { + int j; + rs_t rs; + unsigned int res[1024]; + + if (index != -1 && i != index) continue; + + rs_init_gf(&rs, data[i].prime_poly); + rs_init_code(&rs, data[i].nsym, data[i].index); + rs_encode_uint(&rs, data[i].datalen, data[i].data, res); + + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { + fprintf(stderr, "res "); for (j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d, ", res[j]); fprintf(stderr, "\n"); + fprintf(stderr, "exp "); for (j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d, ", data[i].expected[j]); fprintf(stderr, "\n"); + } + for (j = 0; j < data[i].nsym; j++) { + int k = data[i].nsym - 1 - j; + assert_equal(res[k], data[i].expected[j], "i:%d res[%d] %d != expected[%d] %d\n", i, k, res[k], j, data[i].expected[j]); + } + } + + testFinish(); +} + +static void test_uint_encoding(int index, int debug) { struct item { unsigned int prime_poly; @@ -185,11 +250,13 @@ static void test_encoding_uint(int index) { struct item data[] = { /* 0*/ { 0x409, 1023, 4, 1, 7, { 0x3FF, 0x000, 0x100, 0x1FF, 0x3FF, 0x000, 0x123 }, { 229, 153, 993, 674 } }, /* 1*/ { 0x1069, 4095, 4, 1, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 3472, 2350, 3494, 575 } }, + /* 2*/ { 0x1000, 4095, 4, 0, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 1, 65, 0, 64 } }, + /* 3*/ { 0x1000, 4095, 256, 0, 1, { 0xFFF }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 512, 0, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, }; int data_size = ARRAY_SIZE(data); int i; - testStart("test_encoding_uint"); + testStart("test_uint_encoding"); for (i = 0; i < data_size; i++) { int j; @@ -198,17 +265,35 @@ static void test_encoding_uint(int index) { if (index != -1 && i != index) continue; - rs_uint_init_gf(&rs_uint, data[i].prime_poly, data[i].logmod); + assert_nonzero(rs_uint_init_gf(&rs_uint, data[i].prime_poly, data[i].logmod), "i:%d rs_uint_init_gf() == 0\n", i); rs_uint_init_code(&rs_uint, data[i].nsym, data[i].index); rs_uint_encode(&rs_uint, data[i].datalen, data[i].data, res); rs_uint_free(&rs_uint); - //fprintf(stderr, "res "); for (j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d ", res[j]); fprintf(stderr, "\n"); - //fprintf(stderr, "exp "); for (j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d ", data[i].expected[j]); fprintf(stderr, "\n"); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { + fprintf(stderr, "res "); for (j = data[i].nsym - 1; j >= 0; j--) fprintf(stderr, "%d, ", res[j]); fprintf(stderr, "\n"); + fprintf(stderr, "exp "); for (j = 0; j < data[i].nsym; j++) fprintf(stderr, "%d, ", data[i].expected[j]); fprintf(stderr, "\n"); + } for (j = 0; j < data[i].nsym; j++) { int k = data[i].nsym - 1 - j; assert_equal(res[k], data[i].expected[j], "i:%d res[%d] %d != expected[%d] %d\n", i, k, (int) res[k], j, (int) data[i].expected[j]); } + + /* Simulate rs_uint_init_gf() malloc() failure and rs_uint_init_gf()'s return val not being checked */ + assert_nonzero(rs_uint_init_gf(&rs_uint, data[i].prime_poly, data[i].logmod), "i:%d rs_uint_init_gf() == 0\n", i); + free(rs_uint.logt); + rs_uint.logt = NULL; + free(rs_uint.alog); + rs_uint.alog = NULL; + + rs_uint_init_code(&rs_uint, data[i].nsym, data[i].index); + rs_uint_encode(&rs_uint, data[i].datalen, data[i].data, res); + rs_uint_free(&rs_uint); + + for (j = 0; j < data[i].nsym; j++) { + int k = data[i].nsym - 1 - j; + assert_zero(res[k], "i:%d res[%d] %d != 0\n", i, k, (int) res[k]); + } } testFinish(); @@ -218,8 +303,9 @@ int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_generate", test_generate, 0, 1, 0 }, - { "test_encoding", test_encoding, 1, 0, 0 }, - { "test_encoding_uint", test_encoding_uint, 1, 0, 0 }, + { "test_encoding", test_encoding, 1, 0, 1 }, + { "test_encoding_uint", test_encoding_uint, 1, 0, 1 }, + { "test_uint_encoding", test_uint_encoding, 1, 0, 1 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_sjis.c b/backend/tests/test_sjis.c index 2b6b2926..ce2e6585 100644 --- a/backend/tests/test_sjis.c +++ b/backend/tests/test_sjis.c @@ -139,6 +139,7 @@ static void test_sjis_utf8(int index) { /* 2*/ { "β", -1, 0, 1, { 0x83C0 }, "" }, /* 3*/ { "¥", -1, 0, 1, { 0x5C }, "" }, /* 4*/ { "aβcЖ¥・ソ‾\\\点茗テ", -1, 0, 13, { 'a', 0x83C0, 'c', 0x8447, 0x5C, 0xA5, 0xBF, 0x7E, 0x815F, 0x815F, 0x935F, 0xE4AA, 0x8365 }, "" }, + /* 5*/ { "\200", -1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Invalid UTF-8" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 92c0d969..43a42850 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -45,56 +45,64 @@ static void test_print(int index, int generate, int debug) { int option_1; int option_2; float height; + char *fgcolour; + char *bgcolour; + int rotate_angle; char *data; char *composite; int ret; char *expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, 0, "<>\"&'", "", 0, "code128_amperands.svg" }, - /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, "Égjpqy", "", 0, "code128_egrave_bold.svg" }, - /* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, "Égjpqy", "", 0, "code128_egrave_bold_box3.svg" }, - /* 3*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp2_box2.svg" }, - /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, 3, 3, -1, -1, -1, 0, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp3.svg" }, - /* 5*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", 0, "gs1_128_cc_fig12.svg" }, - /* 6*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, -1, 3, -1, 0, "AAAAAAAAA", "", 0, "codablockf_3rows.svg" }, - /* 7*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, 3, -1, 0, "AAAAAAAAA", "", 0, "codablockf_hvwsp2.svg" }, - /* 8*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, "AAAAAAAAA", "", 0, "codablockf_hvwsp2_box2.svg" }, - /* 9*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.svg" }, - /* 10*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.svg" }, - /* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.svg" }, - /* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.svg" }, - /* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.svg" }, - /* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5.svg" }, - /* 15*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, "614141234417+12345", "", 0, "upca_5addon.svg" }, - /* 16*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, "614141234417+12345", "", 0, "upca_5addon_bind3.svg" }, - /* 17*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, -1, 0, "614141234417+12345", "", 0, "upca_5addon_small_bold.svg" }, - /* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4.svg" }, - /* 19*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4.svg" }, - /* 20*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_notext.svg" }, - /* 21*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_bind3.svg" }, - /* 22*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, "1234567+12", "", 0, "upce_2addon.svg" }, - /* 23*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, "1234567+12345", "", 0, "upce_5addon.svg" }, - /* 24*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, "1234567+12345", "", 0, "upce_5addon_small.svg" }, - /* 25*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, -1, -1, 0, "1234567+12345", "", 0, "upce_5addon_notext.svg" }, - /* 26*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2.svg" }, - /* 27*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2.svg" }, - /* 28*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_notext.svg" }, - /* 29*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "1234567+12", "", 0, "ean8_2addon.svg" }, - /* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "1234567+12345", "", 0, "ean8_5addon.svg" }, - /* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "9876543+65", "[91]1234567", 0, "ean8_cc_2addon_cca_4x3.svg" }, - /* 32*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "9876543+74083", "[91]123456789012345678", 0, "ean8_cc_5addon_ccb_8x3.svg" }, - /* 33*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "12345", "", 0, "ean5.svg" }, - /* 34*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "12", "", 0, "ean2.svg" }, - /* 35*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, "123", "", 0, "code39_small.svg" }, - /* 36*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, "12345", "", 0, "postnet_zip.svg" }, - /* 37*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, -1, -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_box2.svg" }, - /* 38*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.svg" }, - /* 39*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, 1, -1, -1, -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "datamatrix_vwsp1_bind1_dotty.svg" }, - /* 40*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "datamatrix_hvwsp1_bind1_dotty.svg" }, - /* 41*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0, "12345678909", "", 0, "dbar_ltd.svg" }, - /* 42*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5, "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.svg" }, - /* 43*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75, "12345678901234567890", "", 0, "imail_height7.75.svg" }, + /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "<>\"&'", "", 0, "code128_amperands.svg" }, + /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold.svg" }, + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold_box3.svg" }, + /* 3*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp2_box2.svg" }, + /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, 3, 3, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold_hvwsp3.svg" }, + /* 5*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, "", "", 0, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", 0, "gs1_128_cc_fig12.svg" }, + /* 6*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, -1, 3, -1, 0, "", "", 0, "AAAAAAAAA", "", 0, "codablockf_3rows.svg" }, + /* 7*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, 3, -1, 0, "", "", 0, "AAAAAAAAA", "", 0, "codablockf_hvwsp2.svg" }, + /* 8*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, "", "", 0, "AAAAAAAAA", "", 0, "codablockf_hvwsp2_box2.svg" }, + /* 9*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "9771384524017+12", "", 0, "ean13_2addon_ggs_5.2.2.5.1-2.svg" }, + /* 10*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "9780877799306+54321", "", 0, "ean13_5addon_ggs_5.2.2.5.2-2.svg" }, + /* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "", 0, "123456789012+12", "[91]123456789012345678901", 0, "ean13_cc_2addon_cca_4x4.svg" }, + /* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "", "", 0, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4.svg" }, + /* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "", "", 0, "123456789012+54321", "[91]1234567890", 0, "ean13_cc_5addon_ccb_3x4_notext.svg" }, + /* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "012345678905+24", "", 0, "upca_2addon_ggs_5.2.6.6-5.svg" }, + /* 15*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "614141234417+12345", "", 0, "upca_5addon.svg" }, + /* 16*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, "", "", 0, "614141234417+12345", "", 0, "upca_5addon_bind3.svg" }, + /* 17*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, -1, 0, "", "", 0, "614141234417+12345", "", 0, "upca_5addon_small_bold.svg" }, + /* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "", 0, "12345678901+12", "[91]123456789", 0, "upca_cc_2addon_cca_3x4.svg" }, + /* 19*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "", "", 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4.svg" }, + /* 20*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "", "", 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_notext.svg" }, + /* 21*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, "", "", 0, "12345678901+12121", "[91]1234567890123", 0, "upca_cc_5addon_ccb_4x4_bind3.svg" }, + /* 22*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "1234567+12", "", 0, "upce_2addon.svg" }, + /* 23*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "1234567+12345", "", 0, "upce_5addon.svg" }, + /* 24*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, "", "", 0, "1234567+12345", "", 0, "upce_5addon_small.svg" }, + /* 25*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, -1, -1, 0, "", "", 0, "1234567+12345", "", 0, "upce_5addon_notext.svg" }, + /* 26*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "", 0, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2.svg" }, + /* 27*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "FF0000EE", "0000FF11", 0, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2_fgbgalpha.svg" }, + /* 28*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "FFFFFF00", 0, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2_nobg.svg" }, + /* 29*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "", 270, "0654321+89", "[91]1", 0, "upce_cc_2addon_cca_5x2_rotate_270.svg" }, + /* 30*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "", "", 0, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2.svg" }, + /* 31*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, "", "", 0, "1876543+56789", "[91]12345", 0, "upce_cc_5addon_ccb_8x2_notext.svg" }, + /* 32*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "1234567+12", "", 0, "ean8_2addon.svg" }, + /* 33*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "1234567+12345", "", 0, "ean8_5addon.svg" }, + /* 34*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, "", "", 0, "9876543+65", "[91]1234567", 0, "ean8_cc_2addon_cca_4x3.svg" }, + /* 35*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, "", "", 0, "9876543+74083", "[91]123456789012345678", 0, "ean8_cc_5addon_ccb_8x3.svg" }, + /* 36*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "12345", "", 0, "ean5.svg" }, + /* 37*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "12", "", 0, "ean2.svg" }, + /* 38*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, "", "", 0, "123", "", 0, "code39_small.svg" }, + /* 39*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "12345", "", 0, "postnet_zip.svg" }, + /* 40*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, -1, -1, 0, "", "", 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_box2.svg" }, + /* 41*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, "", "", 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_vwsp1_bind1.svg" }, + /* 42*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, "121212DD", "EEEEEE22", 90, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "maxicode_fgbg_rotate_90.svg" }, + /* 43*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, 1, -1, -1, -1, 0, "", "", 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "datamatrix_vwsp1_bind1_dotty.svg" }, + /* 44*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, "", "", 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", 0, "datamatrix_hvwsp1_bind1_dotty.svg" }, + /* 45*/ { BARCODE_DBAR_LTD, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "12345678909", "", 0, "dbar_ltd.svg" }, + /* 46*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 5, "", "", 0, "Your Data Here!", "", ZINT_WARN_NONCOMPLIANT, "pdf417_height5.svg" }, + /* 47*/ { BARCODE_USPS_IMAIL, -1, -1, -1, -1, -1, -1, -1, -1, 7.75, "", "", 0, "12345678901234567890", "", 0, "imail_height7.75.svg" }, + /* 48*/ { BARCODE_ULTRA, -1, 3, BARCODE_BOX, 2, 2, -1, -1, -1, 0, "FF0000", "0000FF", 0, "12345678901234567890", "", 0, "ultra_fgbg_hvwsp2_box3.svg" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -149,6 +157,13 @@ static void test_print(int index, int generate, int debug) { if (data[i].whitespace_height != -1) { symbol->whitespace_height = data[i].whitespace_height; } + if (*data[i].fgcolour) { + strcpy(symbol->fgcolour, data[i].fgcolour); + } + if (*data[i].bgcolour) { + strcpy(symbol->bgcolour, data[i].bgcolour); + } + if (strlen(data[i].composite)) { text = data[i].composite; strcpy(symbol->primary, data[i].data); @@ -161,15 +176,16 @@ static void test_print(int index, int generate, int debug) { assert_equal(ret, data[i].ret, "i:%d %s ZBarcode_Encode ret %d != %d (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, data[i].ret, symbol->errtxt); strcpy(symbol->outfile, svg); - ret = ZBarcode_Print(symbol, 0); + ret = ZBarcode_Print(symbol, data[i].rotate_angle); assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.8g, \"%s\", \"%s\", \"%s\" },\n", - i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), - data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.8g, \"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\" },\n", + i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, + testUtilOutputOptionsName(data[i].output_options), data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, + data[i].option_1, data[i].option_2, data[i].height, data[i].fgcolour, data[i].bgcolour, data[i].rotate_angle, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file); ret = testUtilRename(symbol->outfile, expected_file); assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); @@ -196,10 +212,41 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +INTERNAL int svg_plot(struct zint_symbol *symbol, int rotate_angle); + +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + struct zint_vector vector = {0}; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.vector = &vector; + + strcpy(symbol.outfile, "nosuch_dir/out.svg"); + + ret = svg_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = svg_plot(&symbol, 0); + printf(" - ignore (SVG to stdout)\n"); fflush(stdout); + assert_zero(ret, "svg_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + symbol.vector = NULL; + ret = svg_plot(&symbol, 0); + assert_equal(ret, ZINT_ERROR_INVALID_DATA, "svg_plot ret %d != ZINT_ERROR_INVALID_DATA (%d) (%s)\n", ret, ZINT_ERROR_INVALID_DATA, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/test_telepen.c b/backend/tests/test_telepen.c index cab67119..a55fe7fa 100644 --- a/backend/tests/test_telepen.c +++ b/backend/tests/test_telepen.c @@ -222,6 +222,9 @@ static void test_encode(int index, int generate, int debug) { /* 8*/ { BARCODE_TELEPEN_NUM, "1X3X", -1, 0, 1, 80, "Verified manually against tec-it", "10101010101110001110001110001110111010111000111010111010101110001110001010101010" }, + /* 9*/ { BARCODE_TELEPEN_NUM, "3637", -1, 0, 1, 80, "Glyph count 127, check 0; verified manually against tec-it", + "10101010101110001010101010101110111011101110101011101110111011101110001010101010" + }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_tif.c b/backend/tests/test_tif.c index 6036235c..bcfdcd7d 100644 --- a/backend/tests/test_tif.c +++ b/backend/tests/test_tif.c @@ -43,37 +43,38 @@ static void test_pixel_plot(int index, int debug) { char *pattern; int repeat; int no_identify; // identify fails for some valid TIFFs (eg. RGB with LZW and large rows) + int ret; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { 1, 1, "1", 0, 0 }, - /* 1*/ { 2, 1, "11", 0, 0 }, - /* 2*/ { 1, 2, "11", 0, 0 }, - /* 3*/ { 2, 2, "10", 1, 0 }, - /* 4*/ { 3, 1, "101", 0, 0 }, - /* 5*/ { 1, 3, "101", 0, 0 }, - /* 6*/ { 4, 1, "1010", 0, 0 }, - /* 7*/ { 1, 4, "1010", 0, 0 }, - /* 8*/ { 5, 1, "10101", 0, 0 }, - /* 9*/ { 1, 5, "10101", 0, 0 }, - /* 10*/ { 3, 2, "101", 1, 0 }, - /* 11*/ { 100, 2, "10", 1, 0 }, - /* 12*/ { 2, 100, "10", 1, 0 }, - /* 13*/ { 3, 3, "101010101", 0, 0 }, - /* 14*/ { 4, 3, "10", 1, 0 }, - /* 15*/ { 3, 4, "10", 1, 0 }, - /* 16*/ { 45, 44, "10", 1, 0 }, // Strip Count 1, Rows Per Strip 44 (45 * 44 * 4 == 7920) - /* 17*/ { 45, 45, "10", 1, 0 }, // Strip Count 1, Rows Per Strip 45 (45 * 45 * 4 == 8100) - /* 18*/ { 46, 45, "10", 1, 0 }, // Strip Count 2, Rows Per Strip 44 (46 * 45 * 4 == 8280) - /* 19*/ { 46, 46, "10", 1, 0 }, // Strip Count 2, Rows Per Strip 44 - /* 20*/ { 2048, 1, "10", 1, 1 }, // Strip Count 1, Rows Per Strip 1 (2048 * 4 == 8192) - /* 21*/ { 1, 2048, "10", 1, 0 }, // Strip Count 1, Rows Per Strip 2048 - /* 22*/ { 2048, 2, "10", 1, 1 }, // Strip Count 2, Rows Per Strip 1 - /* 23*/ { 2, 2048, "10", 1, 0 }, // Strip Count 2, Rows Per Strip 1024 (2 * 1024 * 4 == 8192) - /* 24*/ { 2048, 3, "10", 1, 1 }, // Strip Count 3, Rows Per Strip 1 - /* 25*/ { 3, 2048, "10", 1, 0 }, // Strip Count 4, Rows Per Strip 682 ((3 * 682 + 2) * 4 == 8192) - /* 26*/ { 2049, 4, "10", 1, 1 }, // Strip Count 4, Rows Per Strip 1 (2049 * 1 * 4 == 8196) - large rows in 1 strip, even if > 8192 - /* 27*/ { 4, 2049, "10", 1, 0 }, // Strip Count 5, Rows Per Strip 512 ((4 * 512 + 1) * 4 == 8196) + /* 0*/ { 1, 1, "1", 0, 0, 0 }, + /* 1*/ { 2, 1, "11", 0, 0, 0 }, + /* 2*/ { 1, 2, "11", 0, 0, 0 }, + /* 3*/ { 2, 2, "10", 1, 0, 0 }, + /* 4*/ { 3, 1, "101", 0, 0, 0 }, + /* 5*/ { 1, 3, "101", 0, 0, 0 }, + /* 6*/ { 4, 1, "1010", 0, 0, 0 }, + /* 7*/ { 1, 4, "1010", 0, 0, 0 }, + /* 8*/ { 5, 1, "10101", 0, 0, 0 }, + /* 9*/ { 1, 5, "10101", 0, 0, 0 }, + /* 10*/ { 3, 2, "101", 1, 0, 0 }, + /* 11*/ { 100, 2, "10", 1, 0, 0 }, + /* 12*/ { 2, 100, "10", 1, 0, 0 }, + /* 13*/ { 3, 3, "101010101", 0, 0, 0 }, + /* 14*/ { 4, 3, "10", 1, 0, 0 }, + /* 15*/ { 3, 4, "10", 1, 0, 0 }, + /* 16*/ { 45, 44, "10", 1, 0, 0 }, // Strip Count 1, Rows Per Strip 44 (45 * 44 * 4 == 7920) + /* 17*/ { 45, 45, "10", 1, 0, 0 }, // Strip Count 1, Rows Per Strip 45 (45 * 45 * 4 == 8100) + /* 18*/ { 46, 45, "10", 1, 0, 0 }, // Strip Count 2, Rows Per Strip 44 (46 * 45 * 4 == 8280) + /* 19*/ { 46, 46, "10", 1, 0, 0 }, // Strip Count 2, Rows Per Strip 44 + /* 20*/ { 2048, 1, "10", 1, 1, 0 }, // Strip Count 1, Rows Per Strip 1 (2048 * 4 == 8192) + /* 21*/ { 1, 2048, "10", 1, 0, 0 }, // Strip Count 1, Rows Per Strip 2048 + /* 22*/ { 2048, 2, "10", 1, 1, 0 }, // Strip Count 2, Rows Per Strip 1 + /* 23*/ { 2, 2048, "10", 1, 0, 0 }, // Strip Count 2, Rows Per Strip 1024 (2 * 1024 * 4 == 8192) + /* 24*/ { 2048, 3, "10", 1, 1, 0 }, // Strip Count 3, Rows Per Strip 1 + /* 25*/ { 3, 2048, "10", 1, 0, 0 }, // Strip Count 4, Rows Per Strip 682 ((3 * 682 + 2) * 4 == 8192) + /* 26*/ { 2049, 4, "10", 1, 1, 0 }, // Strip Count 4, Rows Per Strip 1 (2049 * 1 * 4 == 8196) - large rows in 1 strip, even if > 8192 + /* 27*/ { 4, 2049, "10", 1, 0, 0 }, // Strip Count 5, Rows Per Strip 512 ((4 * 512 + 1) * 4 == 8196) }; int data_size = ARRAY_SIZE(data); int i, ret; @@ -117,18 +118,24 @@ static void test_pixel_plot(int index, int debug) { symbol->bitmap = (unsigned char *) data_buf; ret = tif_pixel_plot(symbol, (unsigned char *) data_buf); - assert_zero(ret, "i:%d tif_pixel_plot ret %d != 0 (%s)\n", i, ret, symbol->errtxt); + assert_equal(ret, data[i].ret, "i:%d tif_pixel_plot ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - if (have_tiffinfo) { - ret = testUtilVerifyTiffInfo(symbol->outfile, debug); - assert_zero(ret, "i:%d tiffinfo %s ret %d != 0\n", i, symbol->outfile, ret); - } else if (have_identify && !data[i].no_identify) { - ret = testUtilVerifyIdentify(symbol->outfile, debug); - assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); - } + if (ret < ZINT_ERROR) { + if (have_tiffinfo) { + ret = testUtilVerifyTiffInfo(symbol->outfile, debug); + assert_zero(ret, "i:%d tiffinfo %s ret %d != 0\n", i, symbol->outfile, ret); + } else if (have_identify && !data[i].no_identify) { + ret = testUtilVerifyIdentify(symbol->outfile, debug); + assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret); + } - if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { - assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); + } + } else { + if (!(debug & ZINT_DEBUG_TEST_KEEP_OUTFILE)) { + (void) remove(symbol->outfile); + } } symbol->bitmap = NULL; @@ -147,6 +154,7 @@ static void test_print(int index, int generate, int debug) { int border_width; int output_options; int whitespace_width; + int whitespace_height; int show_hrt; int option_1; int option_2; @@ -160,22 +168,27 @@ static void test_print(int index, int generate, int debug) { char *comment; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" }, - /* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "A", "", "code128_bgalpha.tif", "" }, - /* 2*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBA", "A", "", "code128_fgalpha.tif", "" }, - /* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" }, - /* 4*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" }, - /* 5*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" }, - /* 6*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" }, - /* 7*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" }, - /* 8*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" }, - /* 9*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" }, - /* 10*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" }, - /* 11*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" }, - /* 12*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" }, - /* 13*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" }, - /* 14*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, "", "", "F", "", "daft_height8_scale0.5.tif", "" }, - /* 15*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" }, + /* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" }, + /* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "FFFFFF", "000000", "A", "", "code128_reverse.tif", "" }, + /* 2*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "112233", "CCDDEE", "A", "", "code128_cmyk_fgbg.tif", "" }, + /* 3*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "A", "", "code128_bgalpha.tif", "" }, + /* 4*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBA", "A", "", "code128_fgalpha.tif", "" }, + /* 5*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "00000099", "FEDCBACC", "A", "", "code128_fgbgalpha.tif", "" }, + /* 6*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBA", "A", "", "code128_cmyk.tif", "" }, + /* 7*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C0000099", "FEDCBACC", "A", "", "code128_cmyk_fgbgalpha.tif", "" }, + /* 8*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_bgalpha.tif", "" }, + /* 9*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "C00000", "FEDCBACC", "1234", "", "ultra_cmyk_bgalpha.tif", "" }, + /* 10*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBA", "1234", "", "ultra_fgalpha.tif", "" }, + /* 11*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "FEDCBACC", "1234", "", "ultra_fgbgalpha.tif", "" }, + /* 12*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "000000BB", "", "1234", "", "ultra_fgalpha_nobg.tif", "" }, + /* 13*/ { BARCODE_ULTRA, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "", "FEDCBACC", "1234", "", "ultra_bgalpha_nofg.tif", "" }, + /* 14*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "ultra_odd.tif", "" }, + /* 15*/ { BARCODE_ULTRA, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "", "", "1234", "", "ultra_cmyk.tif", "" }, + /* 16*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "FF0000", "0000FF", "1234", "", "ultra_fgbg_hvwsp1_box1.tif", "" }, + /* 17*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1, -1, -1, -1, 4, 84, 0, 2, "", "", "1", "", "hanxin_v84_l4_scale2.tif", "" }, + /* 18*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, -1, 32, 0, 0, "4BE055", "", "1", "", "aztec_v32_fg.tif", "" }, + /* 19*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0.5f, "", "", "F", "", "daft_height8_scale0.5.tif", "" }, + /* 20*/ { BARCODE_DAFT, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0.5f, "", "", "DAFT", "", "daft_height1_scale0.5.tif", "" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -226,6 +239,9 @@ static void test_print(int index, int generate, int debug) { if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (*data[i].fgcolour) { strcpy(symbol->fgcolour, data[i].fgcolour); } @@ -250,9 +266,10 @@ static void test_print(int index, int generate, int debug) { assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i); if (generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), - data[i].whitespace_width, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, + data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, + data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment); ret = testUtilRename(symbol->outfile, expected_file); assert_zero(ret, "i:%d testUtilRename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); @@ -278,11 +295,37 @@ static void test_print(int index, int generate, int debug) { testFinish(); } +static void test_outfile(void) { + int ret; + struct zint_symbol symbol = {0}; + unsigned char data[] = { "1" }; + + testStart("test_outfile"); + + symbol.symbology = BARCODE_CODE128; + symbol.bitmap = data; + symbol.bitmap_width = symbol.bitmap_height = 1; + + strcpy(symbol.outfile, "nosuch_dir/out.tif"); + + ret = tif_pixel_plot(&symbol, data); + assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt); + + symbol.output_options |= BARCODE_STDOUT; + + ret = tif_pixel_plot(&symbol, data); + printf(" - ignore (TIF to stdout)\n"); fflush(stdout); + assert_zero(ret, "tif_pixel_plot ret %d != 0 (%s)\n", ret, symbol.errtxt); + + testFinish(); +} + int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */ { "test_pixel_plot", test_pixel_plot, 1, 0, 1 }, { "test_print", test_print, 1, 1, 1 }, + { "test_outfile", test_outfile, 0, 0, 0 }, }; testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 4ecf1892..29726992 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -828,15 +828,18 @@ int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b) if (a->whitespace_width != b->whitespace_width) { return 6; } - if (a->border_width != b->border_width) { + if (a->whitespace_height != b->whitespace_height) { return 7; } - if (a->output_options != b->output_options) { + if (a->border_width != b->border_width) { return 8; } - if (a->scale != b->scale) { + if (a->output_options != b->output_options) { return 9; } + if (a->scale != b->scale) { + return 10; + } return 0; } @@ -1051,7 +1054,7 @@ int testUtilVectorCmp(const struct zint_vector *a, const struct zint_vector *b) return 0; } -/* Dump modules into buffer as '0'/'1' (or colours 'W', 'C', 'B' etc if Ultra) */ +/* Dump modules into buffer as '0'/'1' (or colours '0', '1', '2' etc if Ultra) */ int testUtilModulesDump(const struct zint_symbol *symbol, char dump[], int dump_size) { int r, w; char *d = dump; @@ -2107,7 +2110,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol { "itf14", BARCODE_ITF14, 89, 0, 0, 0, 0, 0, }, { "kix", BARCODE_KIX, 90, 0, 0, 0, 0, 0, }, { "", -1, 91, 0, 0, 0, 0, 0, }, - { "azteccode", BARCODE_AZTEC, 92, 0, 1, 0, 0, 0, }, + { "azteccode", BARCODE_AZTEC, 92, 1, 1, 0, 0, 0, }, { "daft", BARCODE_DAFT, 93, 0, 0, 0, 0, 0, }, { "", -1, 94, 0, 0, 0, 0, 0, }, { "", -1, 95, 0, 0, 0, 0, 0, }, @@ -2207,6 +2210,14 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol } return NULL; } + } else if (symbology == BARCODE_AZTEC) { + if (option_1 > 0 && option_2 > 0) { + if (debug & ZINT_DEBUG_TEST_PRINT) { + printf("i:%d %s not BWIPP compatible, cannot specify both option_1 %d and option_2 %d\n", + index, testUtilBarcodeName(symbology), option_1, option_2); + } + return NULL; + } } if (linear_row_height) { diff --git a/backend/tif.c b/backend/tif.c index 899383c8..9d099ff1 100644 --- a/backend/tif.c +++ b/backend/tif.c @@ -108,6 +108,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) int compression = TIF_NO_COMPRESSION; tif_lzw_state lzw_state; long file_pos; + const int output_to_stdout = symbol->output_options & BARCODE_STDOUT; #ifdef _MSC_VER uint32_t* strip_offset; uint32_t* strip_bytes; @@ -229,8 +230,8 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) pixels_per_sample = 8; } else if (bg[0] == 0 && bg[1] == 0 && bg[2] == 0 && bg[3] == 0xff && fg[0] == 0xff && fg[1] == 0xff && fg[2] == 0xff && fg[3] == 0xff) { - map['0'] = 1; - map['1'] = 0; + map['0'] = 0; + map['1'] = 1; pmi = TIF_PMI_BLACKISZERO; bits_per_sample = 1; @@ -313,7 +314,8 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) strip_bytes[i] = bytes_per_strip; } else { if (rows_last_strip) { - strip_bytes[i] = rows_last_strip * ((symbol->bitmap_width + pixels_per_sample - 1) / pixels_per_sample) + strip_bytes[i] = rows_last_strip + * ((symbol->bitmap_width + pixels_per_sample - 1) / pixels_per_sample) * samples_per_pixel; } else { strip_bytes[i] = bytes_per_strip; @@ -331,17 +333,17 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) } /* Open output file in binary mode */ - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { - sprintf(symbol->errtxt, "671: Can't open output file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "671: Could not set stdout to binary (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } #endif tif_file = stdout; } else { - if (!(tif_file = fopen(symbol->outfile, "wb+"))) { - sprintf(symbol->errtxt, "672: Can't open output file (%d: %.30s)", errno, strerror(errno)); + if (!(tif_file = fopen(symbol->outfile, "wb+"))) { /* '+' as use fseek/ftell() */ + sprintf(symbol->errtxt, "672: Could not open output file (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_ACCESS; } compression = TIF_LZW; @@ -607,7 +609,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf) total_bytes_put += 6 * color_map_size; } - if (symbol->output_options & BARCODE_STDOUT) { + if (output_to_stdout) { fflush(tif_file); } else { if (ftell(tif_file) != total_bytes_put) { diff --git a/backend/vector.c b/backend/vector.c index 8c21074b..1c064859 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -63,7 +63,7 @@ static struct zint_vector_rect *vector_plot_create_rect(float x, float y, float static int vector_plot_add_rect(struct zint_symbol *symbol, struct zint_vector_rect *rect, struct zint_vector_rect **last_rect) { - if (!rect) return ZINT_ERROR_MEMORY; + if (!rect) return 0; if (*last_rect) (*last_rect)->next = rect; else @@ -89,7 +89,7 @@ static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y, static int vector_plot_add_hexagon(struct zint_symbol *symbol, struct zint_vector_hexagon *hexagon, struct zint_vector_hexagon **last_hexagon) { - if (!hexagon) return ZINT_ERROR_MEMORY; + if (!hexagon) return 0; if (*last_hexagon) (*last_hexagon)->next = hexagon; else @@ -115,7 +115,7 @@ static struct zint_vector_circle *vector_plot_create_circle(float x, float y, fl static int vector_plot_add_circle(struct zint_symbol *symbol, struct zint_vector_circle *circle, struct zint_vector_circle **last_circle) { - if (!circle) return ZINT_ERROR_MEMORY; + if (!circle) return 0; if (*last_circle) (*last_circle)->next = circle; else @@ -272,12 +272,10 @@ static void vector_rotate(struct zint_symbol *symbol, int rotate_angle) { temp = rect->width; rect->width = rect->height; rect->height = temp; - } - if (rotate_angle == 180) { + } else if (rotate_angle == 180) { rect->x = symbol->vector->width - (rect->x + rect->width); rect->y = symbol->vector->height - (rect->y + rect->height); - } - if (rotate_angle == 270) { + } else if (rotate_angle == 270) { temp = rect->x; rect->x = rect->y; rect->y = symbol->vector->width - (temp + rect->width); @@ -295,13 +293,11 @@ static void vector_rotate(struct zint_symbol *symbol, int rotate_angle) { hex->x = symbol->vector->height - hex->y; hex->y = temp; hex->rotation = 90; - } - if (rotate_angle == 180) { + } else if (rotate_angle == 180) { hex->x = symbol->vector->width - hex->x; hex->y = symbol->vector->height - hex->y; hex->rotation = 180; - } - if (rotate_angle == 270) { + } else if (rotate_angle == 270) { temp = hex->x; hex->x = hex->y; hex->y = symbol->vector->width - temp; @@ -316,12 +312,10 @@ static void vector_rotate(struct zint_symbol *symbol, int rotate_angle) { temp = circle->x; circle->x = symbol->vector->height - circle->y; circle->y = temp; - } - if (rotate_angle == 180) { + } else if (rotate_angle == 180) { circle->x = symbol->vector->width - circle->x; circle->y = symbol->vector->height - circle->y; - } - if (rotate_angle == 270) { + } else if (rotate_angle == 270) { temp = circle->x; circle->x = circle->y; circle->y = symbol->vector->width - temp; @@ -336,13 +330,11 @@ static void vector_rotate(struct zint_symbol *symbol, int rotate_angle) { string->x = symbol->vector->height - string->y; string->y = temp; string->rotation = 90; - } - if (rotate_angle == 180) { + } else if (rotate_angle == 180) { string->x = symbol->vector->width - string->x; string->y = symbol->vector->height - string->y; string->rotation = 180; - } - if (rotate_angle == 270) { + } else if (rotate_angle == 270) { temp = string->x; string->x = string->y; string->y = symbol->vector->width - temp; diff --git a/backend/zint.h b/backend/zint.h index 6a252edc..3ba8b62b 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -44,7 +44,7 @@ extern "C" { struct zint_vector_rect { float x, y, height, width; int colour; /* -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White */ - struct zint_vector_rect *next; + struct zint_vector_rect *next; /* Pointer to next rectangle */ }; struct zint_vector_hexagon { @@ -86,11 +86,11 @@ extern "C" { int whitespace_height; /* Height in X-dimensions of whitespace above & below the barcode */ int border_width; /* Size of border in X-dimensions */ int output_options; /* Various output parameters (bind, box etc, see below) */ - char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters */ - char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string, 6 or 8 characters */ + char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated */ + char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated */ char *fgcolor; /* Pointer to fgcolour (alternate spelling) */ char *bgcolor; /* Pointer to bgcolour (alternate spelling) */ - char outfile[256]; /* Name of file to output to. Default "out.png" ("out.gif" if NO_PNG) */ + char outfile[256]; /* Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if NO_PNG) */ float scale; /* Scale factor when printing barcode */ int option_1; /* Symbol-specific options (see "../docs/manual.txt") */ int option_2; /* Symbol-specific options */ @@ -99,13 +99,13 @@ extern "C" { int fontsize; /* Unused */ int input_mode; /* Encoding of input data (see DATA_MODE etc below). Default DATA_MODE */ int eci; /* Extended Channel Interpretation. Default 0 (none) */ - unsigned char text[128]; /* Human Readable Text (if any), UTF-8 */ + unsigned char text[128]; /* Human Readable Text (if any), UTF-8, NUL-terminated (output only) */ int rows; /* Number of rows used by the symbol (output only) */ int width; /* Width of the generated symbol (output only) */ - char primary[128]; /* Primary message data (MaxiCode, Composite) */ + char primary[128]; /* Primary message data (MaxiCode, Composite), NUL-terminated */ unsigned char encoded_data[200][143]; /* Encoded data (output only). Allows for rows of 1144 modules */ float row_height[200]; /* Heights of rows (output only). Allows for 200 row DotCode */ - char errtxt[100]; /* Error message if an error or warning occurs (output only) */ + char errtxt[100]; /* Error message if an error or warning occurs, NUL-terminated (output only) */ unsigned char *bitmap; /* Stored bitmap image (raster output only) */ int bitmap_width; /* Width of bitmap image (raster output only) */ int bitmap_height; /* Height of bitmap image (raster output only) */ diff --git a/docs/manual.txt b/docs/manual.txt index eaf20315..311b527a 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -446,8 +446,8 @@ command zint -r -d "This" gives an inverted Code 128 symbol. This is not practical for most symbologies -but white-on-black is allowed by the Data Matrix and Aztec Code -symbology specifications. +but white-on-black is allowed by the Data Matrix and Aztec Code symbology +specifications. For more specific needs the foreground (ink) and background (paper) colours can be specified using the --fg= and --bg= options followed by a number in RRGGBB @@ -458,7 +458,7 @@ zint --fg=004700 -d "This" alters the symbol to a dark green. Zint also supports RGBA colour information for some output file formats which -support alpha channels (currently only PNG and SVG) in a RRGGBBAA format. +support alpha channels (currently only PNG, TIF and SVG) in a RRGGBBAA format. For example: zint --fg=00ff0055 -d "This" @@ -473,7 +473,7 @@ will give different results for PNG and SVG. Experimentation is advised! Also note that these options don't work properly with MaxiCode yet. In addition the --nobackground option will simply remove the background from -PNG, GIF, SVG, EMF and EPS files. +PNG, GIF, TIF, SVG, EMF and EPS files. 4.8 Rotating the Symbol ----------------------- @@ -736,11 +736,11 @@ Input | Filenames Generated 4.12 Direct output ------------------ -The finished image files can be output directly to stdout for use as part of -a pipe by using the --direct option. By default --direct will output data -as a PNG image, but this can be altered by supplementing the --direct option -with a --filetype= option followed by the suffix of the file type required. -For example: +The finished image files can be output directly to stdout for use as part of a +pipe by using the --direct option. By default --direct will output data as a PNG +image (or GIF image if libpng is not present), but this can be altered by +supplementing the --direct option with a --filetype= option followed by the +suffix of the file type required. For example: zint -b 84 --direct --filetype=pcx -d "Data to encode" @@ -1081,6 +1081,8 @@ outfile | character | Contains the name of the | "out.png" | | Must end in .png, .gif, | | | .bmp, .emf, .eps, .pcx, | | | .svg, .tif or .txt | + | | followed by a terminat- | + | | ing \0. | scale | float | Scale factor for adjusting | 1.0 | | size of image. | option_1 | integer | Symbol specific options. | -1 @@ -1095,9 +1097,11 @@ text | unsigned | Human Readable Text, which | "" (empty) | character | usually consists of in- | | string | put data plus one more | | | check digit. Uses UTF-8 | - | | formatting. | + | | formatting, with a | + | | terminating \0. | primary | character | Primary message data for | "" (empty) - | string | more complex symbols. | + | string | more complex symbols, | + | | with a terminating \0. | dot_size | float | Size of dots used in dotty | 4.0 / 5.0 | | mode. | rows | integer | Number of rows used by the | (output only) @@ -1105,12 +1109,14 @@ rows | integer | Number of rows used by the | (output only) width | integer | Width of the generated sym- | (output only) | | bol. | encoding_data | array of | Representation of the | (output only) - | character | encoded data. | - | strings | | + | unsigned | encoded data. | + | character | | + | arrays | | row_height | array of | Representation of the | (output only) | floats | height of a row. | errtxt | character | Error message in the event | (output only) - | string | that an error occurred. | + | string | that an error occurred, | + | | with a terminating \0. | bitmap | pointer to | Pointer to stored bitmap | (output only) | unsigned | image. | | character | | @@ -1153,7 +1159,7 @@ int main(int argc, char **argv) return 0; } -Background removal for PNG, GIF, SVG, EMF and EPS files can be achieved by +Background removal for PNG, GIF, TIF, SVG, EMF and EPS files can be achieved by setting the background alpha to "00" where the values for R, G and B will be ignored: @@ -1376,7 +1382,7 @@ and will continue to be supported in future versions. 5.9 Adjusting other output options ---------------------------------- The output_options variable can be used to adjust various aspects of the output -file. To select more than one option from the table below simply or them +file. To select more than one option from the table below simply OR them together when adjusting this value: my_symbol->output_options |= BARCODE_BIND | READER_INIT; @@ -1413,7 +1419,7 @@ property. Valid values are shown in the table below. ------------------------------------------------------------------------------- Value | Effect ------------------------------------------------------------------------------- -DATA_MODE | Uses full ASCII range interpreted as Latin-1 or binary data. +DATA_MODE | Uses full 8-bit range interpreted as Latin-1 or binary data. UNICODE_MODE | Uses pre-formatted UTF-8 input. GS1_MODE | Encodes GS1 data using FNC1 characters. ----------------|-------------------------------------------------------------- @@ -1475,7 +1481,7 @@ This can be determined using another additional function: unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag); -by oring the flags below in the "cap_flag" argument and checking the return to +by OR-ing the flags below in the "cap_flag" argument and checking the return to see which are set. ------------------------------------------------------------------------------- @@ -2789,7 +2795,7 @@ to a maximum of approximately 450 characters (or 900 numeric digits). The symbology supports ECI encoding and GS1 data encoding. By default Zint will produce a symbol which is approximately square, however the width of the symbol can be adjusted by using the --cols= option or by setting option_2 (maximum -200). Outputting DotCode to raster images (PNG, GIF, BMP, PCX) will require +200). Outputting DotCode to raster images (PNG, GIF, BMP, PCX, TIF) will require setting the scale of the image to a larger value than the default (e.g. approx 10) for the dots to be plotted correctly. Approximately 33% of the resulting symbol is comprised of error correction codewords. @@ -2804,7 +2810,7 @@ to (N + 1) << 8 where N is 0-7. ------------------- Also known as Chinese Sensible Code, Han Xin is a symbology which is still under development, so it is recommended it should not yet be used for a production -environment. The symbology is capable of encoding characters in the GB18030 +environment. The symbology is capable of encoding characters in the GB 18030 character set (up to 4-byte characters) and is also able to support the ECI mechanism. Support for the encoding of GS1 data has not yet been implemented. @@ -3145,8 +3151,8 @@ F | SI | US | / | ? | O | _ | o | DEL A.2 Latin Alphabet No 1 (ISO/IEC 8859-1) ---------------------------------------- A common extension to the ASCII standard, Latin-1 is used to expand the range -of Code 128, PDF417 and other symbols. Input strings should be in Unicode -(UTF-8) format +of Code 128, PDF417 and other symbols. Input strings to the CLI should be in +Unicode (UTF-8) format, unless the --binary switch is given. ------------------------------------------------------ Hex | 8 | 9 | A | B | C | D | E | F @@ -3168,4 +3174,3 @@ D | | | SHY | ½ | Í | Ý | í | ý E | | | ® | ¾ | Î | Þ | î | þ F | | | ¯ | ¿ | Ï | ß | ï | ÿ ------------------------------------------------------ - diff --git a/frontend/tests/CMakeLists.txt b/frontend/tests/CMakeLists.txt index 27acf20e..bd907a47 100644 --- a/frontend/tests/CMakeLists.txt +++ b/frontend/tests/CMakeLists.txt @@ -3,7 +3,7 @@ # Copyright (C) 2006-2017 Kentaro Fukuchi # vim: set ts=4 sw=4 et : -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.5) project(zint_frontend_tests) enable_testing() diff --git a/win32/README b/win32/README index 7863cab3..eda28bd2 100644 --- a/win32/README +++ b/win32/README @@ -167,6 +167,9 @@ Administrator privileges) is to create two sub-directories in "zlib\zlib.lib" and "lpng\build\Release\libpng16_static.lib" into "lib". +You may need to rename "libpng16_static.lib" to "libpng.lib" depending on the +version of cmake you have. + This example uses Qt 5.15.2 and component "MSVC 2019 32-bit" so install them and add to path (your path may differ):