diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt
index edc16155..a4251d58 100644
--- a/backend/tests/CMakeLists.txt
+++ b/backend/tests/CMakeLists.txt
@@ -93,6 +93,7 @@ zint_add_test(plessey, test_plessey)
zint_add_test(png, test_png)
zint_add_test(postal, test_postal)
zint_add_test(print, test_print)
+zint_add_test(ps, test_ps)
zint_add_test(qr, test_qr)
zint_add_test(raster, test_raster)
zint_add_test(rss, test_rss)
diff --git a/backend/tests/data/bmp/pdf417_fg_bg.bmp b/backend/tests/data/bmp/pdf417_fg_bg.bmp
new file mode 100644
index 00000000..65c50a23
Binary files /dev/null and b/backend/tests/data/bmp/pdf417_fg_bg.bmp differ
diff --git a/backend/tests/data/bmp/ultracode_fg_bg.bmp b/backend/tests/data/bmp/ultracode_fg_bg.bmp
new file mode 100644
index 00000000..7275fd6f
Binary files /dev/null and b/backend/tests/data/bmp/ultracode_fg_bg.bmp differ
diff --git a/backend/tests/data/emf/telenum_fg_bg.emf b/backend/tests/data/emf/telenum_fg_bg.emf
new file mode 100644
index 00000000..1192c339
Binary files /dev/null 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
new file mode 100644
index 00000000..2f38b656
Binary files /dev/null and b/backend/tests/data/emf/ultracode_fg_bg.emf differ
diff --git a/backend/tests/data/eps/code39_fg_bg.eps b/backend/tests/data/eps/code39_fg_bg.eps
new file mode 100644
index 00000000..59959e74
--- /dev/null
+++ b/backend/tests/data/eps/code39_fg_bg.eps
@@ -0,0 +1,76 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Creator: Zint 2.9.0
+%%Title: Zint Generated Symbol
+%%Pages: 0
+%%BoundingBox: 0 0 128 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
+0.98 0.59 0.19 setrgbcolor
+118.00 0.00 TB 0.00 128.00 TR
+TE
+0.08 0.48 0.81 setrgbcolor
+100.00 18.00 TB 0.00 2.00 TR
+TE
+100.00 18.00 TB 6.00 2.00 TR
+TE
+100.00 18.00 TB 10.00 4.00 TR
+TE
+100.00 18.00 TB 16.00 4.00 TR
+TE
+100.00 18.00 TB 22.00 2.00 TR
+TE
+100.00 18.00 TB 26.00 4.00 TR
+TE
+100.00 18.00 TB 32.00 2.00 TR
+TE
+100.00 18.00 TB 38.00 2.00 TR
+TE
+100.00 18.00 TB 42.00 2.00 TR
+TE
+100.00 18.00 TB 46.00 4.00 TR
+TE
+100.00 18.00 TB 52.00 2.00 TR
+TE
+100.00 18.00 TB 56.00 4.00 TR
+TE
+100.00 18.00 TB 64.00 2.00 TR
+TE
+100.00 18.00 TB 68.00 2.00 TR
+TE
+100.00 18.00 TB 72.00 4.00 TR
+TE
+100.00 18.00 TB 78.00 4.00 TR
+TE
+100.00 18.00 TB 84.00 4.00 TR
+TE
+100.00 18.00 TB 92.00 2.00 TR
+TE
+100.00 18.00 TB 96.00 2.00 TR
+TE
+100.00 18.00 TB 100.00 2.00 TR
+TE
+100.00 18.00 TB 104.00 2.00 TR
+TE
+100.00 18.00 TB 110.00 2.00 TR
+TE
+100.00 18.00 TB 114.00 4.00 TR
+TE
+100.00 18.00 TB 120.00 4.00 TR
+TE
+100.00 18.00 TB 126.00 2.00 TR
+TE
+matrix currentmatrix
+/Helvetica findfont
+18.00 scalefont setfont
+ 0 0 moveto 64.00 0.00 translate 0.00 rotate 0 0 moveto
+ (*123*) stringwidth
+pop
+-2 div 0 rmoveto
+ (*123*) show
+setmatrix
diff --git a/backend/tests/data/eps/ultra_fg_bg.eps b/backend/tests/data/eps/ultra_fg_bg.eps
new file mode 100644
index 00000000..fcc301b9
--- /dev/null
+++ b/backend/tests/data/eps/ultra_fg_bg.eps
@@ -0,0 +1,218 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Creator: Zint 2.9.0
+%%Title: Zint Generated Symbol
+%%Pages: 0
+%%BoundingBox: 0 0 32 26
+%%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.98 0.59 0.19 setrgbcolor
+26.00 0.00 TB 0.00 32.00 TR
+TE
+0.00 1.00 1.00 setrgbcolor
+2.00 22.00 TB 18.00 4.00 TR
+TE
+2.00 22.00 TB 24.00 4.00 TR
+TE
+2.00 20.00 TB 14.00 2.00 TR
+TE
+2.00 18.00 TB 6.00 2.00 TR
+TE
+2.00 18.00 TB 18.00 2.00 TR
+TE
+2.00 18.00 TB 24.00 4.00 TR
+TE
+2.00 14.00 TB 12.00 2.00 TR
+TE
+2.00 10.00 TB 12.00 2.00 TR
+TE
+2.00 10.00 TB 16.00 2.00 TR
+TE
+2.00 10.00 TB 20.00 8.00 TR
+TE
+2.00 8.00 TB 6.00 2.00 TR
+TE
+2.00 8.00 TB 18.00 2.00 TR
+TE
+2.00 6.00 TB 22.00 4.00 TR
+TE
+2.00 4.00 TB 12.00 6.00 TR
+TE
+2.00 4.00 TB 26.00 2.00 TR
+TE
+2.00 2.00 TB 6.00 2.00 TR
+TE
+1.00 0.00 1.00 setrgbcolor
+2.00 22.00 TB 16.00 2.00 TR
+TE
+2.00 20.00 TB 6.00 2.00 TR
+TE
+2.00 20.00 TB 12.00 2.00 TR
+TE
+2.00 20.00 TB 18.00 4.00 TR
+TE
+2.00 18.00 TB 14.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 14.00 TB 6.00 2.00 TR
+TE
+2.00 14.00 TB 18.00 2.00 TR
+TE
+2.00 14.00 TB 24.00 2.00 TR
+TE
+2.00 8.00 TB 12.00 2.00 TR
+TE
+2.00 8.00 TB 20.00 4.00 TR
+TE
+2.00 8.00 TB 26.00 2.00 TR
+TE
+2.00 6.00 TB 16.00 2.00 TR
+TE
+2.00 2.00 TB 12.00 12.00 TR
+TE
+1.00 1.00 0.00 setrgbcolor
+2.00 22.00 TB 6.00 2.00 TR
+TE
+2.00 22.00 TB 14.00 2.00 TR
+TE
+2.00 22.00 TB 22.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 16.00 TB 6.00 2.00 TR
+TE
+2.00 16.00 TB 12.00 2.00 TR
+TE
+2.00 16.00 TB 18.00 2.00 TR
+TE
+2.00 16.00 TB 24.00 2.00 TR
+TE
+2.00 14.00 TB 14.00 4.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 10.00 TB 18.00 2.00 TR
+TE
+2.00 8.00 TB 14.00 4.00 TR
+TE
+2.00 6.00 TB 6.00 2.00 TR
+TE
+2.00 6.00 TB 12.00 2.00 TR
+TE
+2.00 6.00 TB 18.00 4.00 TR
+TE
+2.00 6.00 TB 26.00 2.00 TR
+TE
+2.00 4.00 TB 24.00 2.00 TR
+TE
+2.00 2.00 TB 26.00 2.00 TR
+TE
+0.00 1.00 0.00 setrgbcolor
+2.00 22.00 TB 12.00 2.00 TR
+TE
+2.00 20.00 TB 16.00 2.00 TR
+TE
+2.00 20.00 TB 22.00 6.00 TR
+TE
+2.00 18.00 TB 12.00 2.00 TR
+TE
+2.00 18.00 TB 20.00 2.00 TR
+TE
+2.00 16.00 TB 14.00 2.00 TR
+TE
+2.00 16.00 TB 22.00 2.00 TR
+TE
+2.00 16.00 TB 26.00 2.00 TR
+TE
+2.00 14.00 TB 20.00 2.00 TR
+TE
+2.00 10.00 TB 6.00 2.00 TR
+TE
+2.00 10.00 TB 14.00 2.00 TR
+TE
+2.00 8.00 TB 24.00 2.00 TR
+TE
+2.00 6.00 TB 14.00 2.00 TR
+TE
+2.00 4.00 TB 6.00 2.00 TR
+TE
+2.00 4.00 TB 18.00 6.00 TR
+TE
+2.00 2.00 TB 24.00 2.00 TR
+TE
+0.00 0.00 0.00 setrgbcolor
+2.00 24.00 TB 2.00 28.00 TR
+TE
+2.00 22.00 TB 2.00 2.00 TR
+TE
+22.00 2.00 TB 8.00 2.00 TR
+TE
+22.00 2.00 TB 28.00 2.00 TR
+TE
+2.00 20.00 TB 2.00 4.00 TR
+TE
+2.00 18.00 TB 2.00 2.00 TR
+TE
+2.00 16.00 TB 2.00 4.00 TR
+TE
+2.00 14.00 TB 2.00 2.00 TR
+TE
+2.00 12.00 TB 2.00 4.00 TR
+TE
+2.00 12.00 TB 12.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 2.00 TR
+TE
+2.00 10.00 TB 2.00 2.00 TR
+TE
+2.00 8.00 TB 2.00 4.00 TR
+TE
+2.00 6.00 TB 2.00 2.00 TR
+TE
+2.00 4.00 TB 2.00 4.00 TR
+TE
+2.00 2.00 TB 2.00 2.00 TR
+TE
+2.00 0.00 TB 2.00 28.00 TR
+TE
+1.00 1.00 1.00 setrgbcolor
+2.00 22.00 TB 4.00 2.00 TR
+TE
+22.00 2.00 TB 10.00 2.00 TR
+TE
+2.00 18.00 TB 4.00 2.00 TR
+TE
+2.00 14.00 TB 4.00 2.00 TR
+TE
+2.00 12.00 TB 6.00 2.00 TR
+TE
+2.00 12.00 TB 14.00 2.00 TR
+TE
+2.00 12.00 TB 18.00 2.00 TR
+TE
+2.00 12.00 TB 22.00 2.00 TR
+TE
+2.00 12.00 TB 26.00 2.00 TR
+TE
+2.00 10.00 TB 4.00 2.00 TR
+TE
+2.00 6.00 TB 4.00 2.00 TR
+TE
+2.00 2.00 TB 4.00 2.00 TR
+TE
diff --git a/backend/tests/data/print/bmp/ultracode_a.bmp b/backend/tests/data/print/bmp/ultracode_a.bmp
index 0a47e08d..80bfb824 100644
Binary files a/backend/tests/data/print/bmp/ultracode_a.bmp and b/backend/tests/data/print/bmp/ultracode_a.bmp differ
diff --git a/backend/tests/data/print/emf/ultracode_a.emf b/backend/tests/data/print/emf/ultracode_a.emf
index 94ff6340..2e1296e9 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/print/eps/code128_aim.eps b/backend/tests/data/print/eps/code128_aim.eps
index b734344c..78f277d1 100644
--- a/backend/tests/data/print/eps/code128_aim.eps
+++ b/backend/tests/data/print/eps/code128_aim.eps
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
-%%Creator: Zint 2.8.0
+%%Creator: Zint 2.9.0
%%Title: Zint Generated Symbol
%%Pages: 0
%%BoundingBox: 0 0 136 118
diff --git a/backend/tests/data/print/eps/dotcode_aim_fig7.eps b/backend/tests/data/print/eps/dotcode_aim_fig7.eps
index c701551b..7b207422 100644
--- a/backend/tests/data/print/eps/dotcode_aim_fig7.eps
+++ b/backend/tests/data/print/eps/dotcode_aim_fig7.eps
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
-%%Creator: Zint 2.8.0
+%%Creator: Zint 2.9.0
%%Title: Zint Generated Symbol
%%Pages: 0
%%BoundingBox: 0 0 26 20
diff --git a/backend/tests/data/print/eps/qr_v1_m.eps b/backend/tests/data/print/eps/qr_v1_m.eps
index 1220f2c1..cf473d3a 100644
--- a/backend/tests/data/print/eps/qr_v1_m.eps
+++ b/backend/tests/data/print/eps/qr_v1_m.eps
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
-%%Creator: Zint 2.8.0
+%%Creator: Zint 2.9.0
%%Title: Zint Generated Symbol
%%Pages: 0
%%BoundingBox: 0 0 42 42
diff --git a/backend/tests/data/print/eps/ultracode_a.eps b/backend/tests/data/print/eps/ultracode_a.eps
index cb4cde6d..59a5b773 100644
--- a/backend/tests/data/print/eps/ultracode_a.eps
+++ b/backend/tests/data/print/eps/ultracode_a.eps
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
-%%Creator: Zint 2.8.0
+%%Creator: Zint 2.9.0
%%Title: Zint Generated Symbol
%%Pages: 0
%%BoundingBox: 0 0 26 26
@@ -183,3 +183,26 @@ TE
TE
2.00 0.00 TB 0.00 26.00 TR
TE
+1.00 1.00 1.00 setrgbcolor
+2.00 22.00 TB 2.00 2.00 TR
+TE
+22.00 2.00 TB 8.00 2.00 TR
+TE
+2.00 18.00 TB 2.00 2.00 TR
+TE
+2.00 14.00 TB 2.00 2.00 TR
+TE
+2.00 12.00 TB 4.00 2.00 TR
+TE
+2.00 12.00 TB 12.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 10.00 TB 2.00 2.00 TR
+TE
+2.00 6.00 TB 2.00 2.00 TR
+TE
+2.00 2.00 TB 2.00 2.00 TR
+TE
diff --git a/backend/tests/data/print/svg/ultracode_a.svg b/backend/tests/data/print/svg/ultracode_a.svg
index 7f733427..0a27c08d 100644
--- a/backend/tests/data/print/svg/ultracode_a.svg
+++ b/backend/tests/data/print/svg/ultracode_a.svg
@@ -10,8 +10,10 @@
+
+
@@ -26,6 +28,7 @@
+
@@ -41,6 +44,7 @@
+
@@ -49,11 +53,16 @@
+
+
+
+
+
@@ -66,6 +75,7 @@
+
@@ -82,6 +92,7 @@
+
diff --git a/backend/tests/data/print/txt/ultracode_a.txt b/backend/tests/data/print/txt/ultracode_a.txt
index 2ee57305..7d942617 100644
--- a/backend/tests/data/print/txt/ultracode_a.txt
+++ b/backend/tests/data/print/txt/ultracode_a.txt
@@ -1,13 +1,13 @@
FF F8
-B7 F8
-F7 F8
-B7 F8
-F7 F8
-B7 F8
-D5 58
-B7 F8
-F7 F8
-B7 F8
-F7 F8
-B7 F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
+FF F8
FF F8
diff --git a/backend/tests/test_bmp.c b/backend/tests/test_bmp.c
index 6cd8532a..36d1639a 100644
--- a/backend/tests/test_bmp.c
+++ b/backend/tests/test_bmp.c
@@ -112,10 +112,96 @@ static void test_pixel_plot(int index, int debug) {
testFinish();
}
+static void test_print(int index, int generate, int debug) {
+
+ testStart("");
+
+ int have_identify = testUtilHaveIdentify();
+
+ int ret;
+ struct item {
+ int symbology;
+ int whitespace_width;
+ int option_1;
+ int option_2;
+ char *fgcolour;
+ char *bgcolour;
+ unsigned char* data;
+ char* expected_file;
+ };
+ struct item data[] = {
+ /* 0*/ { BARCODE_PDF417, 5, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/pdf417_fg_bg.bmp" },
+ /* 1*/ { BARCODE_ULTRA, 5, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/ultracode_fg_bg.bmp" },
+ };
+ int data_size = ARRAY_SIZE(data);
+
+ char* data_dir = "../data/bmp";
+ char* bmp = "out.bmp";
+ char escaped[1024];
+ int escaped_size = 1024;
+
+ if (generate) {
+ if (!testUtilExists(data_dir)) {
+ ret = mkdir(data_dir, 0755);
+ assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret);
+ }
+ }
+
+ for (int i = 0; i < data_size; i++) {
+
+ if (index != -1 && i != index) continue;
+
+ struct zint_symbol* symbol = ZBarcode_Create();
+ assert_nonnull(symbol, "Symbol not created\n");
+
+ int 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);
+ if (data[i].whitespace_width != -1) {
+ symbol->whitespace_width = data[i].whitespace_width;
+ }
+ if (data[i].fgcolour != NULL) {
+ strcpy(symbol->fgcolour, data[i].fgcolour);
+ }
+ if (data[i].bgcolour != NULL) {
+ strcpy(symbol->bgcolour, data[i].bgcolour);
+ }
+
+ 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, bmp);
+ 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);
+
+ if (generate) {
+ printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
+ i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, 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 = 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);
+ if (have_identify) {
+ ret = testUtilVerifyIdentify(data[i].expected_file, debug);
+ assert_zero(ret, "i:%d %s identify %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), 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 = testUtilCmpBins(symbol->outfile, data[i].expected_file);
+ assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
+ assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
+ }
+
+ ZBarcode_Delete(symbol);
+ }
+
+ 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 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
diff --git a/backend/tests/test_emf.c b/backend/tests/test_emf.c
index bb391a38..e2ce81a9 100644
--- a/backend/tests/test_emf.c
+++ b/backend/tests/test_emf.c
@@ -30,6 +30,7 @@
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
+#include
static void test_emf(int index, int debug) {
@@ -64,13 +65,7 @@ static void test_emf(int index, int debug) {
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 = 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);
if (data[i].fgcolour != NULL) {
strcpy(symbol->fgcolour, data[i].fgcolour);
}
@@ -80,9 +75,6 @@ static void test_emf(int index, int debug) {
if (data[i].scale != 0) {
symbol->scale = data[i].scale;
}
- symbol->debug | debug;
-
- 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);
@@ -103,10 +95,96 @@ static void test_emf(int index, int debug) {
testFinish();
}
+static void test_print(int index, int generate, int debug) {
+
+ testStart("");
+
+ int have_inkscape = testUtilHaveInkscape();
+
+ int ret;
+ struct item {
+ int symbology;
+ int whitespace_width;
+ int option_1;
+ int option_2;
+ char *fgcolour;
+ char *bgcolour;
+ unsigned char* data;
+ char* expected_file;
+ };
+ struct item data[] = {
+ /* 0*/ { BARCODE_TELEPEN, -1, -1, -1, "147AD0", "FC9630", "123", "../data/emf/telenum_fg_bg.emf" },
+ /* 1*/ { BARCODE_ULTRA, 5, -1, -1, "147AD0", "FC9630", "123", "../data/emf/ultracode_fg_bg.emf" },
+ };
+ int data_size = ARRAY_SIZE(data);
+
+ char* data_dir = "../data/emf";
+ char* emf = "out.emf";
+ char escaped[1024];
+ int escaped_size = 1024;
+
+ if (generate) {
+ if (!testUtilExists(data_dir)) {
+ ret = mkdir(data_dir, 0755);
+ assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret);
+ }
+ }
+
+ for (int i = 0; i < data_size; i++) {
+
+ if (index != -1 && i != index) continue;
+
+ struct zint_symbol* symbol = ZBarcode_Create();
+ assert_nonnull(symbol, "Symbol not created\n");
+
+ int 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);
+ if (data[i].whitespace_width != -1) {
+ symbol->whitespace_width = data[i].whitespace_width;
+ }
+ if (data[i].fgcolour != NULL) {
+ strcpy(symbol->fgcolour, data[i].fgcolour);
+ }
+ if (data[i].bgcolour != NULL) {
+ strcpy(symbol->bgcolour, data[i].bgcolour);
+ }
+
+ 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, emf);
+ 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);
+
+ if (generate) {
+ printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
+ i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, 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 = 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);
+ if (have_inkscape) {
+ ret = testUtilVerifyInkscape(data[i].expected_file, debug);
+ assert_zero(ret, "i:%d %s inkscape %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), 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 = testUtilCmpBins(symbol->outfile, data[i].expected_file);
+ assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
+ assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
+ }
+
+ ZBarcode_Delete(symbol);
+ }
+
+ testFinish();
+}
+
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_emf", test_emf, 1, 0, 1 },
+ { "test_print", test_print, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
diff --git a/backend/tests/test_ps.c b/backend/tests/test_ps.c
new file mode 100644
index 00000000..14057c78
--- /dev/null
+++ b/backend/tests/test_ps.c
@@ -0,0 +1,131 @@
+/*
+ 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
+
+static void test_print(int index, int generate, int debug) {
+
+ testStart("");
+
+ int have_inkscape = testUtilHaveInkscape();
+
+ int ret;
+ struct item {
+ int symbology;
+ int whitespace_width;
+ int option_1;
+ int option_2;
+ char *fgcolour;
+ char *bgcolour;
+ unsigned char *data;
+ char *expected_file;
+ };
+ struct item data[] = {
+ /* 0*/ { BARCODE_CODE39, -1, -1, -1, "147AD0", "FC9630", "123", "../data/eps/code39_fg_bg.eps" },
+ /* 1*/ { BARCODE_ULTRA, 1, -1, -1, "147AD0", "FC9630", "123", "../data/eps/ultra_fg_bg.eps" },
+ };
+ int data_size = ARRAY_SIZE(data);
+
+ char *data_dir = "../data/eps";
+ char *eps = "out.eps";
+ char escaped[1024];
+ int escaped_size = 1024;
+
+ if (generate) {
+ if (!testUtilExists(data_dir)) {
+ ret = mkdir(data_dir, 0755);
+ assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret);
+ }
+ }
+
+ for (int i = 0; i < data_size; i++) {
+
+ if (index != -1 && i != index) continue;
+
+ struct zint_symbol *symbol = ZBarcode_Create();
+ assert_nonnull(symbol, "Symbol not created\n");
+
+ int 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);
+ if (data[i].whitespace_width != -1) {
+ symbol->whitespace_width = data[i].whitespace_width;
+ }
+ if (data[i].fgcolour != NULL) {
+ strcpy(symbol->fgcolour, data[i].fgcolour);
+ }
+ if (data[i].bgcolour != NULL) {
+ strcpy(symbol->bgcolour, data[i].bgcolour);
+ }
+
+ 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, eps);
+ 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);
+
+ if (generate) {
+ printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
+ i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, 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 = 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);
+ if (have_inkscape) {
+ ret = testUtilVerifyInkscape(data[i].expected_file, debug);
+ assert_zero(ret, "i:%d %s inkscape %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), 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 = testUtilCmpEpss(symbol->outfile, data[i].expected_file);
+ assert_zero(ret, "i:%d %s testUtilCmpEpss(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
+ assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
+ }
+
+ ZBarcode_Delete(symbol);
+ }
+
+ testFinish();
+}
+
+int main(int argc, char *argv[]) {
+
+ testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
+ { "test_print", test_print, 1, 1, 1 },
+ };
+
+ testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
+
+ testReport();
+
+ return 0;
+}
diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c
index 4a473365..049ac3da 100644
--- a/backend/tests/test_svg.c
+++ b/backend/tests/test_svg.c
@@ -60,7 +60,7 @@ static void test_print(int index, int generate, int debug) {
/* 10*/ { BARCODE_EANX, -1, -1, "12345", "../data/svg/ean5.svg" },
/* 11*/ { BARCODE_EANX, -1, -1, "12", "../data/svg/ean2.svg" },
};
- int data_size = sizeof(data) / sizeof(struct item);
+ int data_size = ARRAY_SIZE(data);
char *data_dir = "../data/svg";
char *svg = "out.svg";
@@ -81,16 +81,7 @@ static void test_print(int index, int generate, int debug) {
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;
- }
- symbol->debug |= debug;
-
- int length = strlen(data[i].data);
+ int 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);
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);
diff --git a/backend/tests/test_ultra.c b/backend/tests/test_ultra.c
index 3bf7869c..067affff 100644
--- a/backend/tests/test_ultra.c
+++ b/backend/tests/test_ultra.c
@@ -93,7 +93,7 @@ static void test_input(int index, int generate, int debug) {
/* 43*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "tel:AAaa", 0, "(8) 272 275 271 161 6 28 262 118", "Mode: c (8)" },
/* 44*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "AAaatel:aA", 0, "(10) 272 276 0 42 0 41 118 46 6 156", "Mode: c (10)" },
};
- int data_size = sizeof(data) / sizeof(struct item);
+ int data_size = ARRAY_SIZE(data);
char escaped[1024];
@@ -104,19 +104,9 @@ static void test_input(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
- symbol->symbology = BARCODE_ULTRA;
- symbol->input_mode = data[i].input_mode;
- symbol->eci = data[i].eci;
- if (data[i].option_1 != -1) {
- symbol->option_1 = data[i].option_1;
- }
- if (data[i].option_3 != -1) {
- symbol->option_3 = data[i].option_3;
- }
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
- symbol->debug |= debug;
- int length = strlen(data[i].data);
+ int length = testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, data[i].eci, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
@@ -158,279 +148,279 @@ static void test_encode(int index, int generate, int debug) {
struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ULTRACODE_123456789!", 0, 13, 22, "AIMD/TSC15032-43 Figure G.1 **NOT SAME** different compression",
"7777777777777777777777"
- "7057065353533131551057"
- "7767053515611616136717"
- "7037036661565555363057"
- "7717055333616336135717"
- "7037036515535515366057"
- "7707070707070707070707"
- "7067016561133113551017"
- "7737035155311665165737"
- "7067066561155551653057"
- "7737033315616663515717"
- "7017051653331136333057"
+ "7857865353533131551857"
+ "7767853515611616136717"
+ "7837836661565555363857"
+ "7717855333616336135717"
+ "7837836515535515366857"
+ "7787878787878787878787"
+ "7867816561133113551817"
+ "7737835155311665165737"
+ "7867866561155551653857"
+ "7737833315616663515717"
+ "7817851653331136333857"
"7777777777777777777777"
},
/* 1*/ { UNICODE_MODE, 0, -1, -1, "ULTRACODE_123456789!", 0, 13, 24, "AIMD/TSC15032-43 Figure G.1 **NOT SAME** no compression; verified against bwipp",
"777777777777777777777777"
- "705706533153313111101157"
- "776703361661161666676617"
- "703706115156555511303357"
- "776705556561633656175517"
- "703701311653551535501657"
- "770707070707070707070707"
- "706701656113311311101117"
- "775703333531166566676537"
- "701706651315555113303357"
- "776705515161666351175517"
- "701706166533113663603357"
+ "785786533153313111181157"
+ "776783361661161666676617"
+ "783786115156555511383357"
+ "776785556561633656175517"
+ "783781311653551535581657"
+ "778787878787878787878787"
+ "786781656113311311181117"
+ "775783333531166566676537"
+ "781786651315555113383357"
+ "776785515161666351175517"
+ "781786166533113663683357"
"777777777777777777777777"
},
/* 2*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, 19, 23, "AIMD/TSC15032-43 Figure G.2 **NOT SAME** different compression",
"77777777777777777777777"
- "70070663151561555150557"
- "77070315565635366667617"
- "70070666656561115530357"
- "77570535365656556367117"
- "70370153656135163550357"
- "77170707070707070707077"
- "70670156315513136160357"
- "77370533531631615537117"
- "70070361155313351360657"
- "77670515613665166537117"
- "70170651131551335150357"
- "77670707070707070707077"
- "70370535163551333630617"
- "77170111531613611567137"
- "70070566665531335610357"
- "77070151331365561537137"
- "70070333656153153360617"
+ "78878663151561555158557"
+ "77878315565635366667617"
+ "78878666656561115538357"
+ "77578535365656556367117"
+ "78378153656135163558357"
+ "77178787878787878787877"
+ "78678156315513136168357"
+ "77378533531631615537117"
+ "78878361155313351368657"
+ "77678515613665166537117"
+ "78178651131551335158357"
+ "77678787878787878787877"
+ "78378535163551333638617"
+ "77178111531613611567137"
+ "78878566665531335618357"
+ "77878151331365561537137"
+ "78878333656153153368617"
"77777777777777777777777"
},
/* 3*/ { DATA_MODE, 0, -1, -1, "\110\105\111\115\101\123\315\320\101\040\113\105\116\116\101\122\101\110\301\123\113\323\114\101\040\315\123\114\101\116\104\123", 0, 19, 23, "AIMD/TSC15032-43 Figure G.2 **NOT SAME** no compression; verified against bwipp",
"77777777777777777777777"
- "70070633151153313350137"
- "77070315666661161167617"
- "70070663155553555530557"
- "77570531366336136167367"
- "70370155555515653350537"
- "77170707070707070707077"
- "70670135513311133130357"
- "77370513331166611617117"
- "70070351153555533550557"
- "77670613615636356367117"
- "70170156336355515530657"
- "77670707070707070707077"
- "70370615133513355130117"
- "77170136511651166517637"
- "70070365635335515350557"
- "77070613551651656517637"
- "70070361115516163130317"
+ "78878633151153313358137"
+ "77878315666661161167617"
+ "78878663155553555538557"
+ "77578531366336136167367"
+ "78378155555515653358537"
+ "77178787878787878787877"
+ "78678135513311133138357"
+ "77378513331166611617117"
+ "78878351153555533558557"
+ "77678613615636356367117"
+ "78178156336355515538657"
+ "77678787878787878787877"
+ "78378615133513355138117"
+ "77178136511651166517637"
+ "78878365635335515358557"
+ "77878613551651656517637"
+ "78878361115516163138317"
"77777777777777777777777"
},
/* 4*/ { UNICODE_MODE, 10, -1, ULTRA_COMPRESSION, "אולטרה-קוד1234", 0, 13, 19, "AIMD/TSC15032-43 Figure G.3 Same except DCC correct whereas DCC in Figure G.3 is incorrent",
"7777777777777777777"
- "7057065565566616657"
- "7737053333613351517"
- "7067015155551565167"
- "7757053333633356657"
- "7037066561515535537"
- "7707070707070707077"
- "7067013561166666517"
- "7737031653311131137"
- "7017065336156555357"
- "7767016565663636117"
- "7017051316355311357"
+ "7857865565566616657"
+ "7737853333613351517"
+ "7867815155551565167"
+ "7757853333633356657"
+ "7837866561515535537"
+ "7787878787878787877"
+ "7867813561166666517"
+ "7737831653311131137"
+ "7817865336156555357"
+ "7767816565663636117"
+ "7817851316355311357"
"7777777777777777777"
},
/* 5*/ { DATA_MODE, 0, -1, -1, "\340\345\354\350\370\344\055\367\345\343\061\062\063\064", 0, 13, 20, "AIMD/TSC15032-43 Figure G.3 **NOT SAME** no compression; verified against bwipp",
"77777777777777777777"
- "70570611115666161157"
- "77670333656133516617"
- "70170655165515651157"
- "77570516516333565617"
- "70370163335155353557"
- "77070707070707070707"
- "70670153311666661117"
- "77370315553111316637"
- "70570631611565551357"
- "77370166136636365117"
- "70170613653553116357"
+ "78578611115666161157"
+ "77678333656133516617"
+ "78178655165515651157"
+ "77578516516333565617"
+ "78378163335155353557"
+ "77878787878787878787"
+ "78678153311666661117"
+ "77378315553111316637"
+ "78578631611565551357"
+ "77378166136636365117"
+ "78178613653553116357"
"77777777777777777777"
},
/* 6*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "https://aimglobal.org/jcrv3tX", 0, 13, 20, "AIMD/TSC15032-43 Figure G.4a **NOT SAME** different compression; also DCC incorrect in figure",
"77777777777777777777"
- "70570655115631563137"
- "77670563356513315617"
- "70170611665136133337"
- "77570565116663516517"
- "70370311355315331357"
- "77070707070707070707"
- "70670113111111615617"
- "77370331553353561537"
- "70570655311165333157"
- "77370311136331165617"
- "70170163363613633157"
+ "78578655115631563137"
+ "77678563356513315617"
+ "78178611665136133337"
+ "77578565116663516517"
+ "78378311355315331357"
+ "77878787878787878787"
+ "78678113111111615617"
+ "77378331553353561537"
+ "78578655311165333157"
+ "77378311136331165617"
+ "78178163363613633157"
"77777777777777777777"
},
/* 7*/ { GS1_MODE, 0, -1, -1, "[01]03453120000011[17]121125[10]ABCD1234", 0, 13, 23, "AIMD/TSC15032-43 Figure G.6 **NOT SAME** different compression and ECC; also DCC incorrect in figure",
"77777777777777777777777"
- "70570616535355353310157"
- "77670553116631616667617"
- "70370331365353335550567"
- "77570563516616556637657"
- "70370656335135665360337"
- "77070707070707070707077"
- "70670161311353355110517"
- "77570313153616611667137"
- "70170635531563535550357"
- "77370516316135616367117"
- "70170335533356531510357"
+ "78578616535355353318157"
+ "77678553116631616667617"
+ "78378331365353335558567"
+ "77578563516616556637657"
+ "78378656335135665368337"
+ "77878787878787878787877"
+ "78678161311353355118517"
+ "77578313153616611667137"
+ "78178635531563535558357"
+ "77378516316135616367117"
+ "78178335533356531518357"
"77777777777777777777777"
},
/* 8*/ { UNICODE_MODE, 0, -1, -1, "A", 0, 13, 13, "Verified against bwipp",
"7777777777777"
- "7057063335517"
- "7717035163667"
- "7067061551557"
- "7757056115637"
- "7037013636557"
- "7707070707077"
- "7067011361117"
- "7717033133337"
- "7057011355157"
- "7737065163617"
- "7017033536357"
+ "7857863335517"
+ "7717835163667"
+ "7867861551557"
+ "7757856115637"
+ "7837813636557"
+ "7787878787877"
+ "7867811361117"
+ "7717833133337"
+ "7857811355157"
+ "7737865163617"
+ "7817833536357"
"7777777777777"
},
/* 9*/ { UNICODE_MODE, 0, 2, -1, "12345678901234567890123", 0, 13, 25, "Length 23 == 26 MCC (C) with EC1 so 7 ECC by Table 12",
"7777777777777777777777777"
- "7057063655511111111011117"
- "7767031563666666666766667"
- "7057063315511333113033117"
- "7717055133656155561755567"
- "7037011366535516355016357"
- "7707070707070707070707077"
- "7067013331111111111011117"
- "7757051515366666666766637"
- "7037016363113331133031157"
- "7757051535651153511753517"
- "7017035653363636636036657"
+ "7857863655511111111811117"
+ "7767831563666666666766667"
+ "7857863315511333113833117"
+ "7717855133656155561755567"
+ "7837811366535516355816357"
+ "7787878787878787878787877"
+ "7867813331111111111811117"
+ "7757851515366666666766637"
+ "7837816363113331133831157"
+ "7757851535651153511753517"
+ "7817835653363636636836657"
"7777777777777777777777777"
},
/* 10*/ { UNICODE_MODE, 0, 1, -1, "1", 0, 13, 11, "Figure 3a min 2-row, EC0; verified against bwipp",
"77777777777"
- "70570661517"
- "77170355667"
- "70370666517"
- "77670551657"
- "70370135537"
- "77070707077"
- "70670151117"
- "77170333337"
- "70370115117"
- "77570631357"
- "70170365567"
+ "78578661517"
+ "77178355667"
+ "78378666517"
+ "77678551657"
+ "78378135537"
+ "77878787877"
+ "78678151117"
+ "77178333337"
+ "78378115117"
+ "77578631357"
+ "78178365567"
"77777777777"
},
/* 11*/ { UNICODE_MODE, 0, 6, -1, "123456789012345678901", 0, 13, 27, "Figure 3a max 2-row, EC5",
"777777777777777777777777777"
- "705706316551651111101111117"
- "771703535313166666676666667"
- "703706166556351133301133317"
- "771705311313665615575615557"
- "706701655165353551603551637"
- "770707070707070707070707077"
- "703701165561111111101111117"
- "771705336136536666676666637"
- "703701113655351333101333157"
- "775703635331635115375115367"
- "701705553563556363606363637"
+ "785786316551651111181111117"
+ "771783535313166666676666667"
+ "783786166556351133381133317"
+ "771785311313665615575615557"
+ "786781655165353551683551637"
+ "778787878787878787878787877"
+ "783781165561111111181111117"
+ "771785336136536666676666637"
+ "783781113655351333181333157"
+ "775783635331635115375115367"
+ "781785553563556363686363637"
"777777777777777777777777777"
},
/* 12*/ { UNICODE_MODE, 0, 6, -1, "1234567890123456789012345678901234567890123456789012", 0, 19, 36, "Figure 3b max 3-row, EC5",
"777777777777777777777777777777777777"
- "700706363653513111101111111111111117"
- "770703511165156356676666666666666667"
- "700706155316333511303133133113313317"
- "775705516633156156175515515361551557"
- "701701335356661335606653331656665337"
- "773707070707070707070707070707070707"
- "705701313116156311101111111111111117"
- "776706665563633166676666666666666667"
- "700703316155566513301133133133113317"
- "773705165316651651573615515515361557"
- "701701556535515533106566653331656667"
- "773707070707070707070707070707070707"
- "706701333331113511101111111111111117"
- "771705161113336666676666666666666657"
- "700703313565163513301331133133133137"
- "770705661613551651575153615515515317"
- "700703155555336565303316566653331637"
+ "788786363653513111181111111111111117"
+ "778783511165156356676666666666666667"
+ "788786155316333511383133133113313317"
+ "775785516633156156175515515361551557"
+ "781781335356661335686653331656665337"
+ "773787878787878787878787878787878787"
+ "785781313116156311181111111111111117"
+ "776786665563633166676666666666666667"
+ "788783316155566513381133133133113317"
+ "773785165316651651573615515515361557"
+ "781781556535515533186566653331656667"
+ "773787878787878787878787878787878787"
+ "786781333331113511181111111111111117"
+ "771785161113336666676666666666666657"
+ "788783313565163513381331133133133137"
+ "778785661613551651575153615515515317"
+ "788783155555336565383316566653331637"
"777777777777777777777777777777777777"
},
/* 13*/ { UNICODE_MODE, 0, 6, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 0, 25, 49, "Figure 3c max 4-row, EC5",
"7777777777777777777777777777777777777777777777777"
- "7007061565635135151011111111111111101111111111117"
- "7707035151513316566766666666666666676666666666667"
- "7007061536666531351031331313313133103133131331317"
- "7707056653153315566755156551565515675515655156557"
- "7007013366335656655013565135651356501356513565137"
- "7707070707070707070707070707070707070707070707077"
- "7057036636366363311011111111111111101111111111117"
- "7737055565651635656766666666666666676666666666667"
- "7017061653316513563031313313133131303131331313317"
- "7757056561153165131755131551315513175513155131557"
- "7067063135615536653036663366633666303666336663367"
- "7707070707070707070707070707070707070707070707077"
- "7037056156651155111011111111111111101111111111117"
- "7717015565563561566766666666666666676666666666667"
- "7067066631136356613031313313133131303131331313317"
- "7737031365663161551756551565515655175655156551567"
- "7017065156355516135065135651356513506513565135657"
- "7707070707070707070707070707070707070707070707077"
- "7007053555355533511011111111111111101111111111117"
- "7707035616631351166766666666666666676666666666657"
- "7007063363316563613013313133131331301331313313167"
- "7707031111653311551731551315513155173155131551357"
- "7007016565561165166063366633666336606336663366637"
+ "7887861565635135151811111111111111181111111111117"
+ "7787835151513316566766666666666666676666666666667"
+ "7887861536666531351831331313313133183133131331317"
+ "7787856653153315566755156551565515675515655156557"
+ "7887813366335656655813565135651356581356513565137"
+ "7787878787878787878787878787878787878787878787877"
+ "7857836636366363311811111111111111181111111111117"
+ "7737855565651635656766666666666666676666666666667"
+ "7817861653316513563831313313133131383131331313317"
+ "7757856561153165131755131551315513175513155131557"
+ "7867863135615536653836663366633666383666336663367"
+ "7787878787878787878787878787878787878787878787877"
+ "7837856156651155111811111111111111181111111111117"
+ "7717815565563561566766666666666666676666666666667"
+ "7867866631136356613831313313133131383131331313317"
+ "7737831365663161551756551565515655175655156551567"
+ "7817865156355516135865135651356513586513565135657"
+ "7787878787878787878787878787878787878787878787877"
+ "7887853555355533511811111111111111181111111111117"
+ "7787835616631351166766666666666666676666666666657"
+ "7887863363316563613813313133131331381331313313167"
+ "7787831111653311551731551315513155173155131551357"
+ "7887816565561165166863366633666336686336663366637"
"7777777777777777777777777777777777777777777777777"
},
/* 14*/ { UNICODE_MODE, 0, 6, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 0, 31, 66, "Figure 3d max 5-row, EC5 **NOT SAME** Max columns due to 282 limit is 60 not 61 as shown",
"777777777777777777777777777777777777777777777777777777777777777777"
- "700706655166656555306351111111111110111111111111111011111111111117"
- "770703331611363336575566666666666667666666666666666766666666666667"
- "700706555153116611103153333333333330333333333333333033333333333337"
- "770705361635661566576361515151515157151515151515151751515151515157"
- "700701513513555315303653636363636360363636363636363063636363636367"
- "770707070707070707070707070707070707070707070707070707070707070707"
- "700705316656355536606131111111111110111111111111111011111111111157"
- "770706653365566155373316666666666667666666666666666766666666666617"
- "700703361516133633605633131313131310313131313131313013131313131357"
- "775705513161356156176361313131313137131313131313131731313131313117"
- "706706166533165615303615656565656560565656565656565065656565656557"
- "775707070707070707070707070707070707070707070707070707070707070707"
- "701703651151633136506611111111111110111111111111111011111111111157"
- "776706533613515615373566666666666667666666666666666766666666666617"
- "700701365531653133101613131313131310313131313131313013131313131357"
- "773703113156366615576151515151515157151515151515151751515151515117"
- "706706351535111563305536363636363630636363636363636036363636363657"
- "773707070707070707070707070707070707070707070707070707070707070707"
- "705705611111515333605311111111111110111111111111111011111111111157"
- "771703336366133651571166666666666667666666666666666766666666666617"
- "700706513535351316103313131313131310313131313131313013131313131357"
- "770703131151115535575555555555555557555555555555555755555555555517"
- "700705665366536111306661616161616160161616161616161061616161616157"
- "770707070707070707070707070707070707070707070707070707070707070707"
- "700706355163151355603611111111111110111111111111111011111111111137"
- "770703563615515136176566666666666667666666666666666766666666666617"
- "700705655136333561505613131313131310313131313131313013131313131357"
- "770701136561611613373365656565656567565656565656565765656565656517"
- "700703663313553565506153535353535350353535353535353053535353535357"
+ "788786655166656555386351111111111118111111111111111811111111111117"
+ "778783331611363336575566666666666667666666666666666766666666666667"
+ "788786555153116611183153333333333338333333333333333833333333333337"
+ "778785361635661566576361515151515157151515151515151751515151515157"
+ "788781513513555315383653636363636368363636363636363863636363636367"
+ "778787878787878787878787878787878787878787878787878787878787878787"
+ "788785316656355536686131111111111118111111111111111811111111111157"
+ "778786653365566155373316666666666667666666666666666766666666666617"
+ "788783361516133633685633131313131318313131313131313813131313131357"
+ "775785513161356156176361313131313137131313131313131731313131313117"
+ "786786166533165615383615656565656568565656565656565865656565656557"
+ "775787878787878787878787878787878787878787878787878787878787878787"
+ "781783651151633136586611111111111118111111111111111811111111111157"
+ "776786533613515615373566666666666667666666666666666766666666666617"
+ "788781365531653133181613131313131318313131313131313813131313131357"
+ "773783113156366615576151515151515157151515151515151751515151515117"
+ "786786351535111563385536363636363638636363636363636836363636363657"
+ "773787878787878787878787878787878787878787878787878787878787878787"
+ "785785611111515333685311111111111118111111111111111811111111111157"
+ "771783336366133651571166666666666667666666666666666766666666666617"
+ "788786513535351316183313131313131318313131313131313813131313131357"
+ "778783131151115535575555555555555557555555555555555755555555555517"
+ "788785665366536111386661616161616168161616161616161861616161616157"
+ "778787878787878787878787878787878787878787878787878787878787878787"
+ "788786355163151355683611111111111118111111111111111811111111111137"
+ "778783563615515136176566666666666667666666666666666766666666666617"
+ "788785655136333561585613131313131318313131313131313813131313131357"
+ "778781136561611613373365656565656567565656565656565765656565656517"
+ "788783663313553565586153535353535358353535353535353853535353535357"
"777777777777777777777777777777777777777777777777777777777777777777"
},
};
- int data_size = sizeof(data) / sizeof(struct item);
+ int data_size = ARRAY_SIZE(data);
char escaped[1024];
@@ -441,18 +431,7 @@ static void test_encode(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
- symbol->symbology = BARCODE_ULTRA;
- symbol->input_mode = data[i].input_mode;
- symbol->eci = data[i].eci;
- if (data[i].option_1 != -1) {
- symbol->option_1 = data[i].option_1;
- }
- if (data[i].option_3 != -1) {
- symbol->option_3 = data[i].option_3;
- }
- symbol->debug |= debug;
-
- int length = strlen(data[i].data);
+ int length = testUtilSetSymbol(symbol, BARCODE_ULTRA, data[i].input_mode, data[i].eci, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
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);