From 5d60d67a84602dc0386c9fe2afe303f42e7ff918 Mon Sep 17 00:00:00 2001 From: gitlost Date: Sat, 4 Apr 2020 16:53:29 +0100 Subject: [PATCH] emf free malloc bufs; tif don't free alloca bufs (Win); -Wextra; tests --- backend/dotcode.c | 2 +- backend/eci.c | 11 +- backend/emf.c | 11 +- backend/gs1.c | 13 +- backend/reedsol.c | 4 +- backend/svg.c | 7 +- backend/tests/CMakeLists.txt | 1 + backend/tests/data/print/bmp/code128_aim.bmp | Bin 0 -> 48198 bytes .../tests/data/print/bmp/dotcode_aim_fig7.bmp | Bin 0 -> 1818 bytes backend/tests/data/print/bmp/qr_v1_m.bmp | Bin 0 -> 5430 bytes backend/tests/data/print/emf/code128_aim.emf | Bin 0 -> 916 bytes .../tests/data/print/emf/dotcode_aim_fig7.emf | Bin 0 -> 1180 bytes backend/tests/data/print/emf/qr_v1_m.emf | Bin 0 -> 2212 bytes backend/tests/data/print/eps/code128_aim.eps | 64 +++++++ .../tests/data/print/eps/dotcode_aim_fig7.eps | 56 ++++++ backend/tests/data/print/eps/qr_v1_m.eps | 181 ++++++++++++++++++ backend/tests/data/print/gif/code128_aim.gif | Bin 0 -> 1371 bytes .../tests/data/print/gif/dotcode_aim_fig7.gif | Bin 0 -> 83 bytes backend/tests/data/print/gif/qr_v1_m.gif | Bin 0 -> 248 bytes backend/tests/data/print/pcx/code128_aim.pcx | Bin 0 -> 23132 bytes .../tests/data/print/pcx/dotcode_aim_fig7.pcx | Bin 0 -> 698 bytes backend/tests/data/print/pcx/qr_v1_m.pcx | Bin 0 -> 2864 bytes .../data/{ => print}/png/code128_aim.png | Bin .../tests/data/print/png/dotcode_aim_fig7.png | Bin 0 -> 145 bytes backend/tests/data/print/png/qr_v1_m.png | Bin 0 -> 295 bytes backend/tests/data/print/svg/code128_aim.svg | 35 ++++ .../tests/data/print/svg/dotcode_aim_fig7.svg | 51 +++++ backend/tests/data/print/svg/qr_v1_m.svg | 94 +++++++++ backend/tests/data/print/tif/code128_aim.tif | Bin 0 -> 48396 bytes .../tests/data/print/tif/dotcode_aim_fig7.tif | Bin 0 -> 1922 bytes backend/tests/data/print/tif/qr_v1_m.tif | Bin 0 -> 5512 bytes backend/tests/data/print/txt/code128_aim.txt | 1 + .../tests/data/print/txt/dotcode_aim_fig7.txt | 10 + backend/tests/data/print/txt/qr_v1_m.txt | 21 ++ backend/tests/test_code128.c | 7 +- backend/tests/test_common.c | 8 +- backend/tests/test_dotcode.c | 82 +++++++- backend/tests/test_library.c | 2 +- backend/tests/test_png.c | 7 +- backend/tests/test_print.c | 167 ++++++++++++++++ backend/tests/test_svg.c | 8 +- backend/tests/testcommon.c | 30 +-- backend/tests/testcommon.h | 8 +- backend/tif.c | 12 +- 44 files changed, 814 insertions(+), 79 deletions(-) create mode 100644 backend/tests/data/print/bmp/code128_aim.bmp create mode 100644 backend/tests/data/print/bmp/dotcode_aim_fig7.bmp create mode 100644 backend/tests/data/print/bmp/qr_v1_m.bmp create mode 100644 backend/tests/data/print/emf/code128_aim.emf create mode 100644 backend/tests/data/print/emf/dotcode_aim_fig7.emf create mode 100644 backend/tests/data/print/emf/qr_v1_m.emf create mode 100644 backend/tests/data/print/eps/code128_aim.eps create mode 100644 backend/tests/data/print/eps/dotcode_aim_fig7.eps create mode 100644 backend/tests/data/print/eps/qr_v1_m.eps create mode 100644 backend/tests/data/print/gif/code128_aim.gif create mode 100644 backend/tests/data/print/gif/dotcode_aim_fig7.gif create mode 100644 backend/tests/data/print/gif/qr_v1_m.gif create mode 100644 backend/tests/data/print/pcx/code128_aim.pcx create mode 100644 backend/tests/data/print/pcx/dotcode_aim_fig7.pcx create mode 100644 backend/tests/data/print/pcx/qr_v1_m.pcx rename backend/tests/data/{ => print}/png/code128_aim.png (100%) create mode 100644 backend/tests/data/print/png/dotcode_aim_fig7.png create mode 100644 backend/tests/data/print/png/qr_v1_m.png create mode 100644 backend/tests/data/print/svg/code128_aim.svg create mode 100644 backend/tests/data/print/svg/dotcode_aim_fig7.svg create mode 100644 backend/tests/data/print/svg/qr_v1_m.svg create mode 100644 backend/tests/data/print/tif/code128_aim.tif create mode 100644 backend/tests/data/print/tif/dotcode_aim_fig7.tif create mode 100644 backend/tests/data/print/tif/qr_v1_m.tif create mode 100644 backend/tests/data/print/txt/code128_aim.txt create mode 100644 backend/tests/data/print/txt/dotcode_aim_fig7.txt create mode 100644 backend/tests/data/print/txt/qr_v1_m.txt create mode 100644 backend/tests/test_print.c diff --git a/backend/dotcode.c b/backend/dotcode.c index da16ced5..5a2d5f5d 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -455,7 +455,7 @@ static int dotcode_encode_message(struct zint_symbol *symbol, const unsigned cha int input_position, array_length, i; char encoding_mode; int inside_macro; - int debug = symbol->debug; + int debug = (symbol->debug & ZINT_DEBUG_PRINT); int binary_buffer_size = 0; int lawrencium[6]; // Reversed radix 103 values diff --git a/backend/eci.c b/backend/eci.c index 73c4bf80..42277904 100644 --- a/backend/eci.c +++ b/backend/eci.c @@ -1,7 +1,7 @@ /* eci.c - Extended Channel Interpretations libzint - the open source barcode library - Copyright (C) 2009-2017 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ #include #include -#include #include "eci.h" #include "common.h" #ifdef _MSC_VER @@ -70,7 +69,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch bytelen = 2; glyph = (source[in_posn] & 0x1f) << 6; - if (*length < (in_posn + 2)) { + if ((int) *length < (in_posn + 2)) { return ZINT_ERROR_INVALID_DATA; } @@ -86,11 +85,11 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch bytelen = 3; glyph = (source[in_posn] & 0x0f) << 12; - if (*length < (in_posn + 2)) { + if ((int) *length < (in_posn + 2)) { return ZINT_ERROR_INVALID_DATA; } - if (*length < (in_posn + 3)) { + if ((int) *length < (in_posn + 3)) { return ZINT_ERROR_INVALID_DATA; } @@ -246,7 +245,7 @@ INTERNAL int utf_to_eci(const int eci, const unsigned char source[], unsigned ch in_posn += bytelen; out_posn++; - } while (in_posn < *length); + } while (in_posn < (int) *length); dest[out_posn] = '\0'; *length = out_posn; diff --git a/backend/emf.c b/backend/emf.c index 3f0a7638..50aa9e66 100644 --- a/backend/emf.c +++ b/backend/emf.c @@ -1,7 +1,7 @@ /* emf.c - Support for Microsoft Enhanced Metafile Format libzint - the open source barcode library - Copyright (C) 2016-2018 Robin Stuart + Copyright (C) 2016 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -181,10 +181,10 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { string_count = count_strings(symbol); #ifndef _MSC_VER - emr_rectangle_t rectangle[rectangle_count]; - emr_ellipse_t circle[circle_count]; - emr_polygon_t hexagon[hexagon_count]; - emr_exttextoutw_t text[string_count]; + emr_rectangle_t rectangle[rectangle_count ? rectangle_count : 1]; // Avoid sanitize runtime error by making always non-zero + 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]; #else rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof (emr_rectangle_t)); circle = (emr_ellipse_t*) _alloca(circle_count * sizeof (emr_ellipse_t)); @@ -509,6 +509,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol) { fwrite(&emr_selectobject_font, sizeof (emr_selectobject_t), 1, emf_file); fwrite(&text[i], sizeof (emr_exttextoutw_t), 1, emf_file); fwrite(this_string[i], bump_up(text[i].w_emr_text.chars + 1) * 2, 1, emf_file); + free(this_string[i]); for (j = 0; j < bump_up(text[i].w_emr_text.chars + 1); j++) { fwrite(&spacing, 4, 1, emf_file); } diff --git a/backend/gs1.c b/backend/gs1.c index 469f1c60..9e7b4ba6 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009-2017 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ /* vim: set ts=4 sw=4 et : */ #include -#include #include #ifdef _MSC_VER #include @@ -93,7 +92,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] #endif /* Detect extended ASCII characters */ - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { if (source[i] >= 128) { strcpy(symbol->errtxt, "250: Extended ASCII characters are not supported by GS1"); return ZINT_ERROR_INVALID_DATA; @@ -121,7 +120,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] min_ai_length = 5; j = 0; ai_latch = 0; - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { ai_length += j; if (((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) { ai_latch = 1; @@ -178,7 +177,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] } ai_count = 0; - for (i = 1; i < src_len; i++) { + for (i = 1; i < (int) src_len; i++) { if (source[i - 1] == '[') { ai_location[ai_count] = i; j = 0; @@ -203,7 +202,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] data_length[i] = 0; do { data_length[i]++; - } while ((source[data_location[i] + data_length[i] - 1] != '[') && (data_location[i] + data_length[i] <= src_len)); + } while ((source[data_location[i] + data_length[i] - 1] != '[') && (data_location[i] + data_length[i] <= (int) src_len)); data_length[i]--; } @@ -662,7 +661,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[] j = 0; last_ai = 0; ai_latch = 1; - for (i = 0; i < src_len; i++) { + for (i = 0; i < (int) src_len; i++) { if ((source[i] != '[') && (source[i] != ']')) { reduced[j++] = source[i]; } diff --git a/backend/reedsol.c b/backend/reedsol.c index fb5273f7..6d908e48 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -124,11 +124,11 @@ INTERNAL void rs_init_code(const int nsym, int index) { } } -INTERNAL void rs_encode(const size_t len,const unsigned char *data, unsigned char *res) { +INTERNAL void rs_encode(const size_t len, const unsigned char *data, unsigned char *res) { int i, k; for (i = 0; i < rlen; i++) res[i] = 0; - for (i = 0; i < len; i++) { + for (i = 0; i < (int) len; i++) { int m = res[rlen - 1] ^ data[i]; for (k = rlen - 1; k > 0; k--) { if (m && rspoly[k]) diff --git a/backend/svg.c b/backend/svg.c index 2d1e9ffa..35d5b526 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009-2019 Robin Stuart + Copyright (C) 2009 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -33,7 +33,6 @@ #include #include -#include #include #include #ifdef _MSC_VER @@ -50,7 +49,7 @@ static void make_html_friendly(unsigned char * string, char * html_version) { html_pos = 0; html_version[html_pos] = '\0'; - for (i = 0; i < ustrlen(string); i++) { + for (i = 0; i < (int) ustrlen(string); i++) { switch(string[i]) { case '>': strcat(html_version, ">"); @@ -105,7 +104,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) { int html_len = strlen((char *)symbol->text) + 1; - for (i = 0; i < strlen((char *)symbol->text); i++) { + for (i = 0; i < (int) strlen((char *)symbol->text); i++) { switch(symbol->text[i]) { case '>': case '<': diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index a6858590..2d408e1a 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -73,6 +73,7 @@ zint_add_test(maxicode, test_maxicode) zint_add_test(pdf417, test_pdf417) zint_add_test(png, test_png) zint_add_test(postal, test_postal) +zint_add_test(print, test_print) zint_add_test(qr, test_qr) zint_add_test(raster, test_raster) zint_add_test(rss, test_rss) diff --git a/backend/tests/data/print/bmp/code128_aim.bmp b/backend/tests/data/print/bmp/code128_aim.bmp new file mode 100644 index 0000000000000000000000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y<(zHw+^?f@{x4eB%w<`(iF4mFR zSF~TJ1UXx3r`naKW$LK!+iAMx?R&aiNlMc*-|^zt~4!EM}6N;(=Bh` z)9p%vx{GyW_7&~dDM8Mb+NpM>X_-3e`*xacdHbGjR}$1+tRu6pXunPga<+m!@$7wgFEE84G9 zf}Ab2Q|(IAGIiAV?KIu;_C4LMB&fSsM`mBqew`BJY^j}USDKcoqrPva>6W+e>2@VS z-NiaG`-=AKlptqI?Nqzcv`iiKeLGFJynRo%D+%f@){)s)v|pzLIa_L{+Lfkd>ZtGA zX}aa@d%9goP2QajbIG%Zs{ecw*gEpOk`?Mi~Wi*;o7746q4LC%)i zsdlAlnL6tGcA9Q^`<`xB64YI+BeSn)zfK8qw$x6wD^1JPQQx=Ibj#cKbi0zE?qVI8 zeMS3qN|3XqcB)-zTBeTrzMZC9-oB^Xl>~Jc>&WaY+OJcBoGrCe?Ml-!b=3FmG~M#{ zJ>9M(sJmE4W?#{Mof711shw(9nwF`fzHg`LmbdTeb|pdG#X2(kiuUW2AZJVMRJ+o& zOda)oJ59H|eNVS53FD zooZK_mZ_t@Z>Q;&x9{n8B|+WAIx_o;_Un`&XG`r=yVA5w9rb-XO}D&#Pq!-x>Mqui R*;lk*rvy1$YNvXfe*t5E*Gd2Y literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/bmp/dotcode_aim_fig7.bmp b/backend/tests/data/print/bmp/dotcode_aim_fig7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d67bd14f63b10d3c0f6881ac5f9241e8011aae64 GIT binary patch literal 1818 zcmcJL(Fwya5JS_iOb{r|0-c}(we-kAc%YmyG&-;mief!(`@ZJsm`~jAIBT3G z&SQGUeLef#(^@;9jLJ)Wnjx5}e7?!dKRVwWX=e-bs(qZvppEKRwDf(PBxED~N^9Q7 znO!8&b~>v0ubZ>qP7)^7cXMhZc~Ub&&7_aBY8>&IN$un0Hgs?LweR>ibtg(vWz;uu F{s0*mT0{T< literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/bmp/qr_v1_m.bmp b/backend/tests/data/print/bmp/qr_v1_m.bmp new file mode 100644 index 0000000000000000000000000000000000000000..731d8d5adea4fc1a7f4af228234f8a13ccab281f GIT binary patch literal 5430 zcmd6n>utk841?1l3Uq{`17v{y@5)}SO~MNJ9GVB6gFFKG!tf|kl7W2x9N!O@&+&AA zo}RD&=k4%u;cq*BFCX_HKZ}>e{SrfOYRJ#x%2!=FmBw3V{FWMGDqkyKUGh|~?4FpD zjQQlbo}ViECH##1*-Yw%InDh1^rMsW<6G(H^XV#_n8b4nua(ao5_1xEPrPpz>-m{U zeE)oQpD;V}$(>=>#Pq58Qzm)Vd73lKB&N@@@K*=3BVy+F@$>W3X2=t#9Z{1o_aaTb ze|H^w^!4=Fo9}63CS|f}W`5Rn@ZNmYbx!ZXGo_)MSFPVawPWl~x8--zsNrn=UZ|8? z%};N~Ow%nHx{i4&*ZE#I&PhEo!9AU+`Tgcm`QCAd@$SfU9Hg25|5qK;gvre0vwDnE za^lBsx~=!$(WaclcRVX!9_f@*x=r~V{cGj>#?oxQ5i*YHOwZ!Cxbq!(V%3QupK#?| zdlt{S;;yw!bF3=*5GT*#J6g{q^Voc*u?x;YTyvhkxA-mYS}P5eWQdhUrI^gK+OgMB hlf0>M%&OXntHj(tf8EXYFLuX{Qjgm%``P>C{{hg2%NPIv literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/emf/code128_aim.emf b/backend/tests/data/print/emf/code128_aim.emf new file mode 100644 index 0000000000000000000000000000000000000000..f1aa5a167af54d24eeee3e0c3ea4f67b957d4d5c GIT binary patch literal 916 zcmaiyy-EZ@5QJ;>lneX|MC1?@K@B{?NQ^ucJrFztF%U6PR5ZE312K|C3=A*u(R>I) z-(anp?Ur^D3u>q5qvvO*y8v)byWSZ*`Gn*5H1IhIEFJc`K!J}@V3E8Lauj}%%k84} z8reL}>958aIUg}vRTacn=>?iwV2qCIPC37)b><8mHLMfUcYrJOF~A0Wi$^@*E~fq) zuP|eR*4;eTeb#CHi_720b98u~qr2V&u78x8bmTfunxZ40OSC>W@|JPERpiUY^^TFZ zjc;ar%lLN2cZ~05eBby%#=FLkGk#)RwTt)hUc1QnrR85|Tx%uOKkm~{6s+=J{%rgu z6YGYEs>DWd|rbdOvlU`b2LK<@wrY4@c;6RQ;n>_gUJd F_y^qPJxl-q literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/emf/dotcode_aim_fig7.emf b/backend/tests/data/print/emf/dotcode_aim_fig7.emf new file mode 100644 index 0000000000000000000000000000000000000000..a836388f3a40eb644a187aced61f58c1733fbe5c GIT binary patch literal 1180 zcmZ9IOG*S$5Cm)dAu@=F$RIAz1xD!QsN>uqM{GvT?( z<;o=A?P2~O%-p?wyw7ar>uBaRJfDB(J9Wg%<~JVmcb7=|cTRGXXXJAB`~AQl61Rzr znBzqE-6!8B=*I-mPKAQ=)5_LCD<$56#izoF|%JEOh2_#eK8u6;~T?Jx9IM za6ITI*CnTx8o706D~=!f@zeGAf#at+e&G0Nt{(r;QkVUyL#MfV=rrd};FE9;?+IsK zbNlhx96#jvq1QPu0@mDq_G_MW$(e_?bMQhPvzj{>)|~zM$KK7=<2{?Jhktt2RHv~@pH>Xlb_snIj z^?f4Gr#Xl`zi-wO+t=G~YhBjQ2W$P99|!&S{JOiA_;UFhALiE=6O;aX?$0Uw&Oxu& z>%!kpyqXw^b#J2Yy_@{eggZH_`#hmXo_J3UjdRW8VRXWu9+#h;cywQ$IFBB^S_hL0 zUZWr1`Zj-Z)aq}SsegWOeVgk``}IWYd^|Wm&D|9bkBENynb+RKw>hi#9^47H2X*|I zA)NpD6c(MXpLF-3_FT`O{>|OT&E4F*xVf6=zI!~xPww;Ce9}F)J9krWR&{1;ZYJDJ z&3VCjY3_{MQ}gZMZ%*8P)q8JUKk1(9W48EAKef%BF>^P!H{5s9JpJsm`J{VpKX#YC z_R~GW&55hkJA9in{&u3deah{#_4&m4Y;IpT9lfH@KhA%1`;yyJ>tF(Fz8zej=H82X z`pvy7x!-t>A537)GtYM7>1QrA(b1QV`C4bvJvUd^+p#)+n#ap_;*;)m-mf0%Yj5t; zZ{FX|Hov7l?@I6HG=#aDn+vzk<~K*~dr%X7d)_AWx2tgTZWHEhZeCn8cgAQpHzUqZ zbNcdpbLnf&XqhcMy7Zd!FXzAK;v46;`F3!ud35<~9$kL>eetPoJ8|A|y}N$WJ@?-A o$XxlKl)tfX{@v%l>-EL+j#IxKT>q|*51yLS5SZZ0jCq{@0JqUUuK)l5 literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/eps/code128_aim.eps b/backend/tests/data/print/eps/code128_aim.eps new file mode 100644 index 00000000..5d65ec70 --- /dev/null +++ b/backend/tests/data/print/eps/code128_aim.eps @@ -0,0 +1,64 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 136 118 +%%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 +118.00 0.00 TB 0.00 136.00 TR +TE +0.00 0.00 0.00 setrgbcolor +100.00 18.00 TB 0.00 4.00 TR +TE +100.00 18.00 TB 6.00 2.00 TR +TE +100.00 18.00 TB 12.00 2.00 TR +TE +100.00 18.00 TB 22.00 2.00 TR +TE +100.00 18.00 TB 26.00 2.00 TR +TE +100.00 18.00 TB 34.00 4.00 TR +TE +100.00 18.00 TB 44.00 4.00 TR +TE +100.00 18.00 TB 54.00 2.00 TR +TE +100.00 18.00 TB 62.00 2.00 TR +TE +100.00 18.00 TB 66.00 2.00 TR +TE +100.00 18.00 TB 70.00 6.00 TR +TE +100.00 18.00 TB 78.00 4.00 TR +TE +100.00 18.00 TB 88.00 2.00 TR +TE +100.00 18.00 TB 92.00 6.00 TR +TE +100.00 18.00 TB 100.00 4.00 TR +TE +100.00 18.00 TB 110.00 4.00 TR +TE +100.00 18.00 TB 120.00 6.00 TR +TE +100.00 18.00 TB 128.00 2.00 TR +TE +100.00 18.00 TB 132.00 4.00 TR +TE +matrix currentmatrix +/Helvetica findfont +18.00 scalefont setfont + 0 0 moveto 68.00 0.00 translate 0.00 rotate 0 0 moveto + (AIM) stringwidth +pop +-2 div 0 rmoveto + (AIM) show +setmatrix diff --git a/backend/tests/data/print/eps/dotcode_aim_fig7.eps b/backend/tests/data/print/eps/dotcode_aim_fig7.eps new file mode 100644 index 00000000..af59ba97 --- /dev/null +++ b/backend/tests/data/print/eps/dotcode_aim_fig7.eps @@ -0,0 +1,56 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 26 20 +%%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 +20.00 0.00 TB 0.00 26.00 TR +TE +0.00 0.00 0.00 setrgbcolor +1.00 19.00 1.00 TD +5.00 19.00 1.00 TD +13.00 19.00 1.00 TD +17.00 19.00 1.00 TD +21.00 19.00 1.00 TD +25.00 19.00 1.00 TD +7.00 17.00 1.00 TD +1.00 15.00 1.00 TD +9.00 15.00 1.00 TD +17.00 15.00 1.00 TD +21.00 15.00 1.00 TD +25.00 15.00 1.00 TD +3.00 13.00 1.00 TD +15.00 13.00 1.00 TD +19.00 13.00 1.00 TD +9.00 11.00 1.00 TD +13.00 11.00 1.00 TD +21.00 11.00 1.00 TD +3.00 9.00 1.00 TD +11.00 9.00 1.00 TD +23.00 9.00 1.00 TD +1.00 7.00 1.00 TD +9.00 7.00 1.00 TD +13.00 7.00 1.00 TD +17.00 7.00 1.00 TD +25.00 7.00 1.00 TD +3.00 5.00 1.00 TD +7.00 5.00 1.00 TD +11.00 5.00 1.00 TD +19.00 5.00 1.00 TD +1.00 3.00 1.00 TD +9.00 3.00 1.00 TD +17.00 3.00 1.00 TD +21.00 3.00 1.00 TD +25.00 3.00 1.00 TD +3.00 1.00 1.00 TD +7.00 1.00 1.00 TD +15.00 1.00 1.00 TD +23.00 1.00 1.00 TD diff --git a/backend/tests/data/print/eps/qr_v1_m.eps b/backend/tests/data/print/eps/qr_v1_m.eps new file mode 100644 index 00000000..361fae1a --- /dev/null +++ b/backend/tests/data/print/eps/qr_v1_m.eps @@ -0,0 +1,181 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Zint 2.7.1 +%%Title: Zint Generated Symbol +%%Pages: 0 +%%BoundingBox: 0 0 42 42 +%%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 +42.00 0.00 TB 0.00 42.00 TR +TE +0.00 0.00 0.00 setrgbcolor +2.00 40.00 TB 0.00 14.00 TR +TE +2.00 40.00 TB 18.00 2.00 TR +TE +2.00 40.00 TB 24.00 2.00 TR +TE +2.00 40.00 TB 28.00 14.00 TR +TE +10.00 30.00 TB 0.00 2.00 TR +TE +10.00 30.00 TB 12.00 2.00 TR +TE +2.00 38.00 TB 16.00 2.00 TR +TE +2.00 38.00 TB 22.00 4.00 TR +TE +10.00 30.00 TB 28.00 2.00 TR +TE +10.00 30.00 TB 40.00 2.00 TR +TE +6.00 32.00 TB 4.00 6.00 TR +TE +2.00 36.00 TB 18.00 2.00 TR +TE +6.00 32.00 TB 32.00 6.00 TR +TE +8.00 28.00 TB 24.00 2.00 TR +TE +2.00 32.00 TB 16.00 4.00 TR +TE +2.00 28.00 TB 0.00 14.00 TR +TE +2.00 28.00 TB 16.00 2.00 TR +TE +2.00 28.00 TB 20.00 2.00 TR +TE +2.00 28.00 TB 28.00 14.00 TR +TE +2.00 26.00 TB 18.00 2.00 TR +TE +2.00 26.00 TB 22.00 4.00 TR +TE +2.00 24.00 TB 0.00 2.00 TR +TE +2.00 24.00 TB 4.00 2.00 TR +TE +2.00 24.00 TB 8.00 2.00 TR +TE +2.00 24.00 TB 12.00 2.00 TR +TE +2.00 24.00 TB 18.00 6.00 TR +TE +2.00 24.00 TB 32.00 2.00 TR +TE +2.00 24.00 TB 38.00 2.00 TR +TE +2.00 22.00 TB 0.00 12.00 TR +TE +2.00 22.00 TB 14.00 4.00 TR +TE +2.00 22.00 TB 20.00 2.00 TR +TE +2.00 22.00 TB 28.00 2.00 TR +TE +2.00 22.00 TB 40.00 2.00 TR +TE +6.00 16.00 TB 0.00 2.00 TR +TE +2.00 20.00 TB 4.00 14.00 TR +TE +2.00 20.00 TB 24.00 2.00 TR +TE +2.00 20.00 TB 32.00 4.00 TR +TE +4.00 16.00 TB 8.00 2.00 TR +TE +4.00 16.00 TB 28.00 2.00 TR +TE +2.00 18.00 TB 34.00 2.00 TR +TE +2.00 18.00 TB 40.00 2.00 TR +TE +2.00 16.00 TB 12.00 2.00 TR +TE +2.00 16.00 TB 24.00 2.00 TR +TE +2.00 16.00 TB 32.00 2.00 TR +TE +2.00 16.00 TB 38.00 4.00 TR +TE +2.00 14.00 TB 16.00 8.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 +4.00 12.00 TB 34.00 2.00 TR +TE +2.00 14.00 TB 38.00 2.00 TR +TE +2.00 12.00 TB 0.00 14.00 TR +TE +2.00 12.00 TB 20.00 4.00 TR +TE +2.00 12.00 TB 26.00 6.00 TR +TE +10.00 2.00 TB 0.00 2.00 TR +TE +10.00 2.00 TB 12.00 2.00 TR +TE +2.00 10.00 TB 18.00 2.00 TR +TE +2.00 10.00 TB 22.00 6.00 TR +TE +2.00 10.00 TB 30.00 6.00 TR +TE +2.00 10.00 TB 38.00 4.00 TR +TE +6.00 4.00 TB 4.00 6.00 TR +TE +2.00 8.00 TB 16.00 2.00 TR +TE +2.00 8.00 TB 20.00 4.00 TR +TE +2.00 8.00 TB 26.00 6.00 TR +TE +2.00 8.00 TB 34.00 4.00 TR +TE +2.00 8.00 TB 40.00 2.00 TR +TE +2.00 6.00 TB 20.00 2.00 TR +TE +2.00 6.00 TB 28.00 4.00 TR +TE +2.00 6.00 TB 38.00 2.00 TR +TE +2.00 4.00 TB 16.00 2.00 TR +TE +2.00 4.00 TB 24.00 2.00 TR +TE +2.00 4.00 TB 32.00 6.00 TR +TE +2.00 4.00 TB 40.00 2.00 TR +TE +2.00 2.00 TB 18.00 2.00 TR +TE +2.00 2.00 TB 28.00 4.00 TR +TE +2.00 2.00 TB 34.00 2.00 TR +TE +2.00 0.00 TB 0.00 14.00 TR +TE +2.00 0.00 TB 16.00 6.00 TR +TE +2.00 0.00 TB 24.00 2.00 TR +TE +2.00 0.00 TB 28.00 2.00 TR +TE +2.00 0.00 TB 32.00 2.00 TR +TE +2.00 0.00 TB 36.00 2.00 TR +TE +2.00 0.00 TB 40.00 2.00 TR +TE diff --git a/backend/tests/data/print/gif/code128_aim.gif b/backend/tests/data/print/gif/code128_aim.gif new file mode 100644 index 0000000000000000000000000000000000000000..e2f87bf94c3f23a01b0f878fb37f369b48b70e86 GIT binary patch literal 1371 zcmV-h1*G~%Nk%v~VTb^B0Pp|+|Ns90001li0001p0CoTX0{@HyV42JB96YblDp^G8 z>}*+{$W353c4V5Jp^9B*snPFurPIpk_37F0gtbZ$HZ%HOJ6NzMJ3dLuDDU=!Hml5^ z4fO?T!8k4%Do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ir1Hq2A`s((zuq=Rf0~x!#--U%BarW8RhG%j;aW&%g65 zqU4*iUcBq4V;}mjqjTT9?XTmVyYhiDPo(+ZAEuw|lhajX>KM2AQig1J^ETIWc zh{6=AaD^;vp$lIK!x+kNhBR~v1wKK;9O_VoJ;1=db_m2E`cMN9_@NMwxI-Kgu>mSL z2NItsLnShii3@Nd6tCDqM>F3&qa5#u$2{tBk9_Q-AO8r*K2n)s?R+_Xrc4dS% zy$@-R5`x%ap5l3BCONJ0*LvI*m-C3*u)j&wG{4#}wKAe^#HEs#1S*G2RVhaj246j7 zRqLf{JI8B}jCOX-XfOEdj=!^Vs`%!DTJ7s*-Wt`>w4=k-R`vJCGi3pixTKf1MMy_E zS-0gTG)2h2BU yj3}H6e5_oghPrF&j0+e`%{I;Hjn(|Bm;1!}J4Q-4?j3D?2tJFfyPRxR002AU0d^<= literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/pcx/code128_aim.pcx b/backend/tests/data/print/pcx/code128_aim.pcx new file mode 100644 index 0000000000000000000000000000000000000000..0050e1ea45aa3c9698d285a3ea3abae0729c7f51 GIT binary patch literal 23132 zcmeI)VM@d>5QgC_B8X?%>v;yfR%3S&k5q*?v)$0{A87><;VGm|r%6g?)A`Wm zhZ4tgc`C=l@sRml$K6ZWUuk*6SZb?fjPw>M^XE2RQ|4z|ZRdEF_Pp=;yw7~v#-gRQ zZ`OH!n#Yv!L!B2Wa1V7uzj=w)rK>2emKyTTJDjst z(NX>-Bdm-kaG*ZMxbHY4a&@VODhsD?qd-k5AbioJ0(zQbNUu+s_@~1gXyB*J>Z2QB n2<1LIPXwpBb)q-Th^cdA&9vT~a;E?Lp2oopO1FPv72o4{s#ymWsFjGA(xk!+Oe;K*0zY|g_>vbV(-`CM)Ex59fxti zde?J#(*BQ1gqcEO9h_#WV==vCPu6{d&T1cwa*CM))1-XN2D7txJWtN3aO>~k6tXS~ ztIg_EUS!KNrn6ctkXbbaZQDT46booQ7&-U zrfu1^enJckcZF>)99gp1rkTR1pU2fSsg{jjdklZH LoCD}+Gx~eJE$*Fh literal 0 HcmV?d00001 diff --git a/backend/tests/data/png/code128_aim.png b/backend/tests/data/print/png/code128_aim.png similarity index 100% rename from backend/tests/data/png/code128_aim.png rename to backend/tests/data/print/png/code128_aim.png diff --git a/backend/tests/data/print/png/dotcode_aim_fig7.png b/backend/tests/data/print/png/dotcode_aim_fig7.png new file mode 100644 index 0000000000000000000000000000000000000000..3d7b7119c4cf9ef682372391e45e02e0c7742d72 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^(m*WA!2~2N_AnIzsR&OO#}JFt$$$R;w`UGz6lP{- zR#sM?(|^W|ZO4^_O_G_9-2Uh(i5gt8k?Aaad7xF!d$q$rxJ~nc=PdZ$F u;F9vkM6dM)D*DshKbsy+bie$CgQ4?`VoBDHd;LH=7(8A5T-G@yGywqVA~DMV literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/png/qr_v1_m.png b/backend/tests/data/print/png/qr_v1_m.png new file mode 100644 index 0000000000000000000000000000000000000000..0892287b39e365e66f26847e9d8da0e53d85638a GIT binary patch literal 295 zcmV+?0oeYDP)1Se}YpdOvEZaz<%1Ln(P3W6~YSWZ*$hYB$GNWj@h=i+&%9@2!qk*M$@P^Zre;-F4REH2hAj8K-G} zJ=GK4G*Z2Lw${mhQ@?36=Lg@%_&&@1r|o$4oYOtEfApNT<*1#PMBQ%MS={lI1`us9 tiv0_9Pqtune>44D&i}<7{j=xI^j|j}4l{;$78w8l002ovPDHLkV1k1aj@|$O literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/svg/code128_aim.svg b/backend/tests/data/print/svg/code128_aim.svg new file mode 100644 index 00000000..c552746e --- /dev/null +++ b/backend/tests/data/print/svg/code128_aim.svg @@ -0,0 +1,35 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + AIM + + + diff --git a/backend/tests/data/print/svg/dotcode_aim_fig7.svg b/backend/tests/data/print/svg/dotcode_aim_fig7.svg new file mode 100644 index 00000000..f07c2d59 --- /dev/null +++ b/backend/tests/data/print/svg/dotcode_aim_fig7.svg @@ -0,0 +1,51 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/print/svg/qr_v1_m.svg b/backend/tests/data/print/svg/qr_v1_m.svg new file mode 100644 index 00000000..41a6e3c9 --- /dev/null +++ b/backend/tests/data/print/svg/qr_v1_m.svg @@ -0,0 +1,94 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/print/tif/code128_aim.tif b/backend/tests/data/print/tif/code128_aim.tif new file mode 100644 index 0000000000000000000000000000000000000000..1782079123b5d0ad96f23794aa5bed31f7fe87b6 GIT binary patch literal 48396 zcmeI!J+7_kRYl=luEHWhLgG(g$tj`}q_`ENw1AY^C%NzRV}zmU`VXr_7Wz->tfG%>Vc=lD6-<bTJu%p+}$TReTAGU*{+w=m1EK^ zbqRZSYDw_j#VRsgH#zBcySuw(mf#J#lI5s3KP9^&=i-{*ccpoc`i0hf6*+hJNlsrO zXG*r~C3WSPbW2^r-kn+!e0Q;mOxI0Ly4~*XZkZ)`gRW#b>djBduE@E#=J#D`-lKk@ zHD5)}-F=eNSIC)??RrUFIVRmwm#}xImIU8jtRmBOlap?@ySrOv3ErS9S&n-1Q?e^^ zF0T1~SDN>zUuex&k#l#Six6~!<-KizPcNeS3blv2n+wJb|mRW)~ z=t`EO-u#s8ikypUe&3bmJ?a-)^Ht>B-6uJHg`6qbu9wu6W6~{k343>HN$}mpDl%O+ zIq7!0ySrtU;0?Nx<)}A5CA%W$;+o%grFoC~h1Pr(Id}I-PG2EsO1A4Ib>*0JOI^a= zomvuncd?30*G*2k-R|ygnI(9Gu4Fmt%}>d$$ho-Y_g!h;qkf?^Uq#N{e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*Xw6rV zb9bNQ^c8ZZWV>EcSB^=y)FtfQsU^X87pus0-Q=X(?e6ZDS%Np{N|vME{FLm9oQrFI z-<9S)>K9t`Rpi{=CpmqEoGIC^m(-PG(k*ofdv|I{@ZH5KGF>-0>2|xjyJeQ(4Z4!$ zs5d_)yCUb}n%{S&d5`*q)_fH?clSw7Um<5ow(BKz<(PC!UBcd-S`vJBv5HLBO-{Pq z?(S}xC3u6bWI5{1Psy&xxwz){U1{E_FzyIxXP zj!C!FCG6d)CBb(WtH^ZSEp-WdcWO!S-Nh<0T{k)DcDuW~WtQL#x{~FnH$Nr2BIn|o-*=^X zkNSnyd=)u&_eoA)A!kaq>m_yNm~=~B!rq-)5`1^DicHr{PP*Oh?rxbSc!REFIqJ<% z$*#z`xaRj=Y2KrLp*3Gc&fR^I(^trulI?m)T{$M*QkSrIr1qu%_K?24R=YkuFA<~`~cTJu%p+}$TReTAGU*{+w=m1EK^ zbqRZSYDw_j#VRsgH#zBcySuw(mf#J#lI5s3KP9^&=i-{*ccpoc`i0hf6*+hJNlss( zEC2KT`3rph0-wLY=P&So{R{Mef&Jh1_xpXo^PeA=eD&vt{`vT+eu0l)_~Y?GR(Zca z{`CD3{(Ss|zre>&{VkQU;U}|`TqO`K7WDFU*Pi> z`1}Pve}T_m;Q#j*_`TPEy}o;W^V|P#=9_PSc>ntS_cveOfBSy_?EU`s{onumo7d~x zFZ%bLpMQD(?EU`zZ@zo|{Qckm`p*2}7ybLrAHDVOvw!gZ_aA@B{QEoer{Da}5Bh(; z-+%Vy{oOykUcZ3<=kVY4*YAG$zt`(Oe))R+%U`};|M1tZ*RTKX_4=E?f4%+1jj literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/tif/dotcode_aim_fig7.tif b/backend/tests/data/print/tif/dotcode_aim_fig7.tif new file mode 100644 index 0000000000000000000000000000000000000000..680d1bda1e04d472fb7138cb7d13e95bb0ef9fce GIT binary patch literal 1922 zcmcJOK?=e!6hwcTS_MIHQ3dM(q$ja=aOKjaOWk@NkEl+{7iaU~2b+|T*Xd;DZ#oRU zJR6aBfh82n%vG#=nD3Tgo}om3Zl*PlM`sUn?hGEkC!amcp8OIXo`IRWES)`n^6%fX z$}F9WJs$SwvX#%e#oWan)~905x0t)w!+Hs}x;#32m`l%Tb>-@l%(;@6)DqA=t`JA= z@Dh|;a0QMyPjiu|db-mnSKxK1C7ow@TGi8?4fNz)VsF)RfoB(HqkaW<$~W+y@(+}c U>$1>C-3 z+e8zxd~zmJx4SA%Z6V3FWv_ZNqMTi-Gk#6(ePVS?cIn?S55}x{#Qx#oLt~e`=^wcwBs{V{*?W!kCah|GOb9f`wB>Zo)yD*=# z$7xQTs+~EiwUHz=pL$=Oa#p*PsGlTDR!+herjciwIh@USZbDC{nH(NED{1slGbhv9&V-8Q&eTk<>q;X%Y^1I?#uWX` z$uxJ+StZ)iPRM$h!vy-Lv@=t+wv%v&DO`JbBc4uaIc{6sggHEIb9E}w+tEX<&cADq zUbd5vb1QntRcD(sfh`$lGCky~+wJscnaZ>dj4!oaPIq$tI|J)6pH}~9kXM6tc`eD!?t{;*AgnS>ji{Wjyy)ygq O&-bO-v!C=0hwoq5eWVcp literal 0 HcmV?d00001 diff --git a/backend/tests/data/print/txt/code128_aim.txt b/backend/tests/data/print/txt/code128_aim.txt new file mode 100644 index 00000000..e0349487 --- /dev/null +++ b/backend/tests/data/print/txt/code128_aim.txt @@ -0,0 +1 @@ +D2 14 63 11 5D 8B B1 8E B diff --git a/backend/tests/data/print/txt/dotcode_aim_fig7.txt b/backend/tests/data/print/txt/dotcode_aim_fig7.txt new file mode 100644 index 00000000..4a367cbc --- /dev/null +++ b/backend/tests/data/print/txt/dotcode_aim_fig7.txt @@ -0,0 +1,10 @@ +A2 A8 +10 00 +88 A8 +41 40 +0A 20 +44 10 +8A 88 +54 40 +88 A8 +51 10 diff --git a/backend/tests/data/print/txt/qr_v1_m.txt b/backend/tests/data/print/txt/qr_v1_m.txt new file mode 100644 index 00000000..5b7bec81 --- /dev/null +++ b/backend/tests/data/print/txt/qr_v1_m.txt @@ -0,0 +1,21 @@ +FE 4B F8 +82 9A 08 +BA 42 E8 +BA 0A E8 +BA CA E8 +82 0A 08 +FE AB F8 +00 58 00 +AA 70 90 +FD A2 08 +BF 88 C0 +88 02 48 +8A 0A 98 +00 F5 50 +FE 37 40 +82 5D D8 +BA B7 68 +BA 23 10 +BA 88 E8 +82 43 40 +FE EA A8 diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index 7534d285..081bde9b 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -52,8 +52,9 @@ static void test_input(void) /* 2*/ { BARCODE_CODE128, UNICODE_MODE, "éAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAé", -1, 0 }, // 39 chars /* 3*/ { BARCODE_CODE128, UNICODE_MODE, "éAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéAéA", -1, ZINT_ERROR_TOO_LONG }, // 40 chars (+ 20 shifts) /* 4*/ { BARCODE_CODE128, UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA }, // PAD U+0080, not in ISO 8859-1 although encodable in CODE128 - /* 5*/ { BARCODE_CODE128, UNICODE_MODE, "\000\037é", 4, 0 }, - /* 6*/ { BARCODE_CODE128B, UNICODE_MODE, "\000\037é", 4, 0 }, + /* 5*/ { BARCODE_CODE128, DATA_MODE, "\302\200", -1, 0 }, // PAD U+0080, use binary + /* 6*/ { BARCODE_CODE128, UNICODE_MODE, "\000\037é", 4, 0 }, + /* 7*/ { BARCODE_CODE128B, UNICODE_MODE, "\000\037é", 4, 0 }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -67,7 +68,7 @@ static void test_input(void) symbol->symbology = data[i].symbology; symbol->input_mode = data[i].input_mode; - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; ret = ZBarcode_Encode(symbol, 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); diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index 8ca42a8f..94b6639d 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -60,15 +60,15 @@ static void test_utf8_to_unicode(void) for (int i = 0; i < data_size; i++) { - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; size_t ret_length = length; ret = utf8_to_unicode(&symbol, data[i].data, vals, &ret_length, data[i].disallow_4byte); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); if (ret == 0) { assert_equal(ret_length, data[i].ret_length, "i:%d ret_length %ld != %ld\n", i, ret_length, data[i].ret_length); - for (int j = 0; j < ret_length; j++) { - assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%d] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]); + for (size_t j = 0; j < ret_length; j++) { + assert_equal(vals[j], data[i].expected_vals[j], "i:%d vals[%zu] %04X != %04X\n", i, j, vals[j], data[i].expected_vals[j]); } } } diff --git a/backend/tests/test_dotcode.c b/backend/tests/test_dotcode.c index 86d84f7e..d8ad0931 100644 --- a/backend/tests/test_dotcode.c +++ b/backend/tests/test_dotcode.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2020 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -31,6 +31,85 @@ #include "testcommon.h" +#define TEST_ENCODE_GENERATE_EXPECTED 1 + +// TODO: Verify against AIM standard +static void test_encode(void) +{ + testStart(""); + + int ret; + struct item { + int input_mode; + int option_2; + unsigned char* data; + int ret; + + int expected_rows; + int expected_width; + char* comment; + char* expected; + }; + struct item data[] = { + /* 0*/ { UNICODE_MODE, -1, "2741", 0, 10, 13, "Verified manually againt bwipp (tec-it differs)", + "1010001010101" + "0001000000000" + "1000100010101" + "0100000101000" + "0000101000100" + "0100010000010" + "1000101010001" + "0101010001000" + "1000100010101" + "0101000100010" + }, + }; + int data_size = sizeof(data) / sizeof(struct item); + + char escaped[1024]; + + for (int i = 0; i < data_size; i++) { + + struct zint_symbol* symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + symbol->symbology = BARCODE_DOTCODE; + symbol->input_mode = data[i].input_mode; + if (data[i].option_2 != -1) { + symbol->option_2 = data[i].option_2; + } + symbol->debug = ZINT_DEBUG_PRINT; + + int length = strlen(data[i].data); + + ret = ZBarcode_Encode(symbol, 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); + + #ifdef TEST_ENCODE_GENERATE_EXPECTED + printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", + i, testUtilInputModeName(data[i].input_mode), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); + testUtilModulesDump(symbol, " ", "\n"); + printf(" },\n"); + #else + if (ret < 5) { + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + + if (ret == 0) { + int width, row; + ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); + assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + } + } + #endif + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + // #181 Christian Hartlage / Nico Gunkel OSS-Fuzz static void test_fuzz(void) { @@ -95,6 +174,7 @@ static void test_fuzz(void) int main() { + test_encode(); test_fuzz(); testReport(); diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index d0528f27..695d315f 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -84,7 +84,7 @@ static void test_checks(void) if (data[i].dot_size != -1) { symbol->dot_size = data[i].dot_size; } - int length = data[i].length == -1 ? strlen(data[i].data) : data[i].length; + int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; ret = ZBarcode_Encode(symbol, data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt); diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index 412d9aa5..52f643ae 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -47,8 +47,7 @@ static void test_print(void) char* expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, "AIM", "../data/png/code128_aim.png" }, - /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png" }, + /* 0*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png"}, }; int data_size = sizeof(data) / sizeof(struct item); @@ -88,13 +87,15 @@ static void test_print(void) #ifdef TEST_PRINT_GENERATE_EXPECTED - printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); #else assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); + assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file); ret = testUtilCmpPngs(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/test_print.c b/backend/tests/test_print.c new file mode 100644 index 00000000..d92f899e --- /dev/null +++ b/backend/tests/test_print.c @@ -0,0 +1,167 @@ +/* + libzint - the open source barcode library + Copyright (C) 2020 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* vim: set ts=4 sw=4 et : */ + +#include "testcommon.h" +#include + +//#define TEST_PRINT_GENERATE_EXPECTED 1 + +static void test_print(void) +{ + testStart(""); + + int ret; + struct item { + int symbology; + int option_1; + int option_2; + unsigned char* data; + char* expected_file; + }; + struct item data[] = { + /* 0*/ { BARCODE_CODE128, -1, -1, "AIM", "code128_aim"}, + /* 1*/ { BARCODE_QRCODE, 2, 1, "1234567890", "qr_v1_m"}, + /* 2*/ { BARCODE_DOTCODE, -1, -1, "2741", "dotcode_aim_fig7"}, + }; + int data_size = sizeof(data) / sizeof(struct item); + + char* exts[] = { "bmp", "emf", "eps", "gif", "pcx", "png", "svg", "tif", "txt" }; + int exts_len = sizeof(exts) / sizeof(char*); + + char data_dir[1024]; + char expected_file[1024]; + + char escaped[1024]; + int escaped_size = 1024; + + #ifdef TEST_PRINT_GENERATE_EXPECTED + strcpy(data_dir, "../data"); + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + strcat(data_dir, "/print"); + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + #endif + + for (int j = 0; j < exts_len; j++) { + strcpy(data_dir, "../data/print/"); + strcat(data_dir, exts[j]); + + #ifdef TEST_PRINT_GENERATE_EXPECTED + if (!testUtilExists(data_dir)) { + ret = mkdir(data_dir, 0755); + assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret); + } + #endif + + for (int i = 0; i < data_size; i++) { + + struct zint_symbol* 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; + } + if (data[i].option_2 != -1) { + symbol->option_2 = data[i].option_2; + } + + int length = strlen(data[i].data); + + ret = ZBarcode_Encode(symbol, 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, "out."); + strcat(symbol->outfile, exts[j]); + + strcpy(expected_file, data_dir); + strcat(expected_file, "/"); + strcat(expected_file, data[i].expected_file); + strcat(expected_file, "."); + strcat(expected_file, exts[j]); + + ret = ZBarcode_Print(symbol, 0); + assert_zero(ret, "i:%d j:%d %s %s ZBarcode_Print %s ret %d != 0\n", i, j, exts[j], testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); + + #ifdef TEST_PRINT_GENERATE_EXPECTED + + if (j == 0) { + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + } + ret = rename(symbol->outfile, expected_file); + assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, expected_file, ret); + + #else + + assert_nonzero(testUtilExists(symbol->outfile), "i:%d j:%d %s testUtilExists(%s) == 0\n", i, j, exts[j], symbol->outfile); + + if (strcmp(exts[j], "eps") == 0) { + ret = testUtilCmpEpss(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "png") == 0) { + ret = testUtilCmpPngs(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "svg") == 0) { + ret = testUtilCmpSvgs(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else if (strcmp(exts[j], "txt") == 0) { + ret = testUtilCmpTxts(symbol->outfile, expected_file); + assert_zero(ret, "i:%d %s testUtilCmpTxts(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret); + } else { + 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); + + #endif + + ZBarcode_Delete(symbol); + } + } + + testFinish(); +} + +int main() +{ + test_print(); + + testReport(); + + return 0; +} diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 0e13dbe2..093327e2 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -47,8 +47,8 @@ static void test_print(void) char* expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" }, - /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg" }, + /* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" }, + /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg"}, }; int data_size = sizeof(data) / sizeof(struct item); @@ -88,13 +88,15 @@ static void test_print(void) #ifdef TEST_PRINT_GENERATE_EXPECTED - printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); + printf(" /*%3d*/ { %s, %d, %d, \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); #else assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile); + assert_nonzero(testUtilExists(data[i].expected_file), "i:%d testUtilExists(%s) == 0\n", i, data[i].expected_file); ret = testUtilCmpSvgs(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 50e3e78f..000772b1 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -33,8 +33,6 @@ * Copyright (C) 2006-2017 Kentaro Fukuchi */ -#include -#include #include "testcommon.h" #ifndef NO_PNG #include @@ -354,7 +352,7 @@ int testUtilDAFTConvert(const struct zint_symbol* symbol, char* buffer, int buff /* Is string valid UTF-8? */ int testUtilIsValidUTF8(const unsigned char str[], const size_t length) { - int i; + size_t i; unsigned int codepoint, state = 0; for (i = 0; i < length; i++) { @@ -954,7 +952,7 @@ int testUtilCmpPngs(char* png1, char* png2) return ret; } -static int testUtilCmpTxts(char* txt1, char* txt2) +int testUtilCmpTxts(char* txt1, char* txt2) { int ret = -1; FILE* fp1; @@ -1005,7 +1003,7 @@ static int testUtilCmpTxts(char* txt1, char* txt2) return ret; } -static int testUtilCmpBins(char* bin1, char* bin2) +int testUtilCmpBins(char* bin1, char* bin2) { int ret = -1; FILE* fp1; @@ -1114,23 +1112,3 @@ int testUtilCmpEpss(char* eps1, char* eps2) return ret; } - -int testUtilCmpEmfs(char* emf1, char* emf2) -{ - return testUtilCmpBins(emf1, emf2); -} - -int testUtilCmpGifs(char* gif1, char* gif2) -{ - return testUtilCmpBins(gif1, gif2); -} - -int testUtilCmpBmps(char* bmp1, char* bmp2) -{ - return testUtilCmpBins(bmp1, bmp2); -} - -int testUtilCmpPcxs(char* pcx1, char* pcx2) -{ - return testUtilCmpBins(pcx1, pcx2); -} diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index 276c3e1e..fb5655d8 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2008-2019 Robin Stuart + Copyright (C) 2019 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -79,11 +79,9 @@ int testUtilModulesCmp(const struct zint_symbol* symbol, const char* expected, i int testUtilModulesDumpHex(const struct zint_symbol* symbol, char dump[], int dump_size); int testUtilExists(char* filename); int testUtilCmpPngs(char* file1, char* file2); +int testUtilCmpTxts(char* txt1, char* txt2); +int testUtilCmpBins(char* bin1, char* bin2); int testUtilCmpSvgs(char* svg1, char* svg2); int testUtilCmpEpss(char* eps1, char* eps2); -int testUtilCmpEmfs(char* emf1, char* emf2); -int testUtilCmpGifs(char* gif1, char* gif2); -int testUtilCmpBmps(char* bmp1, char* bmp2); -int testUtilCmpPcxs(char* pcx1, char* pcx2); #endif /* TESTCOMMON_H */ diff --git a/backend/tif.c b/backend/tif.c index ff21a1cf..9c9afe36 100644 --- a/backend/tif.c +++ b/backend/tif.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2016-2017 Robin Stuart + Copyright (C) 2016 - 2020 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ /* vim: set ts=4 sw=4 et : */ #include -#include #include #include #include "common.h" @@ -47,8 +46,9 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) { int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int i; int rows_per_strip, strip_count; - int free_memory; - int row, column, strip, bytes_put; + unsigned int free_memory; + int row, column, strip; + unsigned int bytes_put; FILE *tif_file; #ifdef _MSC_VER uint32_t* strip_offset; @@ -113,10 +113,6 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) { } if (free_memory > 0xffff0000) { -#ifdef _MSC_VER - free(strip_offset); - free(strip_bytes); -#endif strcpy(symbol->errtxt, "670: Output file size too big"); return ZINT_ERROR_MEMORY; }