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 7275fd6f..c204e252 100644 Binary files a/backend/tests/data/bmp/ultracode_fg_bg.bmp and b/backend/tests/data/bmp/ultracode_fg_bg.bmp differ diff --git a/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp b/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp new file mode 100644 index 00000000..e8eca02a Binary files /dev/null and b/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp differ diff --git a/backend/tests/data/emf/code128_egrave_bold.emf b/backend/tests/data/emf/code128_egrave_bold.emf index 1979555b..d27b9309 100644 Binary files a/backend/tests/data/emf/code128_egrave_bold.emf and b/backend/tests/data/emf/code128_egrave_bold.emf differ diff --git a/backend/tests/data/emf/code39_rotate_180.emf b/backend/tests/data/emf/code39_rotate_180.emf index 5f208be1..ed0b8bae 100644 Binary files a/backend/tests/data/emf/code39_rotate_180.emf and b/backend/tests/data/emf/code39_rotate_180.emf differ diff --git a/backend/tests/data/emf/code39_rotate_270.emf b/backend/tests/data/emf/code39_rotate_270.emf index a474087f..7e416a7e 100644 Binary files a/backend/tests/data/emf/code39_rotate_270.emf and b/backend/tests/data/emf/code39_rotate_270.emf differ diff --git a/backend/tests/data/emf/code39_rotate_90.emf b/backend/tests/data/emf/code39_rotate_90.emf index a735b78c..6e3bcf03 100644 Binary files a/backend/tests/data/emf/code39_rotate_90.emf and b/backend/tests/data/emf/code39_rotate_90.emf differ diff --git a/backend/tests/data/emf/ean13_5addon_#185.emf b/backend/tests/data/emf/ean13_5addon_#185.emf index 2898e104..27ad3a1c 100644 Binary files a/backend/tests/data/emf/ean13_5addon_#185.emf and b/backend/tests/data/emf/ean13_5addon_#185.emf differ diff --git a/backend/tests/data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf b/backend/tests/data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf index 78bbb49c..ca4d94ae 100644 Binary files a/backend/tests/data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf and b/backend/tests/data/emf/ean13_5addon_ggs_5.2.2.5.2-2.emf differ diff --git a/backend/tests/data/emf/itf14_bold.emf b/backend/tests/data/emf/itf14_bold.emf index 32ea1e85..5bf28f86 100644 Binary files a/backend/tests/data/emf/itf14_bold.emf and b/backend/tests/data/emf/itf14_bold.emf differ diff --git a/backend/tests/data/emf/maxicode_#185.emf b/backend/tests/data/emf/maxicode_#185.emf index 4c2c5a1e..000f1254 100644 Binary files a/backend/tests/data/emf/maxicode_#185.emf and b/backend/tests/data/emf/maxicode_#185.emf differ diff --git a/backend/tests/data/emf/maxicode_rotate_90_nobg.emf b/backend/tests/data/emf/maxicode_rotate_90_nobg.emf new file mode 100644 index 00000000..b2ba16e9 Binary files /dev/null and b/backend/tests/data/emf/maxicode_rotate_90_nobg.emf differ diff --git a/backend/tests/data/emf/telenum_fg_bg.emf b/backend/tests/data/emf/telenum_fg_bg.emf index f9c78727..10d2991b 100644 Binary files a/backend/tests/data/emf/telenum_fg_bg.emf and b/backend/tests/data/emf/telenum_fg_bg.emf differ diff --git a/backend/tests/data/emf/ultracode_fg_bg.emf b/backend/tests/data/emf/ultracode_fg_bg.emf index 8f9da669..8cf5d473 100644 Binary files a/backend/tests/data/emf/ultracode_fg_bg.emf and b/backend/tests/data/emf/ultracode_fg_bg.emf differ diff --git a/backend/tests/data/emf/ultracode_fg_bg_box2.emf b/backend/tests/data/emf/ultracode_fg_bg_box2.emf new file mode 100644 index 00000000..915704f9 Binary files /dev/null and b/backend/tests/data/emf/ultracode_fg_bg_box2.emf differ 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 9d29c327..9ba4b41b 100644 Binary files a/backend/tests/data/emf/upca_2addon_ggs_5.2.6.6-5.emf and b/backend/tests/data/emf/upca_2addon_ggs_5.2.6.6-5.emf differ diff --git a/backend/tests/data/emf/upce_2addon.emf b/backend/tests/data/emf/upce_2addon.emf index 73848cea..23a1fd89 100644 Binary files a/backend/tests/data/emf/upce_2addon.emf and b/backend/tests/data/emf/upce_2addon.emf differ diff --git a/backend/tests/data/emf/upce_2addon_small_bold.emf b/backend/tests/data/emf/upce_2addon_small_bold.emf index b9e69908..c1100b74 100644 Binary files a/backend/tests/data/emf/upce_2addon_small_bold.emf and b/backend/tests/data/emf/upce_2addon_small_bold.emf differ 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 00000000..dedd7d88 Binary files /dev/null and b/backend/tests/data/gif/dotcode_bgfgalpha.gif differ diff --git a/backend/tests/data/gif/dotcode_bgfgtrans.gif b/backend/tests/data/gif/dotcode_bgfgtrans.gif new file mode 100644 index 00000000..4eb4f5c9 Binary files /dev/null and b/backend/tests/data/gif/dotcode_bgfgtrans.gif differ 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 00000000..25036164 Binary files /dev/null and b/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif differ diff --git a/backend/tests/data/pcx/codeblockf_reverse.pcx b/backend/tests/data/pcx/codeblockf_reverse.pcx new file mode 100644 index 00000000..d3c29da4 Binary files /dev/null and b/backend/tests/data/pcx/codeblockf_reverse.pcx differ diff --git a/backend/tests/data/pcx/gridmatrix_fg_0.75.pcx b/backend/tests/data/pcx/gridmatrix_fg_0.75.pcx new file mode 100644 index 00000000..165753db Binary files /dev/null and b/backend/tests/data/pcx/gridmatrix_fg_0.75.pcx differ diff --git a/backend/tests/data/pcx/qr_bg.pcx b/backend/tests/data/pcx/qr_bg.pcx new file mode 100644 index 00000000..69fc1ef2 Binary files /dev/null and b/backend/tests/data/pcx/qr_bg.pcx differ diff --git a/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx b/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx new file mode 100644 index 00000000..060a6de6 Binary files /dev/null and b/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx differ diff --git a/backend/tests/data/png/aztec.png b/backend/tests/data/png/aztec.png new file mode 100644 index 00000000..5507506f Binary files /dev/null and b/backend/tests/data/png/aztec.png differ diff --git a/backend/tests/data/png/ultra_hvwsp1_box1.png b/backend/tests/data/png/ultra_hvwsp1_box1.png new file mode 100644 index 00000000..cfa074f7 Binary files /dev/null and b/backend/tests/data/png/ultra_hvwsp1_box1.png differ diff --git a/backend/tests/data/print/emf/code128_aim.emf b/backend/tests/data/print/emf/code128_aim.emf index 8ea27995..48060f3e 100644 Binary files a/backend/tests/data/print/emf/code128_aim.emf and b/backend/tests/data/print/emf/code128_aim.emf differ diff --git a/backend/tests/data/print/emf/dotcode_aim_fig7.emf b/backend/tests/data/print/emf/dotcode_aim_fig7.emf index 42b87b01..73c1d70e 100644 Binary files a/backend/tests/data/print/emf/dotcode_aim_fig7.emf and b/backend/tests/data/print/emf/dotcode_aim_fig7.emf differ diff --git a/backend/tests/data/print/emf/maxicode_fig_2.emf b/backend/tests/data/print/emf/maxicode_fig_2.emf index db5bb7b8..56405975 100644 Binary files a/backend/tests/data/print/emf/maxicode_fig_2.emf and b/backend/tests/data/print/emf/maxicode_fig_2.emf differ diff --git a/backend/tests/data/print/emf/qr_v1_m.emf b/backend/tests/data/print/emf/qr_v1_m.emf index 069c0641..1fb8e5ec 100644 Binary files a/backend/tests/data/print/emf/qr_v1_m.emf and b/backend/tests/data/print/emf/qr_v1_m.emf differ diff --git a/backend/tests/data/print/emf/ultracode_a.emf b/backend/tests/data/print/emf/ultracode_a.emf index 9cc2caa1..7d7c28c4 100644 Binary files a/backend/tests/data/print/emf/ultracode_a.emf and b/backend/tests/data/print/emf/ultracode_a.emf differ 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 00000000..09beab60 Binary files /dev/null and b/backend/tests/data/tif/code128_cmyk_fgbg.tif differ diff --git a/backend/tests/data/tif/code128_reverse.tif b/backend/tests/data/tif/code128_reverse.tif new file mode 100644 index 00000000..3d4f0393 Binary files /dev/null and b/backend/tests/data/tif/code128_reverse.tif differ diff --git a/backend/tests/data/tif/ultra_cmyk.tif b/backend/tests/data/tif/ultra_cmyk.tif new file mode 100644 index 00000000..83fef86a Binary files /dev/null and b/backend/tests/data/tif/ultra_cmyk.tif differ diff --git a/backend/tests/data/tif/ultra_cmyk_bgalpha.tif b/backend/tests/data/tif/ultra_cmyk_bgalpha.tif new file mode 100644 index 00000000..a0e4b586 Binary files /dev/null and b/backend/tests/data/tif/ultra_cmyk_bgalpha.tif differ 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 00000000..c2d02c46 Binary files /dev/null and b/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif differ diff --git a/backend/tests/test_aztec.c b/backend/tests/test_aztec.c index 7c494042..973e21ee 100644 --- a/backend/tests/test_aztec.c +++ b/backend/tests/test_aztec.c @@ -48,17 +48,22 @@ static void test_options(int index, int debug) { // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { /* 0*/ { BARCODE_AZTEC, -1, -1, -1, -1, "1234567890", 0, 15, 15 }, - /* 1*/ { BARCODE_AZTEC, -1, -1, 4, -1, "1234567890", 0, 19, 19 }, - /* 2*/ { BARCODE_AZTEC, -1, -1, 5, -1, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15 }, - /* 3*/ { BARCODE_AZTEC, -1, -1, -1, 36, "1234567890", 0, 151, 151 }, - /* 4*/ { BARCODE_AZTEC, -1, -1, -1, 37, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 }, - /* 5*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1 }, - /* 6*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, "[91]A", 0, 15, 15 }, - /* 7*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, "(91)A", 0, 15, 15 }, - /* 8*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, "A", 0, 109, 109 }, // 22 layers - /* 9*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, "A", ZINT_ERROR_TOO_LONG, -1, -1 }, // 23 layers - /* 10*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, "A", 0, 15, 15 }, // Compact 1 layer - /* 11*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 2, "A", 0, 19, 19 }, // Compact 2 layers gets set to full 1 layer if READER_INIT set + /* 1*/ { BARCODE_AZTEC, -1, -1, 1, -1, "1234567890", 0, 15, 15 }, + /* 2*/ { BARCODE_AZTEC, -1, -1, 4, -1, "1234567890", 0, 19, 19 }, + /* 3*/ { BARCODE_AZTEC, -1, -1, 5, -1, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15 }, + /* 4*/ { BARCODE_AZTEC, -1, -1, -1, 1, "12345678901234567890", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 5*/ { BARCODE_AZTEC, -1, -1, -1, 36, "1234567890", 0, 151, 151 }, + /* 6*/ { BARCODE_AZTEC, -1, -1, -1, 37, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 }, + /* 7*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1 }, + /* 8*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, "[91]A", 0, 15, 15 }, + /* 9*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, "(91)A", 0, 15, 15 }, + /* 10*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, "A", 0, 109, 109 }, // 22 layers + /* 11*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, "A", ZINT_ERROR_TOO_LONG, -1, -1 }, // 23 layers + /* 12*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, "A", 0, 15, 15 }, // Compact 1 layer + /* 13*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 2, "A", 0, 19, 19 }, // Compact 2 layers gets set to full 1 layer if READER_INIT set + /* 14*/ { BARCODE_AZRUNE, -1, -1, -1, -1, "0001", ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 15*/ { BARCODE_AZRUNE, -1, -1, -1, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1 }, + /* 16*/ { BARCODE_AZRUNE, -1, -1, -1, -1, "256", ZINT_ERROR_INVALID_DATA, -1, -1 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -902,7 +907,7 @@ static void test_encode(int index, int generate, int debug) { "101010100011011" "000000000111010" }, - /* 27*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", -1, 0, 61, 61, 0, "Zint website example gui3.png NOTE now ends with CTRL_DL . instead of CTRL_PS .; BWIPP different encodation (doesn't use CTRL_PS doubles)", + /* 27*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", -1, 0, 61, 61, 0, "Zint website example gui3.png NOTE now ends with D/L . instead of P/S .; BWIPP same encodation but estimates number of Data/ECC codewords differently", "0010110111101110101100000101001101110100010000100111011100001" "0001100000000000001101110010000100010101110011000001000011110" "0001111110101010100101000110101101000110011000101111011100110" @@ -965,7 +970,115 @@ static void test_encode(int index, int generate, int debug) { "1110000011010000000000100001100001000111011110011010000000001" "0000010101001111100010001001111100101000010001110010010101101" }, - /* 28*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 36, "Lorem ipsum dolor sit amet.", -1, 0, 151, 151, 1, "Max version 151x151", + /* 28*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "Colon: etc. NUM. 12345, num. 12345 @, 123. . . . . @.¡.!A ", -1, 0, 27, 27, 0, "BWIPP different encodation (better use of D/L and B/S)", + "001011011101101011011110111" + "101001010000010000111010101" + "011101001100101111010111111" + "110110011100000110101001100" + "001111101101100101101110001" + "100111011111010110000110011" + "001000010001011010000001001" + "001000110100110011000111111" + "110110111111101100110000010" + "011110001111111111110110000" + "100101000100000001011101100" + "001110100101111101010001111" + "001101111101000101100011111" + "110100110101010101100001010" + "111010100101000101110000101" + "000010101101111101000101010" + "000010011100000001011100010" + "001000100111111111101010010" + "010101000000010100010000000" + "011011001101111000010001010" + "001010001110010110111001111" + "110011011101100111101010100" + "011011101110010010110011101" + "011111111001010010100110111" + "011101011001001010010111111" + "000000111111011010100010100" + "010000011101011110110000100" + }, + /* 29*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "1. 1a @ A@@ @@!!@@!!1!!!!¡a ", -1, 0, 23, 23, 0, "BWIPP different encodation (better use of B/S)", + "11110101100111101010011" + "11111111110111111001011" + "00000000001000011111000" + "01011101110100100010110" + "11100111000010110111010" + "10001110100110000111101" + "10110111100111001011101" + "00000111111111111000101" + "10010101000000010101010" + "01100001011111010100010" + "11000001010001010101000" + "11111001010101011000100" + "01010011010001010110100" + "11110001011111010110111" + "00111001000000010110100" + "00110001111111111110100" + "01111000110001100101100" + "00100010011001110001000" + "00001101111011011111001" + "01011001100100111010101" + "11010001100000011111100" + "01100011101111001100010" + "11000011000010110000011" + }, + /* 30*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, -1, "1234\01512\015AB\015AB\015ab\015ab\01512\015ab\015!\015!\015a,a,1,a,@,", -1, 0, 27, 27, 0, "BWIPP different encodation (better use of P/S CRs)", + "111111110000010110000011001" + "110110110010011110100000101" + "000011100001000111001100111" + "010010110001110000100100110" + "101001010011110101010100011" + "100111100011101010001101110" + "001001011111111011000000011" + "100011010101001101001011110" + "100010001111100110110101110" + "111011011111111111100110011" + "000110011100000001110110111" + "001010001101111101110000010" + "000000011101000101101010000" + "000011001101010101101110001" + "011110001101000101000100100" + "001100111101111101110100101" + "111111000100000001010101000" + "011010110111111111111011100" + "001111010001101110010011100" + "000001011010011101101000000" + "000011010100101100000000101" + "000101100011010101010110010" + "000000101000011010111000000" + "110000000111001101111000001" + "110010101110100110101001000" + "000110100001100100110010100" + "101110010000110000111111101" + }, + /* 31*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 6, "AA!! ", -1, 0, 23, 23, 1, "", + "00110111000010111110110" + "01011001101100101011001" + "00101000101000011110111" + "00011011100111110011101" + "10011100001000000010001" + "00001111111111111110000" + "00010100000000000100111" + "00011101111111110100111" + "01000101000000010101101" + "11110101011111010110011" + "00110101010001010110010" + "01010101010101010101010" + "00010101010001010100011" + "00100101011111010101001" + "00100101000000010101010" + "11001101111111110111100" + "00011100000000000101000" + "00110111111111111111011" + "01100000101000010001001" + "11101001010111001100010" + "11110100110010110001111" + "00111110110110100011111" + "10010010100010101110001" + }, + /* 32*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 36, "Lorem ipsum dolor sit amet.", -1, 0, 151, 151, 1, "Max version 151x151", "0110011000001101111010100010010110101010100001110111111001101101010000111100111111111001000011100001010000101001010001001010101001000111101011111001101" "1011011111111000001111111001010101111011100101110110001011011000101000010101101100000110011110100000010100110111100111111011011110001000110100111100100" "1110001110001111110101011110010010011011001011001000001010000010000110101010101011111110110010000010000111000010000011011110001111111001000010000000111" @@ -1118,7 +1231,7 @@ static void test_encode(int index, int generate, int debug) { "1000000100011011110011111011110000011111110111001111111010110101100011000111010100100010001111000101110110110100000111000011101011011101111111000011111" "1000110110001001001111110010011100000100011010101101101101101001001001011110101010011110010011011110100111100111110111111110000101100111110000101010011" }, - /* 29*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, -1, 31, "aztec barcode", -1, 0, 131, 131, 1, "Layers 27 example from Andre Maute, mailing list 2020-12-16", + /* 33*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, -1, 31, "aztec barcode", -1, 0, 131, 131, 1, "Layers 27 example from Andre Maute, mailing list 2020-12-16", "10101111100010101000001110000100001111111110110110010011000100100000011000101001100000001111111010100010010101111010001011001110001" "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" "10001110111111000001001111011100100100010011110010101011110111111000000110101100000110101010110000010101101110010010010101001001001" @@ -1251,7 +1364,7 @@ static void test_encode(int index, int generate, int debug) { "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010" "10111010011101110010010111100011101001001011100010101101110000011000110101000011100000011000101000101010001110100000000100101100001" }, - /* 30*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 6, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 23, 23, 1, "Full 2 layers example", + /* 34*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 6, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 23, 23, 1, "Full 2 layers example", "00000100110001011110010" "01111011110100100101111" "00001011010000010011001" @@ -1276,7 +1389,7 @@ static void test_encode(int index, int generate, int debug) { "11001100111110110000000" "00011010100010111001011" }, - /* 31*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", -1, 0, 27, 27, 1, "Full 3 layers example", + /* 35*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", -1, 0, 27, 27, 1, "Full 3 layers example", "001011111011101010010010000" "011111001111111001111010110" "001111101101101100001011101" @@ -1305,7 +1418,7 @@ static void test_encode(int index, int generate, int debug) { "110011110110011010110100110" "101010010111000001000111010" }, - /* 32*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 8, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO", -1, 0, 31, 31, 1, "Full 4 layers example", + /* 36*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 8, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO", -1, 0, 31, 31, 1, "Full 4 layers example", "0011101110100110101001010110000" "0110000101110011101111001100111" "0000011000110010000001101101001" @@ -1338,7 +1451,7 @@ static void test_encode(int index, int generate, int debug) { "1111011001010111010011101111110" "1001011100001000011100011001100" }, - /* 33*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 9, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 37, 37, 1, "5 layers example", + /* 37*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 9, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 37, 37, 1, "5 layers example", "0010010100110011001011100010000111101" "0101111010111110110100101101010011001" "1010101010101010101010101010101010101" @@ -1377,7 +1490,7 @@ static void test_encode(int index, int generate, int debug) { "0101001010110100110101111101011110000" "0111100001000111001011001100101001111" }, - /* 34*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 12, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 49, 49, 1, "8 layers example", + /* 38*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 12, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 49, 49, 1, "8 layers example", "0001000111011100100000001101000011110011100000101" "0110100001000100011100000000110110101100010111110" "0000011110010100101100001010000010000100110110111" @@ -1428,7 +1541,7 @@ static void test_encode(int index, int generate, int debug) { "1001110101111010111101010001000110101110000111011" "1110001110011001010011001001010000100100101000001" }, - /* 35*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 14, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 57, 57, 1, "10 layers example", + /* 39*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 14, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 57, 57, 1, "10 layers example", "001011000011100111111010110111010001110110001110011100010" "011110001010001111111111000000100000100100110001001011111" "000101001001111111010111010010011011111011101011010110010" @@ -1487,7 +1600,7 @@ static void test_encode(int index, int generate, int debug) { "111101011110010100100011010101100011100110010111011001001" "001100101001110000101000010011000100001101011001011100010" }, - /* 36*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 16, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 67, 67, 1, "12 layers example", + /* 40*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 16, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 67, 67, 1, "12 layers example", "0000000100001010000100101101101010101011010000001010001111010001101" "0101010101010101010101010101010101010101010101010101010101010101010" "0001010100101010100010110000101110111100001101110000000100111010001" @@ -1556,7 +1669,7 @@ static void test_encode(int index, int generate, int debug) { "0101010101010101010101010101010101010101010101010101010101010101010" "0001010011000010100000100100010000011010100101110000010001110001101" }, - /* 37*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 17, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 71, 71, 1, "13 layers example", + /* 41*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 17, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 71, 71, 1, "13 layers example", "00001101010011011010101011001110001000011100011011001100101000001110111" "01110010110000100111001011100101010101000111011001110000100101100001100" "00000111000100010100111110101011100011011010001110001000101100010000011" @@ -1629,7 +1742,7 @@ static void test_encode(int index, int generate, int debug) { "10110010001101011101001110011001111101100101011010011110111110101111111" "10000010100001001000010000110101001001110000100011100001100110010100001" }, - /* 38*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 20, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 83, 83, 1, "16 layers example", + /* 42*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 20, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 83, 83, 1, "16 layers example", "00001011100001101001010010111011000000000010110111001100101011111010100110010011011" "00001100111101010101111001100010000000000101110110000101011100011010011001001000011" "00000001101101111000000010100101011010101011110011000000000101010100111000110101100" @@ -1714,7 +1827,7 @@ static void test_encode(int index, int generate, int debug) { "01101011110001110011001111101100101011010101110111110101111101011001011101100001111" "00001001000010000110101000101110000100011010001100110010100011011111011100001101110" }, - /* 39*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 23, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 95, 95, 1, "19 layers example", + /* 43*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 23, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 95, 95, 1, "19 layers example", "00010001011000001001011100000100010100011110001000101101010001101011000110101100111011100100000" "00111000100000010000111101010111001010100110100100101001100010111101100100110001001101001001000" "00110000001000100010001011100100111100110000000000111101000101101101011010001100100111011100010" @@ -1811,7 +1924,7 @@ static void test_encode(int index, int generate, int debug) { "10011001111011010101011010011101111110101111010101011110010010111111000001000011100100110011001" "00110101001011100000100011100010100110010100111000001111111101000000001100011000110110100110000" }, - /* 40*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 101, 101, 1, "20 layers example", + /* 44*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 24, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 101, 101, 1, "20 layers example", "00100011001001111011101000010101101000001111011011100001010111001110100001111011101010011110100110110" "01001011101010010001000100010011010011001011100001000010011001000001100110100110000010001111010101011" "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101" @@ -1914,7 +2027,7 @@ static void test_encode(int index, int generate, int debug) { "01011101100101011001001110111110100111101011010110010100101110001100000100001110000011101010010100001" "01100101110000100011110001100110011010011000001110100010010101000111010001001111111100001101100010111" }, - /* 41*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 30, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 125, 125, 1, "26 layers example", + /* 45*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 30, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 125, 125, 1, "26 layers example", "00100110111101111000100011101010001011000100011001100001000110110101101111011010100110010101111010000000001001111011011101111" "01000110110001010011111011000100001101000010100100110101101011001111101101110000100110101000000100001011010101000110110110011" "00100000111011111011100111001111100011001111101001011011011111100001111010110111111101111111011010001000100011110110101111001" @@ -2041,7 +2154,7 @@ static void test_encode(int index, int generate, int debug) { "11111010111101011001001001001000000000110100010101011110101011001010101011000101010010100111110010111001110100001111110111011" "10011001010011111111011111100010010011110010001010100100000110100111000110011010110111001010011011101001111100110010110010011" }, - /* 42*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "0", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)", + /* 46*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "0", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)", "11101010101" "11111111111" "01000000010" @@ -2054,7 +2167,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00101010100" }, - /* 43*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "25", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)", + /* 47*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "25", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)", "11101100101" "11111111111" "01000000011" @@ -2067,7 +2180,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00100100000" }, - /* 44*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "125", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)", + /* 48*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "125", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)", "11110101101" "11111111111" "11000000011" @@ -2080,7 +2193,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00111101000" }, - /* 45*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "255", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)", + /* 49*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "255", -1, 0, 11, 11, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)", "11010101001" "11111111111" "01000000011" @@ -2093,7 +2206,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00110011100" }, - /* 46*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "1", -1, 0, 11, 11, 1, "", + /* 50*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "1", -1, 0, 11, 11, 1, "", "11101010101" "11111111111" "11000000011" @@ -2106,7 +2219,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00100110100" }, - /* 47*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "15", -1, 0, 11, 11, 1, "", + /* 51*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "15", -1, 0, 11, 11, 1, "", "11101001001" "11111111111" "11000000011" @@ -2119,7 +2232,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00001111100" }, - /* 48*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "16", -1, 0, 11, 11, 1, "", + /* 52*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "16", -1, 0, 11, 11, 1, "", "11101110101" "11111111111" "11000000010" @@ -2132,7 +2245,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00111100100" }, - /* 49*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "63", -1, 0, 11, 11, 1, "", + /* 53*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "63", -1, 0, 11, 11, 1, "", "11100101001" "11111111111" "11000000011" @@ -2145,7 +2258,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00101010000" }, - /* 50*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "64", -1, 0, 11, 11, 1, "", + /* 54*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "64", -1, 0, 11, 11, 1, "", "11111010101" "11111111111" "01000000010" @@ -2158,7 +2271,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00111011100" }, - /* 51*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "65", -1, 0, 11, 11, 1, "", + /* 55*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "65", -1, 0, 11, 11, 1, "", "11111010101" "11111111111" "11000000011" @@ -2171,7 +2284,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00110111100" }, - /* 52*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "126", -1, 0, 11, 11, 1, "", + /* 56*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "126", -1, 0, 11, 11, 1, "", "11110101001" "11111111111" "01000000010" @@ -2184,7 +2297,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00110111000" }, - /* 53*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "127", -1, 0, 11, 11, 1, "", + /* 57*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "127", -1, 0, 11, 11, 1, "", "11110101001" "11111111111" "11000000011" @@ -2197,7 +2310,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00111011000" }, - /* 54*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "128", -1, 0, 11, 11, 1, "", + /* 58*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "128", -1, 0, 11, 11, 1, "", "11001010101" "11111111111" "11000000010" @@ -2210,7 +2323,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00100010000" }, - /* 55*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "191", -1, 0, 11, 11, 1, "", + /* 59*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "191", -1, 0, 11, 11, 1, "", "11000101001" "11111111111" "01000000011" @@ -2223,7 +2336,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00100010100" }, - /* 56*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "192", -1, 0, 11, 11, 1, "", + /* 60*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "192", -1, 0, 11, 11, 1, "", "11011010101" "11111111111" "11000000010" @@ -2236,7 +2349,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00110011000" }, - /* 57*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "225", -1, 0, 11, 11, 1, "", + /* 61*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "225", -1, 0, 11, 11, 1, "", "11010010101" "11111111111" "11000000011" @@ -2249,7 +2362,7 @@ static void test_encode(int index, int generate, int debug) { "01111111111" "00001100100" }, - /* 58*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "254", -1, 0, 11, 11, 1, "", + /* 62*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, "254", -1, 0, 11, 11, 1, "", "11010101001" "11111111111" "11000000010" diff --git a/backend/tests/test_bmp.c b/backend/tests/test_bmp.c index 69753e85..9847fb9d 100644 --- a/backend/tests/test_bmp.c +++ b/backend/tests/test_bmp.c @@ -41,19 +41,20 @@ 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*/ { 4, 1, "1001", 0 }, - /* 7*/ { 4, 3, "1001", 1 }, - /* 8*/ { 5, 1, "10101", 0 }, - /* 9*/ { 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*/ { 4, 1, "1001", 0, 0 }, + /* 7*/ { 4, 3, "1001", 1, 0 }, + /* 8*/ { 5, 1, "10101", 0, 0 }, + /* 9*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0, 0 }, }; int data_size = ARRAY_SIZE(data); int i, ret; @@ -63,12 +64,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,15 +92,28 @@ static void test_pixel_plot(int index, int debug) { } assert_equal(size, (int) strlen(data_buf), "i:%d bmp_pixel_plot size %d != strlen(data_buf) %d\n", i, size, (int) strlen(data_buf)); + if (*data_buf > '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):