comparison mupdf-source/thirdparty/zint/backend_qt/tests/test_qzint.cpp @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /***************************************************************************
2 * Copyright (C) 2021-2024 by Robin Stuart <rstuart114@gmail.com> *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * You should have received a copy of the GNU General Public License *
13 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14 ***************************************************************************/
15 /* SPDX-License-Identifier: GPL-3.0-or-later */
16
17 #include <QtTest/QSignalSpy>
18 #include <QtTest/QTest>
19 #include "../qzint.h" /* Don't use <qzint.h> in case it's been changed */
20
21 #define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
22
23 // Whether using ZINT_SANITIZE
24 #if !defined(__has_feature)
25 # define __has_feature(x) 0
26 #endif
27 #if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
28 # define TESTQZINT_HAVE_ASAN
29 #endif
30
31 class TestQZint : public QObject
32 {
33 Q_OBJECT
34
35 // This avoids WaylandClient memory leaks for Qt5 > 5.15.2 (taken from "frontend_qt/main.cpp")
36 #if defined(__linux__) && QT_VERSION > 0x50F02
37 public:
38 static void initMain()
39 {
40 /* Not compatible with Wayland for some reason(s) so use X11 unless overridden */
41 if (qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM")) {
42 qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb"));
43 }
44 }
45 #endif
46
47 public:
48 TestQZint() : m_skipIfFontUsed(false)
49 {
50 // Qt will trigger "detected memory leaks" if font used (libfontconfig) so skip if ASAN enabled
51 #ifdef TESTQZINT_HAVE_ASAN
52 m_skipIfFontUsed = true;
53 #endif
54 // Unfortunately Qt5 > 5.15.13 & Qt6 > 6.4.2 have further libfontconfig leaks which this doesn't address...
55 // ...only option found so far is to use `QTEST_GUILESS_MAIN()` and skip `renderTest()` completely
56 #if defined(__linux__) && ((QT_VERSION > 0x50F0D && QT_VERSION < 0x60000) || QT_VERSION > 0x60402) \
57 && defined(TESTQZINT_HAVE_ASAN)
58 #define TESTQZINT_GUILESS
59 #endif
60 }
61
62 virtual ~TestQZint() {} // Seems to be needed to generate vtable
63
64 private:
65 bool m_skipIfFontUsed; // Hack to get around Qt5 ASAN leaks
66
67 private slots:
68
69 void setGetTest()
70 {
71 Zint::QZint bc;
72
73 int symbology = BARCODE_CODE11;
74 bc.setSymbol(symbology);
75 QCOMPARE(bc.symbol(), symbology);
76
77 int inputMode = UNICODE_MODE;
78 bc.setInputMode(inputMode);
79 QCOMPARE(bc.inputMode(), inputMode);
80
81 QString text("text");
82 bc.setText(text);
83 QCOMPARE(bc.text(), text);
84 QCOMPARE(bc.segs().empty(), true);
85
86 std::vector<QString> segTexts;
87 std::vector<int> segECIs;
88 segTexts.push_back(QString("Τεχτ"));
89 segECIs.push_back(9);
90 segTexts.push_back(QString("貫やぐ禁"));
91 segECIs.push_back(20);
92 segTexts.push_back(QString("กขฯ"));
93 segECIs.push_back(13);
94
95 std::vector<Zint::QZintSeg> segs;
96 for (int i = 0; i < (int) segTexts.size(); i++) {
97 segs.push_back(Zint::QZintSeg(segTexts[i]));
98 segs.back().m_eci = segECIs[i];
99 }
100
101 bc.setSegs(segs);
102 QCOMPARE(bc.segs().size(), segs.size());
103 for (int i = 0; i < (int) segs.size(); i++) {
104 QCOMPARE(bc.segs()[i].m_text, segTexts[i]);
105 QCOMPARE(bc.segs()[i].m_eci, segECIs[i]);
106 }
107 QCOMPARE(bc.text().isEmpty(), true);
108 QCOMPARE(bc.eci(), segECIs[0]);
109
110 bc.setText(text);
111 QCOMPARE(bc.text(), text);
112 QCOMPARE(bc.segs().empty(), true);
113
114 QString primaryMessage("primary message");
115 bc.setPrimaryMessage(primaryMessage);
116 QCOMPARE(bc.primaryMessage(), primaryMessage);
117
118 float height = 12.345f;
119 bc.setHeight(height);
120 QCOMPARE(bc.height(), height);
121
122 int option1 = 1;
123 bc.setOption1(option1);
124 QCOMPARE(bc.option1(), option1);
125
126 int option2 = 2;
127 bc.setOption2(option2);
128 QCOMPARE(bc.option2(), option2);
129
130 int option3 = 3;
131 bc.setOption3(option3);
132 QCOMPARE(bc.option3(), option3);
133
134 float scale = 0.678f;
135 bc.setScale(scale);
136 QCOMPARE(bc.scale(), scale);
137
138 float dpmm = 11.811f;
139 bc.setDPMM(dpmm);
140 QCOMPARE(bc.dpmm(), dpmm);
141
142 bool dotty = true;
143 bc.setDotty(dotty);
144 QCOMPARE(bc.dotty(), dotty);
145
146 float dotSize = 1.234f;
147 bc.setDotSize(dotSize);
148 QCOMPARE(bc.dotSize(), dotSize);
149
150 float textGap = 4.321f;
151 bc.setTextGap(textGap);
152 QCOMPARE(bc.textGap(), textGap);
153
154 float guardDescent = 0.678f;
155 bc.setGuardDescent(guardDescent);
156 QCOMPARE(bc.guardDescent(), guardDescent);
157
158 struct zint_structapp structapp = { 2, 3, "ID" };
159 bc.setStructApp(structapp.count, structapp.index, structapp.id);
160 QCOMPARE(bc.structAppCount(), structapp.count);
161 QCOMPARE(bc.structAppIndex(), structapp.index);
162 QCOMPARE(bc.structAppID(), QString(structapp.id));
163
164 QString fgStr("12344567");
165 bc.setFgStr(fgStr);
166 QCOMPARE(bc.fgStr(), fgStr);
167
168 QColor fgColor(0x12, 0x34, 0x45, 0x67);
169 bc.setFgColor(fgColor);
170 QCOMPARE(bc.fgColor(), fgColor);
171 QCOMPARE(bc.fgStr(), fgStr);
172
173 QString bgStr("89ABCDEF");
174 bc.setBgStr(bgStr);
175 QCOMPARE(bc.bgStr(), bgStr);
176
177 QColor bgColor(0x89, 0xAB, 0xCD, 0xEF);
178 bc.setBgColor(bgColor);
179 QCOMPARE(bc.bgColor(), bgColor);
180 QCOMPARE(bc.bgStr(), bgStr);
181
182 QString bgStr2("71,0,40,44");
183 bc.setBgStr(bgStr2);
184 QCOMPARE(bc.bgStr(), bgStr2);
185
186 bool cmyk = true;
187 bc.setCMYK(cmyk);
188 QCOMPARE(bc.cmyk(), cmyk);
189
190 int borderTypes[] = { 0, BARCODE_BIND, BARCODE_BOX, BARCODE_BIND_TOP };
191 for (int i = 0; i < ARRAY_SIZE(borderTypes); i++) {
192 bc.setBorderType(i);
193 QCOMPARE(bc.borderType(), borderTypes[i]);
194 }
195
196 int borderWidth = 4;
197 bc.setBorderWidth(borderWidth);
198 QCOMPARE(bc.borderWidth(), borderWidth);
199
200 int whitespace = 5;
201 bc.setWhitespace(whitespace);
202 QCOMPARE(bc.whitespace(), whitespace);
203
204 int vWhitespace = 6;
205 bc.setVWhitespace(vWhitespace);
206 QCOMPARE(bc.vWhitespace(), vWhitespace);
207
208 int fontSettings[] = { 0, BOLD_TEXT, SMALL_TEXT, SMALL_TEXT | BOLD_TEXT };
209 for (int i = 0; i < ARRAY_SIZE(fontSettings); i++) {
210 bc.setFontSetting(i);
211 QCOMPARE(bc.fontSetting(), fontSettings[i]);
212
213 bc.setFontSettingValue(fontSettings[i]);
214 QCOMPARE(bc.fontSetting(), fontSettings[i]);
215 }
216 bc.setFontSetting(ARRAY_SIZE(fontSettings));
217 QCOMPARE(bc.fontSetting(), 0);
218 bc.setFontSetting(-1);
219 QCOMPARE(bc.fontSetting(), 0);
220
221 bc.setFontSettingValue(-1);
222 QCOMPARE(bc.fontSetting(), 0);
223 bc.setFontSettingValue(CMYK_COLOUR);
224 QCOMPARE(bc.fontSetting(), 0);
225
226 bool showText = false;
227 bc.setShowText(showText);
228 QCOMPARE(bc.showText(), showText);
229
230 bool gsSep = true;
231 bc.setGSSep(gsSep);
232 QCOMPARE(bc.gsSep(), gsSep);
233
234 bool quietZones = true;
235 bc.setQuietZones(quietZones);
236 QCOMPARE(bc.quietZones(), quietZones);
237
238 bool noQuietZones = true;
239 bc.setNoQuietZones(noQuietZones);
240 QCOMPARE(bc.noQuietZones(), noQuietZones);
241
242 bool compliantHeight = true;
243 bc.setCompliantHeight(compliantHeight);
244 QCOMPARE(bc.compliantHeight(), compliantHeight);
245
246 int rotateAngles[] = { 0, 90, 180, 270 };
247 for (int i = 0; i < ARRAY_SIZE(rotateAngles); i++) {
248 bc.setRotateAngle(i);
249 QCOMPARE(bc.rotateAngle(), rotateAngles[i]);
250
251 bc.setRotateAngleValue(rotateAngles[i]);
252 QCOMPARE(bc.rotateAngle(), rotateAngles[i]);
253 }
254 bc.setRotateAngle(ARRAY_SIZE(rotateAngles));
255 QCOMPARE(bc.rotateAngle(), 0);
256 bc.setRotateAngle(-1);
257 QCOMPARE(bc.rotateAngle(), 0);
258
259 bc.setRotateAngleValue(-1);
260 QCOMPARE(bc.rotateAngle(), 0);
261 bc.setRotateAngleValue(45);
262 QCOMPARE(bc.rotateAngle(), 0);
263
264 int ecis[] = {
265 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
266 12, 13, 15, 16, 17, 18, 20, 21, 22, 23,
267 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
268 34, 35, 170, 899,
269 };
270 for (int i = 0; i < ARRAY_SIZE(ecis); i++) {
271 bc.setECI(i);
272 QCOMPARE(bc.eci(), ecis[i]);
273
274 bc.setECIValue(ecis[i]);
275 QCOMPARE(bc.eci(), ecis[i]);
276 }
277 bc.setECI(ARRAY_SIZE(ecis));
278 QCOMPARE(bc.eci(), 0);
279 bc.setECI(-1);
280 QCOMPARE(bc.eci(), 0);
281 // See also setGetECIValueTest()
282
283 bool gs1Parens = true;
284 bc.setGS1Parens(gs1Parens);
285 QCOMPARE(bc.gs1Parens(), gs1Parens);
286
287 bool gs1NoCheck = true;
288 bc.setGS1NoCheck(gs1NoCheck);
289 QCOMPARE(bc.gs1NoCheck(), gs1NoCheck);
290
291 bool readerInit = true;
292 bc.setReaderInit(readerInit);
293 QCOMPARE(bc.readerInit(), readerInit);
294
295 bool guardWhitespace = true;
296 bc.setGuardWhitespace(guardWhitespace);
297 QCOMPARE(bc.guardWhitespace(), guardWhitespace);
298
299 bool embedVectorFont = true;
300 bc.setEmbedVectorFont(embedVectorFont);
301 QCOMPARE(bc.embedVectorFont(), embedVectorFont);
302
303 int warnLevel = WARN_FAIL_ALL;
304 bc.setWarnLevel(warnLevel);
305 QCOMPARE(bc.warnLevel(), warnLevel);
306
307 bool debug = true;
308 bc.setDebug(debug);
309 QCOMPARE(bc.debug(), debug);
310
311 QCOMPARE(bc.encodedWidth(), 0); // Read-only
312 QCOMPARE(bc.encodedRows(), 0); // Read-only
313 QCOMPARE(bc.encodedHeight(), 0.0f); // Read-only
314
315 QCOMPARE(bc.vectorWidth(), 0.0f); // Read-only
316 QCOMPARE(bc.vectorHeight(), 0.0f); // Read-only
317
318 QCOMPARE(bc.takesGS1AIData(BARCODE_CODE128), false);
319 QCOMPARE(bc.takesGS1AIData(BARCODE_GS1_128), true);
320 }
321
322 void setGetECIValueTest_data()
323 {
324 QTest::addColumn<int>("value");
325 QTest::addColumn<int>("eci");
326
327 QTest::newRow("-1") << -1 << 0;
328 QTest::newRow("0") << 0 << 0;
329 QTest::newRow("1") << 1 << 0;
330 QTest::newRow("2") << 2 << 0;
331 QTest::newRow("14") << 14 << 0;
332 QTest::newRow("19") << 19 << 0;
333 QTest::newRow("31") << 31 << 31;
334 QTest::newRow("36") << 36 << 0;
335 QTest::newRow("169") << 169 << 0;
336 QTest::newRow("171") << 171 << 0;
337 QTest::newRow("898") << 898 << 0;
338 QTest::newRow("900") << 900 << 0;
339 QTest::newRow("1000") << 1000 << 0;
340 }
341
342 void setGetECIValueTest()
343 {
344 Zint::QZint bc;
345
346 QFETCH(int, value);
347 QFETCH(int, eci);
348
349 bc.setECIValue(value);
350 QCOMPARE(bc.eci(), eci);
351 }
352
353 void legacyTest()
354 {
355 Zint::QZint bc;
356
357 int width = 12;
358 bc.setWidth(width);
359 QCOMPARE(bc.width(), width);
360 QCOMPARE(bc.option2(), width);
361
362 int securityLevel = 2;
363 bc.setSecurityLevel(securityLevel);
364 QCOMPARE(bc.securityLevel(), securityLevel);
365 QCOMPARE(bc.option1(), securityLevel);
366
367 int pdf417CodeWords = 123;
368 bc.setPdf417CodeWords(pdf417CodeWords);
369 QCOMPARE(bc.pdf417CodeWords(), 0); // No-op
370
371 bool hideText = true;
372 bc.setHideText(hideText);
373 QCOMPARE(bc.showText(), !hideText);
374
375 // No get for target size
376 }
377
378 void capTest_data()
379 {
380 QTest::addColumn<int>("symbology");
381 QTest::addColumn<int>("cap_flag");
382
383 QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11
384 << (ZINT_CAP_HRT | ZINT_CAP_STACKABLE);
385 QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128
386 << (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_READER_INIT);
387 QTest::newRow("BARCODE_EANX") << BARCODE_EANX
388 << (ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES
389 | ZINT_CAP_COMPLIANT_HEIGHT);
390 QTest::newRow("BARCODE_EANX_CC") << BARCODE_EANX_CC
391 << (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES
392 | ZINT_CAP_COMPLIANT_HEIGHT);
393 QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE
394 << (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE
395 | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP);
396 }
397
398 void capTest()
399 {
400 Zint::QZint bc;
401
402 QFETCH(int, symbology);
403 QFETCH(int, cap_flag);
404
405 bc.setSymbol(symbology);
406 QCOMPARE(bc.hasHRT(), (cap_flag & ZINT_CAP_HRT) != 0);
407 QCOMPARE(bc.isStackable(), (cap_flag & ZINT_CAP_STACKABLE) != 0);
408 QCOMPARE(bc.isExtendable(), (cap_flag & ZINT_CAP_EXTENDABLE) != 0);
409 QCOMPARE(bc.isComposite(), (cap_flag & ZINT_CAP_COMPOSITE) != 0);
410 QCOMPARE(bc.supportsECI(), (cap_flag & ZINT_CAP_ECI) != 0);
411 QCOMPARE(bc.supportsGS1(), (cap_flag & ZINT_CAP_GS1) != 0);
412 QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
413 QCOMPARE(bc.hasDefaultQuietZones(), (cap_flag & ZINT_CAP_QUIET_ZONES) != 0);
414 QCOMPARE(bc.isFixedRatio(), (cap_flag & ZINT_CAP_FIXED_RATIO) != 0);
415 QCOMPARE(bc.supportsReaderInit(), (cap_flag & ZINT_CAP_READER_INIT) != 0);
416 QCOMPARE(bc.supportsFullMultibyte(), (cap_flag & ZINT_CAP_FULL_MULTIBYTE) != 0);
417 QCOMPARE(bc.hasMask(), (cap_flag & ZINT_CAP_MASK) != 0);
418 QCOMPARE(bc.supportsStructApp(), (cap_flag & ZINT_CAP_STRUCTAPP) != 0);
419 QCOMPARE(bc.hasCompliantHeight(), (cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) != 0);
420 }
421
422 void renderTest_data()
423 {
424 QTest::addColumn<int>("symbology");
425 QTest::addColumn<QString>("text");
426 QTest::addColumn<float>("scale");
427 QTest::addColumn<int>("getError");
428 QTest::addColumn<QString>("error_message");
429 QTest::addColumn<int>("encodedWidth");
430 QTest::addColumn<int>("encodedRows");
431 QTest::addColumn<float>("encodedHeight");
432 QTest::addColumn<float>("vectorWidth");
433 QTest::addColumn<float>("vectorHeight");
434
435 QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << "1234" << 0.0f << 0 << "" << 57 << 1 << 50.0f << 114.0f << 100.0f;
436 QTest::newRow("BARCODE_CODE128 Scale 2") << BARCODE_CODE128 << "1234" << 2.0f << 0 << "" << 57 << 1 << 50.0f << 228.0f << 200.0f;
437 QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0.0f << 0 << "" << 21 << 21 << 21.0f << 42.0f << 42.0f;
438 QTest::newRow("BARCODE_QRCODE Scale 1.5") << BARCODE_QRCODE << "1234" << 1.5f << 0 << "" << 21 << 21 << 21.0f << 63.0f << 63.0f;
439 if (!m_skipIfFontUsed) {
440 QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << 0.0f << ZINT_ERROR_INVALID_DATA << "Error 228: No input data (segment 0 empty)" << 0 << 0 << 0.0f << 0.0f << 0.0f;
441 }
442 QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "1234" << 0.0f << 0 << "" << 30 << 33 << 28.578f << 60.0f << 57.7334f;
443 QTest::newRow("BARCODE_MAXICODE Scale 2") << BARCODE_MAXICODE << "1234" << 2.0f << 0 << "" << 30 << 33 << 28.578f << 120.0f << 115.467f;
444 }
445
446 void renderTest()
447 {
448 #ifdef TESTQZINT_GUILESS
449 QSKIP("disabled on Linux for Qt5 > 5.15.13 & Qt6 > 6.4.2 due to memory leaks (ZINT_SANITIZE)");
450 #endif
451 Zint::QZint bc;
452
453 bool bRet;
454 QPainter painter;
455 constexpr int width = 100, height = 100;
456 QPixmap paintDevice(width, height);
457 QRectF paintRect(0, 0, width, height);
458 Zint::QZint::AspectRatioMode mode;
459 QSignalSpy spyEncoded(&bc, SIGNAL(encoded()));
460 QSignalSpy spyErrored(&bc, SIGNAL(errored()));
461
462 mode = Zint::QZint::AspectRatioMode::KeepAspectRatio; // Legacy - ignored
463
464 QFETCH(int, symbology);
465 QFETCH(QString, text);
466 QFETCH(float, scale);
467 QFETCH(int, getError);
468 QFETCH(QString, error_message);
469 QFETCH(int, encodedWidth);
470 QFETCH(int, encodedRows);
471 QFETCH(float, encodedHeight);
472 QFETCH(float, vectorWidth);
473 QFETCH(float, vectorHeight);
474
475 bc.setSymbol(symbology);
476 bc.setText(text);
477 bc.setShowText(false);
478 if (scale) {
479 bc.setScale(scale);
480 }
481
482 bRet = painter.begin(&paintDevice);
483 QCOMPARE(bRet, true);
484
485 bc.render(painter, paintRect, mode);
486
487 bRet = painter.end();
488 QCOMPARE(bRet, true);
489
490 QCOMPARE(bc.getError(), getError);
491 QCOMPARE(bc.error_message(), error_message);
492 QCOMPARE(bc.lastError(), error_message);
493 QCOMPARE(bc.hasErrors(), getError != 0);
494 QCOMPARE(bc.encodedWidth(), encodedWidth);
495 QCOMPARE(bc.encodedRows(), encodedRows);
496 QCOMPARE(bc.encodedHeight(), encodedHeight);
497 QCOMPARE(bc.vectorWidth(), vectorWidth);
498 QCOMPARE(bc.vectorHeight(), vectorHeight);
499
500 if (getError) {
501 QCOMPARE(spyEncoded.count(), 0);
502 QCOMPARE(spyErrored.count(), 1);
503 } else {
504 QCOMPARE(spyEncoded.count(), 1);
505 QCOMPARE(spyErrored.count(), 0);
506 }
507 }
508
509 void saveToFileTest_data()
510 {
511 QTest::addColumn<int>("symbology");
512 QTest::addColumn<QString>("text");
513 QTest::addColumn<QString>("fileName");
514 QTest::addColumn<bool>("expected_bRet");
515
516 QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.gif" << true;
517 QTest::newRow("BARCODE_DATAMATRIX unknown format") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.ext" << false;
518 QTest::newRow("BARCODE_DATAMATRIX UTF8 gif") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file_τ.gif" << true;
519 QTest::newRow("BARCODE_DATAMATRIX too long (unknown format)") << BARCODE_DATAMATRIX << "1234"
520 << "test_6789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.gif" // 256 long so should be truncated to end in ".gi"
521 << false;
522 }
523
524 void saveToFileTest()
525 {
526 Zint::QZint bc;
527
528 bool bRet;
529
530 QFETCH(int, symbology);
531 QFETCH(QString, text);
532 QFETCH(QString, fileName);
533 QFETCH(bool, expected_bRet);
534
535 bc.setSymbol(symbology);
536 bc.setText(text);
537
538 bRet = bc.save_to_file(fileName);
539 QCOMPARE(bRet, expected_bRet);
540
541 if (bRet) {
542 bRet = QFile::remove(fileName);
543 QCOMPARE(bRet, true);
544 }
545 }
546
547 void getAsCLITest_data()
548 {
549 QTest::addColumn<bool>("autoHeight");
550 QTest::addColumn<float>("heightPerRow");
551 QTest::addColumn<QString>("outfile");
552
553 QTest::addColumn<int>("symbology");
554 QTest::addColumn<int>("inputMode");
555
556 QTest::addColumn<QString>("text");
557 QTest::addColumn<QString>("primary");
558
559 QTest::addColumn<float>("height");
560 QTest::addColumn<int>("option1");
561 QTest::addColumn<int>("option2");
562 QTest::addColumn<int>("option3");
563 QTest::addColumn<float>("scale");
564 QTest::addColumn<float>("dpmm");
565 QTest::addColumn<bool>("dotty");
566 QTest::addColumn<float>("dotSize");
567 QTest::addColumn<float>("textGap");
568
569 QTest::addColumn<float>("guardDescent");
570 QTest::addColumn<int>("structAppCount");
571 QTest::addColumn<int>("structAppIndex");
572 QTest::addColumn<QString>("structAppID");
573
574 QTest::addColumn<QString>("fgStr");
575 QTest::addColumn<QString>("bgStr");
576 QTest::addColumn<QColor>("fgColor");
577 QTest::addColumn<QColor>("bgColor");
578 QTest::addColumn<bool>("cmyk");
579
580 QTest::addColumn<int>("borderTypeIndex");
581 QTest::addColumn<int>("borderWidth");
582 QTest::addColumn<int>("whitespace");
583 QTest::addColumn<int>("vWhitespace");
584 QTest::addColumn<int>("fontSetting");
585
586 QTest::addColumn<bool>("showText");
587 QTest::addColumn<bool>("gsSep");
588 QTest::addColumn<bool>("quietZones");
589 QTest::addColumn<bool>("noQuietZones");
590 QTest::addColumn<bool>("compliantHeight");
591 QTest::addColumn<int>("rotateAngle");
592
593 QTest::addColumn<int>("eci");
594 QTest::addColumn<bool>("gs1Parens");
595 QTest::addColumn<bool>("gs1NoCheck");
596 QTest::addColumn<bool>("readerInit");
597 QTest::addColumn<bool>("guardWhitespace");
598 QTest::addColumn<bool>("embedVectorFont");
599 QTest::addColumn<int>("warnLevel");
600 QTest::addColumn<bool>("debug");
601
602 QTest::addColumn<double>("xdimdp_x_dim");
603 QTest::addColumn<int>("xdimdp_x_dim_units");
604 QTest::addColumn<int>("xdimdp_resolution");
605 QTest::addColumn<int>("xdimdp_resolution_units");
606 QTest::addColumn<int>("xdimdp_filetype");
607 QTest::addColumn<int>("xdimdp_filetype_maxicode");
608
609 QTest::addColumn<QString>("expected_cmd");
610 QTest::addColumn<QString>("expected_win");
611 QTest::addColumn<QString>("expected_longOptOnly");
612 QTest::addColumn<QString>("expected_barcodeNames");
613 QTest::addColumn<QString>("expected_noexe");
614 QTest::addColumn<QString>("expected_xdimdp");
615
616 QTest::newRow("BARCODE_AUSPOST") << true << 0.0f << ""
617 << BARCODE_AUSPOST << DATA_MODE // symbology-inputMode
618 << "12345678" << "" // text-primary
619 << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
620 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
621 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
622 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
623 << true << false << false << false << true << 0 // showText-rotateAngle
624 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
625 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
626 << "zint -b 63 --binary --compliantheight -d '12345678'"
627 << "zint.exe -b 63 --binary --compliantheight -d \"12345678\""
628 << "zint --barcode=63 --binary --compliantheight --data='12345678'"
629 << "zint -b AUSPOST --binary --compliantheight -d '12345678'"
630 << "zint -b 63 --binary --compliantheight -d \"12345678\""
631 << "";
632
633 QTest::newRow("BARCODE_AZTEC") << false << 0.0f << ""
634 << BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
635 << "12345678Ж0%var%" << "" // text-primary
636 << 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f << 1.0f // height-textGap
637 << 5.0f << 2 << 1 << "as\"dfa'sdf" // guardDescent-structAppID
638 << "" << "" << QColor(Qt::blue) << QColor(Qt::white) << true // fgStr-cmyk
639 << 0 << 0 << 2 << 3 << 0 // borderTypeIndex-fontSetting
640 << true << false << false << false << false << 0 // showText-rotateAngle
641 << 7 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
642 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
643 << "zint -b 92 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty --fg=0000FF --scale=4"
644 " --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
645 << "zint.exe -b 92 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --fg=0000FF --scale=4"
646 " --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
647 << "" << "" << "" << "";
648
649 QTest::newRow("BARCODE_AZTEC (bgStr CMYK, fgStr CMYK)") << false << 0.0f << ""
650 << BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
651 << "12345678Ж0%var%" << "" // text-primary
652 << 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f << 1.0f // height-textGap
653 << 5.0f << 2 << 1 << "as\"dfa'sdf" // guardDescent-structAppID
654 << "71,0,40,44" << "0,0,0,0" << QColor(Qt::black) << QColor(Qt::white) << true // fgStr-cmyk
655 << 0 << 0 << 2 << 3 << 0 // borderTypeIndex-fontSetting
656 << true << false << false << false << false << 0 // showText-rotateAngle
657 << 7 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
658 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
659 << "zint -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4"
660 " --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
661 << "zint.exe -b 92 --bg=0,0,0,0 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --fg=71,0,40,44 --scale=4"
662 " --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
663 << "" << "" << "" << "";
664
665 QTest::newRow("BARCODE_C25INTER") << true << 0.0f << ""
666 << BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode
667 << "12345" << "" // text-primary
668 << 0.0f << -1 << 2 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
669 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
670 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
671 << 0 << 0 << 0 << 0 << SMALL_TEXT // borderTypeIndex-fontSetting
672 << true << false << false << false << true << 0 // showText-rotateAngle
673 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
674 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
675 << "zint -b 3 --compliantheight -d '12345' --small --vers=2"
676 << "zint.exe -b 3 --compliantheight -d \"12345\" --small --vers=2"
677 << "" << "" << "" << "";
678
679 QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
680 << BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
681 << "453678" << "" // text-primary
682 << 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
683 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
684 << "" << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) << false // fgStr-cmyk
685 << 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
686 << true << false << true << false << false << 90 // showText-rotateAngle
687 << 0 << false << false << false << false << false << WARN_DEFAULT << true // eci-debug
688 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
689 << "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
690 " --rotate=90 --verbose --vers=7"
691 << "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
692 " --rotate=90 --verbose --vers=7"
693 << "" << "" << "" << "";
694
695 QTest::newRow("BARCODE_CHANNEL (bgStr FFFFFF00)") << false << 0.0f << ""
696 << BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
697 << "453678" << "" // text-primary
698 << 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
699 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
700 << "" << "FFFFFF00" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
701 << 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
702 << true << false << true << false << false << 90 // showText-rotateAngle
703 << 0 << false << false << false << false << false << WARN_DEFAULT << true // eci-debug
704 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
705 << "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
706 " --rotate=90 --verbose --vers=7"
707 << "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
708 " --rotate=90 --verbose --vers=7"
709 << "" << "" << "" << "";
710
711 QTest::newRow("BARCODE_CHANNEL (bgStr 12345600)") << false << 0.0f << ""
712 << BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
713 << "453678" << "" // text-primary
714 << 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
715 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
716 << "" << "12345600" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
717 << 1 << 2 << 0 << 0 << BOLD_TEXT // borderTypeIndex-fontSetting
718 << true << false << true << false << false << 90 // showText-rotateAngle
719 << 0 << false << false << false << false << false << WARN_DEFAULT << true // eci-debug
720 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
721 << "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
722 " --rotate=90 --verbose --vers=7"
723 << "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
724 " --rotate=90 --verbose --vers=7"
725 << "" << "" << "" << "";
726
727 QTest::newRow("BARCODE_CODE128") << false << 0.0f << ""
728 << BARCODE_CODE128 << (UNICODE_MODE | EXTRA_ESCAPE_MODE) // symbology-inputMode
729 << "1234\\^A56" << "" // text-primary
730 << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
731 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
732 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
733 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
734 << false << false << true << false << true << 0 // showText-rotateAngle
735 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
736 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
737 << "zint -b 20 -d '1234\\^A56' --extraesc --notext --quietzones"
738 << "zint.exe -b 20 -d \"1234\\^A56\" --extraesc --notext --quietzones"
739 << "" << "" << "" << "";
740
741 QTest::newRow("BARCODE_GS1_128_CC") << false << 0.0f << ""
742 << BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode
743 << "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary
744 << 71.142f << 3 << 0 << 0 << 3.5f << 0.0f << false << 0.8f << 1.0f // height-textGap
745 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
746 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
747 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
748 << false << false << true << false << true << 0 // showText-rotateAngle
749 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
750 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
751 << "zint -b 131 --compliantheight -d '[11]901222[99]ABCDE' --height=71.142 --mode=3 --notext"
752 " --primary='[01]12345678901231[15]121212' --quietzones --scale=3.5"
753 << "zint.exe -b 131 --compliantheight -d \"[11]901222[99]ABCDE\" --height=71.142 --mode=3 --notext"
754 " --primary=\"[01]12345678901231[15]121212\" --quietzones --scale=3.5"
755 << "" << "" << "" << "";
756
757 QTest::newRow("BARCODE_CODE16K") << false << 11.7f << ""
758 << BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
759 << "12345678901234567890123456789012" << "" // text-primary
760 << 0.0f << 4 << 0 << 2 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
761 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
762 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
763 << 1 << 1 << 0 << 0 << SMALL_TEXT // borderTypeIndex-fontSetting
764 << true << false << false << true << true << 0 // showText-rotateAngle
765 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
766 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
767 << "zint -b 23 --compliantheight -d '12345678901234567890123456789012'"
768 " --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
769 << "zint.exe -b 23 --compliantheight -d \"12345678901234567890123456789012\""
770 " --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
771 << "" << "" << "" << "";
772
773 QTest::newRow("BARCODE_CODE49") << true << 0.0f << ""
774 << BARCODE_CODE49 << UNICODE_MODE // symbology-inputMode
775 << "12345678901234567890" << "" // text-primary
776 << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
777 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
778 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
779 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
780 << true << false << false << false << true << 0 // showText-rotateAngle
781 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
782 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
783 << "zint -b 24 --compliantheight -d '12345678901234567890'"
784 << "zint.exe -b 24 --compliantheight -d \"12345678901234567890\""
785 << "" << "" << "" << "";
786
787 QTest::newRow("BARCODE_CODABLOCKF") << true << 0.0f << ""
788 << BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode
789 << "T\\n\\xA0t\\\"" << "" // text-primary
790 << 0.0f << 2 << 5 << 3 << 3.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
791 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
792 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
793 << 2 << 4 << 0 << 0 << 0 // borderTypeIndex-fontSetting
794 << true << false << false << false << true << 0 // showText-rotateAngle
795 << 0 << false << false << true << false << false << WARN_DEFAULT << false // eci-debug
796 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
797 << "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc --init"
798 " --rows=2 --scale=3 --separator=3"
799 << "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc --init"
800 " --rows=2 --scale=3 --separator=3"
801 << "" << "" << "" << "";
802
803 QTest::newRow("BARCODE_DAFT") << false << 0.0f << ""
804 << BARCODE_DAFT << UNICODE_MODE // symbology-inputMode
805 << "daft" << "" // text-primary
806 << 9.2f << -1 << 251 << 0 << 1.0f << 0.0f << false << 0.7f << 1.0f // height-textGap
807 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
808 << "" << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) << false // fgStr-cmyk
809 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
810 << true << false << false << false << true << 0 // showText-rotateAngle
811 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
812 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
813 << "zint -b 93 --bg=BFBEBDBC -d 'daft' --fg=30313233 --height=9.2 --vers=251"
814 << "zint.exe -b 93 --bg=BFBEBDBC -d \"daft\" --fg=30313233 --height=9.2 --vers=251"
815 << "" << "" << "" << "";
816
817 QTest::newRow("BARCODE_DATAMATRIX (GS1)") << true << 0.0f << ""
818 << BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode
819 << "[20]12" << "" // text-primary
820 << 0.0f << -1 << 0 << DM_SQUARE << 1.0f << 0.0f << false << 0.7f << 1.0f // height-textGap
821 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
822 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
823 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
824 << true << true << false << false << true << 0 // showText-rotateAngle
825 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
826 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
827 << "zint -b 71 -d '[20]12' --gs1 --gssep --square"
828 << "zint.exe -b 71 -d \"[20]12\" --gs1 --gssep --square"
829 << "" << "" << "" << "";
830
831 QTest::newRow("BARCODE_DATAMATRIX") << false << 0.0f << ""
832 << BARCODE_DATAMATRIX << (DATA_MODE | ESCAPE_MODE | FAST_MODE) // symbology-inputMode
833 << "ABCDEFGH\\x01I" << "" // text-primary
834 << 0.0f << -1 << 0 << DM_ISO_144 << 1.0f << 0.0f << false << 0.7f << 1.0f // height-textGap
835 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
836 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
837 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
838 << true << false << false << false << true << 0 // showText-rotateAngle
839 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
840 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
841 << "zint -b 71 --binary -d 'ABCDEFGH\\x01I' --dmiso144 --esc --fast"
842 << "zint.exe -b 71 --binary -d \"ABCDEFGH\\x01I\" --dmiso144 --esc --fast"
843 << "" << "" << "" << "";
844
845 QTest::newRow("BARCODE_DBAR_EXPSTK_CC") << false << 40.8f << ""
846 << BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
847 << "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary
848 << 0.0f << -1 << 0 << 2 << 1.0f << 0.0f << true << 0.9f << 1.0f // height-textGap
849 << 3.0f << 2 << 1 << "" // guardDescent-structAppID
850 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
851 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
852 << true << false << false << false << true << 0 // showText-rotateAngle
853 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
854 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
855 << "zint -b 139 --binary --compliantheight -d '[11]901222[99]ABCDE' --height=40.8 --heightperrow"
856 " --primary='[91]ABCDEFGHIJKL' --rows=2"
857 << "zint.exe -b 139 --binary --compliantheight -d \"[11]901222[99]ABCDE\" --height=40.8 --heightperrow"
858 " --primary=\"[91]ABCDEFGHIJKL\" --rows=2"
859 << "" << "" << "" << "";
860
861 QTest::newRow("BARCODE_DOTCODE") << false << 1.0f << ""
862 << BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
863 << "[20]01" << "" // text-primary
864 << 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f << 1.0f // height-textGap
865 << 0.0f << 0 << 0 << "" // guardDescent-structAppID
866 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
867 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
868 << true << false << false << false << true << 0 // showText-rotateAngle
869 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
870 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
871 << "zint -b 115 --cols=8 -d '[20]01' --dotsize=0.7 --gs1 --mask=0"
872 << "zint.exe -b 115 --cols=8 -d \"[20]01\" --dotsize=0.7 --gs1 --mask=0"
873 << "" << "" << "" << "";
874
875 QTest::newRow("BARCODE_DPD") << true << 0.0f << ""
876 << BARCODE_DPD << UNICODE_MODE // symbology-inputMode
877 << "1234567890123456789012345678" << "" // text-primary
878 << 0.0f << -1 << 0 << 0 << 4.5f << 24.0f << true << 0.8f << 1.0f // height-textGap
879 << 0.0f << 0 << 0 << "" // guardDescent-structAppID
880 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
881 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
882 << true << false << false << false << true << 0 // showText-rotateAngle
883 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
884 << 0.375 << 0 << 600 << 1 << 0 << 0 // xdimdp
885 << "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375,24"
886 << "zint.exe -b 96 --compliantheight -d \"1234567890123456789012345678\" --scalexdimdp=0.375,24"
887 << "" << "" << ""
888 << "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375mm,600dpi";
889
890 QTest::newRow("BARCODE_EANX") << true << 0.0f << ""
891 << BARCODE_EANX << UNICODE_MODE // symbology-inputMode
892 << "123456789012+12" << "" // text-primary
893 << 0.0f << -1 << 8 << 0 << 1.0f << 0.0f << true << 0.8f << 1.0f // height-textGap
894 << 0.0f << 0 << 0 << "" // guardDescent-structAppID
895 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
896 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
897 << true << false << false << false << true << 0 // showText-rotateAngle
898 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
899 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
900 << "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --guarddescent=0"
901 << "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --guarddescent=0"
902 << "" << "" << "" << "";
903
904 QTest::newRow("BARCODE_EANX (guardWhitespace/embedVectorFont") << true << 0.0f << ""
905 << BARCODE_EANX << UNICODE_MODE // symbology-inputMode
906 << "123456789012+12" << "" // text-primary
907 << 0.0f << -1 << 8 << 0 << 1.0f << 0.0f << true << 0.8f << 1.0f // height-textGap
908 << 0.0f << 0 << 0 << "" // guardDescent-structAppID
909 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
910 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
911 << true << false << false << false << true << 0 // showText-rotateAngle
912 << 0 << false << false << false << true << true << WARN_DEFAULT << false // eci-debug
913 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
914 << "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --embedfont --guarddescent=0 --guardwhitespace"
915 << "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --embedfont --guarddescent=0 --guardwhitespace"
916 << "" << "" << "" << "";
917
918 QTest::newRow("BARCODE_GRIDMATRIX") << false << 0.0f << ""
919 << BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode
920 << "Your Data Here!" << "" // text-primary
921 << 0.0f << 1 << 5 << 0 << 0.5f << 0.0f << false << 0.8f << 1.0f // height-textGap
922 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
923 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
924 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
925 << true << false << true << false << true << 270 // showText-rotateAngle
926 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
927 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
928 << "zint -b 142 -d 'Your Data Here!' --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
929 << "zint.exe -b 142 -d \"Your Data Here!\" --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
930 << "" << "" << "" << "";
931
932 QTest::newRow("BARCODE_HANXIN") << false << 0.0f << ""
933 << BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
934 << "éβÿ啊\\e\"'" << "" // text-primary
935 << 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
936 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
937 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
938 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
939 << true << false << false << false << true << 0 // showText-rotateAngle
940 << 29 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
941 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
942 << "zint -b 116 --eci=29 -d 'éβÿ啊\\e\"'\\''' --esc --mask=0 --secure=2 --vers=5"
943 << "zint.exe -b 116 --eci=29 -d \"éβÿ啊\\e\\\"'\" --esc --mask=0 --secure=2 --vers=5"
944 << "" << "" << "" << "";
945
946 QTest::newRow("BARCODE_HIBC_DM") << false << 10.0f << ""
947 << BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode
948 << "1234" << "" // text-primary
949 << 0.0f << -1 << 8 << DM_DMRE << 1.0f << 0.0f << false << 0.7f << 1.0f // height-textGap
950 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
951 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
952 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
953 << true << true << false << false << true << 0 // showText-rotateAngle
954 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
955 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
956 << "zint -b 102 -d '1234' --dmre --vers=8"
957 << "zint.exe -b 102 -d \"1234\" --dmre --vers=8"
958 << "" << "" << "" << "";
959
960 QTest::newRow("BARCODE_HIBC_PDF") << false << 0.0f << ""
961 << BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
962 << "TEXT" << "" // text-primary
963 << 3.5f << 3 << 4 << 10 << 10.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
964 << 5.0f << 2 << 1 << "" // guardDescent-structAppID
965 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
966 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
967 << true << false << true << false << true << 0 // showText-rotateAngle
968 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
969 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
970 << "zint -b 106 --binary --cols=4 -d 'TEXT' --height=3.5 --heightperrow --quietzones"
971 " --rows=10 --scale=10 --secure=3 --structapp=1,2"
972 << "zint.exe -b 106 --binary --cols=4 -d \"TEXT\" --height=3.5 --heightperrow --quietzones"
973 " --rows=10 --scale=10 --secure=3 --structapp=1,2"
974 << "" << "" << "" << "";
975
976 QTest::newRow("BARCODE_ITF14") << true << 0.0f << ""
977 << BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
978 << "9212320967145" << "" // text-primary
979 << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
980 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
981 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
982 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
983 << true << false << false << false << true << 0 // showText-rotateAngle
984 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
985 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
986 << "zint -b 89 --compliantheight -d '9212320967145'"
987 << "zint.exe -b 89 --compliantheight -d \"9212320967145\""
988 << "" << "" << "" << "";
989
990 QTest::newRow("BARCODE_ITF14 (border)") << true << 0.0f << ""
991 << BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
992 << "9212320967145" << "" // text-primary
993 << 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
994 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
995 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
996 << 0 << 1 << 0 << 0 << 0 // borderTypeIndex-fontSetting
997 << true << false << false << false << true << 0 // showText-rotateAngle
998 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
999 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1000 << "zint -b 89 --border=1 --compliantheight -d '9212320967145'"
1001 << "zint.exe -b 89 --border=1 --compliantheight -d \"9212320967145\""
1002 << "" << "" << "" << "";
1003
1004 QTest::newRow("BARCODE_MAXICODE") << true << 0.0f << ""
1005 << BARCODE_MAXICODE << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
1006 << "152382802840001"
1007 << "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary
1008 << 0.0f << -1 << (96 + 1) << 0 << 2.5f << 0.0f << false << 0.8f << 1.0f // height-textGap
1009 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1010 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1011 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
1012 << true << false << true << false << true << 0 // showText-rotateAngle
1013 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1014 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1015 << "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E'"
1016 " --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96"
1017 << "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E\""
1018 " --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96"
1019 << "" << "" << "" << "";
1020
1021 QTest::newRow("BARCODE_MICROQR") << false << 0.0f << ""
1022 << BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode
1023 << "1234" << "" // text-primary
1024 << 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
1025 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1026 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1027 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
1028 << true << false << false << false << true << 0 // showText-rotateAngle
1029 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1030 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1031 << "zint -b 97 -d '1234' --fullmultibyte --mask=3 --secure=2 --vers=3"
1032 << "zint.exe -b 97 -d \"1234\" --fullmultibyte --mask=3 --secure=2 --vers=3"
1033 << "" << "" << "" << "";
1034
1035 QTest::newRow("BARCODE_QRCODE") << true << 0.0f << ""
1036 << BARCODE_QRCODE << GS1_MODE // symbology-inputMode
1037 << "(01)12" << "" // text-primary
1038 << 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
1039 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1040 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1041 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
1042 << true << false << true << false << true << 0 // showText-rotateAngle
1043 << 0 << true << true << false << false << false << WARN_DEFAULT << false // eci-debug
1044 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1045 << "zint -b 58 -d '(01)12' --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
1046 " --secure=1 --vers=5"
1047 << "zint.exe -b 58 -d \"(01)12\" --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
1048 " --secure=1 --vers=5"
1049 << "" << "" << "" << "";
1050
1051 QTest::newRow("BARCODE_RMQR") << true << 0.0f << ""
1052 << BARCODE_RMQR << UNICODE_MODE // symbology-inputMode
1053 << "テ" << "" // text-primary
1054 << 30.0f << -1 << 8 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
1055 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1056 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1057 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
1058 << true << false << false << false << true << 180 // showText-rotateAngle
1059 << 20 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1060 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1061 << "zint -b 145 --eci=20 -d 'テ' --rotate=180 --vers=8"
1062 << "zint.exe -b 145 --eci=20 -d \"テ\" --rotate=180 --vers=8"
1063 << "" << "" << "" << "";
1064
1065 QTest::newRow("BARCODE_ULTRA") << false << 0.0f << ""
1066 << BARCODE_ULTRA << (GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE) // symbology-inputMode
1067 << "(01)1" << "" // text-primary
1068 << 0.0f << 6 << 2 << 0 << 1.0f << 0.0f << true << 0.8f << 1.0f // height-textGap
1069 << 5.0f << 2 << 1 << "4" // guardDescent-structAppID
1070 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1071 << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting
1072 << true << false << false << false << true << 0 // showText-rotateAngle
1073 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1074 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1075 << "zint -b 144 -d '(01)1' --gs1 --gs1parens --gs1nocheck --secure=6 --structapp='1,2,4' --vers=2"
1076 << "zint.exe -b 144 -d \"(01)1\" --gs1 --gs1parens --gs1nocheck --secure=6 --structapp=\"1,2,4\" --vers=2"
1077 << "" << "" << "" << "";
1078
1079 QTest::newRow("BARCODE_UPCE_CC") << true << 0.0f << "out.svg"
1080 << BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode
1081 << "12345670+1234" << "[11]901222[99]ABCDE" // text-primary
1082 << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f << 1.0f // height-textGap
1083 << 6.5f << 0 << 0 << "" // guardDescent-structAppID
1084 << "" << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) << false // fgStr-cmyk
1085 << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // borderTypeIndex-fontSetting
1086 << true << false << false << true << true << 0 // showText-rotateAngle
1087 << 0 << false << false << false << false << false << WARN_FAIL_ALL << false // eci-debug
1088 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1089 << "zint -b 136 --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
1090 " --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
1091 << "zint.exe -b 136 --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
1092 " --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror"
1093 << "zint --barcode=136 --compliantheight --data='[11]901222[99]ABCDE' --fg=EF2929"
1094 " --guarddescent=6.5 --noquietzones --output='out.svg' --primary='12345670+1234' --small --werror"
1095 << "zint -b UPCE_CC --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
1096 " --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
1097 << "zint -b 136 --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
1098 " --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror"
1099 << "";
1100
1101 QTest::newRow("BARCODE_VIN") << false << 2.0f << ""
1102 << BARCODE_VIN << UNICODE_MODE // symbology-inputMode
1103 << "12345678701234567" << "" // text-primary
1104 << 20.0f << -1 << 1 << 0 << 1.0f << 0.0f << false << 0.8f << 1.2f // height-textGap
1105 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1106 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1107 << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // borderTypeIndex-fontSetting
1108 << true << false << false << false << true << 0 // showText-rotateAngle
1109 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1110 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1111 << "zint -b 73 --bold -d '12345678701234567' --height=20 --small --textgap=1.2 --vers=1"
1112 << "zint.exe -b 73 --bold -d \"12345678701234567\" --height=20 --small --textgap=1.2 --vers=1"
1113 << "" << "" << "" << "";
1114
1115 QTest::newRow("BARCODE_VIN (notext)") << false << 2.0f << ""
1116 << BARCODE_VIN << UNICODE_MODE // symbology-inputMode
1117 << "12345678701234567" << "" // text-primary
1118 << 20.0f << -1 << 1 << 0 << 1.0f << 0.0f << false << 0.8f << 1.2f // height-textGap
1119 << 5.0f << 0 << 0 << "" // guardDescent-structAppID
1120 << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk
1121 << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // borderTypeIndex-fontSetting
1122 << false << false << false << false << true << 0 // showText-rotateAngle
1123 << 0 << false << false << false << false << false << WARN_DEFAULT << false // eci-debug
1124 << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
1125 << "zint -b 73 -d '12345678701234567' --height=20 --notext --vers=1"
1126 << "zint.exe -b 73 -d \"12345678701234567\" --height=20 --notext --vers=1"
1127 << "" << "" << "" << "";
1128 }
1129
1130 void getAsCLITest()
1131 {
1132 Zint::QZint bc;
1133
1134 QString cmd;
1135
1136 QFETCH(bool, autoHeight);
1137 QFETCH(float, heightPerRow);
1138 QFETCH(QString, outfile);
1139
1140 QFETCH(int, symbology);
1141 QFETCH(int, inputMode);
1142 QFETCH(QString, text);
1143 QFETCH(QString, primary);
1144 QFETCH(float, height);
1145 QFETCH(int, option1);
1146 QFETCH(int, option2);
1147 QFETCH(int, option3);
1148 QFETCH(float, scale);
1149 QFETCH(float, dpmm);
1150 QFETCH(bool, dotty);
1151 QFETCH(float, dotSize);
1152 QFETCH(float, textGap);
1153 QFETCH(float, guardDescent);
1154 QFETCH(int, structAppCount);
1155 QFETCH(int, structAppIndex);
1156 QFETCH(QString, structAppID);
1157 QFETCH(QString, fgStr);
1158 QFETCH(QString, bgStr);
1159 QFETCH(QColor, fgColor);
1160 QFETCH(QColor, bgColor);
1161 QFETCH(bool, cmyk);
1162 QFETCH(int, borderTypeIndex);
1163 QFETCH(int, borderWidth);
1164 QFETCH(int, whitespace);
1165 QFETCH(int, vWhitespace);
1166 QFETCH(int, fontSetting);
1167 QFETCH(bool, showText);
1168 QFETCH(bool, gsSep);
1169 QFETCH(bool, quietZones);
1170 QFETCH(bool, noQuietZones);
1171 QFETCH(bool, compliantHeight);
1172 QFETCH(int, rotateAngle);
1173 QFETCH(int, eci);
1174 QFETCH(bool, gs1Parens);
1175 QFETCH(bool, gs1NoCheck);
1176 QFETCH(bool, readerInit);
1177 QFETCH(bool, guardWhitespace);
1178 QFETCH(bool, embedVectorFont);
1179 QFETCH(int, warnLevel);
1180 QFETCH(bool, debug);
1181
1182 QFETCH(double, xdimdp_x_dim);
1183 QFETCH(int, xdimdp_x_dim_units);
1184 QFETCH(int, xdimdp_resolution);
1185 QFETCH(int, xdimdp_resolution_units);
1186 QFETCH(int, xdimdp_filetype);
1187 QFETCH(int, xdimdp_filetype_maxicode);
1188
1189 QFETCH(QString, expected_cmd);
1190 QFETCH(QString, expected_win);
1191 QFETCH(QString, expected_longOptOnly);
1192 QFETCH(QString, expected_barcodeNames);
1193 QFETCH(QString, expected_noexe);
1194 QFETCH(QString, expected_xdimdp);
1195
1196 bc.setSymbol(symbology);
1197 bc.setInputMode(inputMode);
1198 if (primary.isEmpty()) {
1199 bc.setText(text);
1200 } else {
1201 bc.setText(primary);
1202 bc.setPrimaryMessage(text);
1203 }
1204 bc.setHeight(height);
1205 bc.setOption1(option1);
1206 bc.setOption2(option2);
1207 bc.setOption3(option3);
1208 bc.setScale(scale);
1209 bc.setDPMM(dpmm);
1210 bc.setDotty(dotty);
1211 bc.setDotSize(dotSize);
1212 bc.setTextGap(textGap);
1213 bc.setGuardDescent(guardDescent);
1214 bc.setStructApp(structAppCount, structAppIndex, structAppID);
1215 if (fgStr.isEmpty()) {
1216 bc.setFgColor(fgColor);
1217 } else {
1218 bc.setFgStr(fgStr);
1219 }
1220 if (bgStr.isEmpty()) {
1221 bc.setBgColor(bgColor);
1222 } else {
1223 bc.setBgStr(bgStr);
1224 }
1225 bc.setCMYK(cmyk);
1226 bc.setBorderType(borderTypeIndex);
1227 bc.setBorderWidth(borderWidth);
1228 bc.setWhitespace(whitespace);
1229 bc.setVWhitespace(vWhitespace);
1230 bc.setFontSettingValue(fontSetting);
1231 bc.setShowText(showText);
1232 bc.setGSSep(gsSep);
1233 bc.setQuietZones(quietZones);
1234 bc.setNoQuietZones(noQuietZones);
1235 bc.setCompliantHeight(compliantHeight);
1236 bc.setRotateAngleValue(rotateAngle);
1237 bc.setECIValue(eci);
1238 bc.setGS1Parens(gs1Parens);
1239 bc.setGS1NoCheck(gs1NoCheck);
1240 bc.setReaderInit(readerInit);
1241 bc.setGuardWhitespace(guardWhitespace);
1242 bc.setEmbedVectorFont(embedVectorFont);
1243 bc.setWarnLevel(warnLevel);
1244 bc.setDebug(debug);
1245
1246 cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, false /*barcodeNames*/, false /*noEXE*/,
1247 autoHeight, heightPerRow, outfile);
1248 QCOMPARE(cmd, expected_cmd);
1249
1250 cmd = bc.getAsCLI(true /*win*/, false /*longOptOnly*/, false /*barcodeNames*/, false /*noEXE*/,
1251 autoHeight, heightPerRow, outfile);
1252 QCOMPARE(cmd, expected_win);
1253
1254 if (!expected_longOptOnly.isEmpty()) {
1255 cmd = bc.getAsCLI(false /*win*/, true /*longOptOnly*/, false /*barcodeNames*/, false /*noEXE*/,
1256 autoHeight, heightPerRow, outfile);
1257 QCOMPARE(cmd, expected_longOptOnly);
1258 }
1259
1260 if (!expected_barcodeNames.isEmpty()) {
1261 cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, true /*barcodeNames*/, false /*noEXE*/,
1262 autoHeight, heightPerRow, outfile);
1263 QCOMPARE(cmd, expected_barcodeNames);
1264 }
1265
1266 if (!expected_noexe.isEmpty()) {
1267 cmd = bc.getAsCLI(true /*win*/, false /*longOptOnly*/, false /*barcodeNames*/, true /*noEXE*/,
1268 autoHeight, heightPerRow, outfile);
1269 QCOMPARE(cmd, expected_noexe);
1270 }
1271
1272 if (xdimdp_x_dim) {
1273 /* Avoid clang 14 error "no matching constructor for initialization" by initializing field-wise */
1274 struct Zint::QZintXdimDpVars vars;
1275 vars.x_dim = xdimdp_x_dim;
1276 vars.x_dim_units = xdimdp_x_dim_units;
1277 vars.resolution = xdimdp_resolution;
1278 vars.resolution_units = xdimdp_resolution_units;
1279 vars.filetype = xdimdp_filetype;
1280 vars.filetype_maxicode = xdimdp_filetype_maxicode;
1281 vars.set = 1;
1282 cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, false /*barcodeNames*/, false /*noEXE*/,
1283 autoHeight, heightPerRow, outfile, &vars);
1284 QCOMPARE(cmd, expected_xdimdp);
1285 }
1286 }
1287
1288 void getAsCLISegsTest()
1289 {
1290 Zint::QZint bc;
1291
1292 QString cmd;
1293 QString expected_cmd;
1294 QString expected_win;
1295
1296 std::vector<QString> segTexts;
1297 std::vector<int> segECIs;
1298 segTexts.push_back(QString("Τεχτ"));
1299 segECIs.push_back(9);
1300 segTexts.push_back(QString("Téxt"));
1301 segECIs.push_back(3);
1302 segTexts.push_back(QString("กขฯ"));
1303 segECIs.push_back(13);
1304 segTexts.push_back(QString("貫やぐ禁"));
1305 segECIs.push_back(20);
1306
1307 std::vector<Zint::QZintSeg> segs;
1308 for (int i = 0; i < (int) segTexts.size(); i++) {
1309 segs.push_back(Zint::QZintSeg(segTexts[i]));
1310 segs.back().m_eci = segECIs[i];
1311 }
1312
1313 bc.setSymbol(BARCODE_QRCODE);
1314 bc.setSegs(segs);
1315 bc.setDotty(true);
1316
1317 expected_cmd = "zint -b 58 --eci=9 -d 'Τεχτ' --seg1=3,'Téxt' --seg2=13,'กขฯ' --seg3=20,'貫やぐ禁' --dotty";
1318 cmd = bc.getAsCLI(false /*win*/);
1319 QCOMPARE(cmd, expected_cmd);
1320
1321 expected_win = "zint.exe -b 58 --eci=9 -d \"Τεχτ\" --seg1=3,\"Téxt\" --seg2=13,\"กขฯ\" --seg3=20,\"貫やぐ禁\" --dotty";
1322 cmd = bc.getAsCLI(true /*win*/);
1323 QCOMPARE(cmd, expected_win);
1324 }
1325
1326 void qZintAndLibZintEqualTest_data()
1327 {
1328 QTest::addColumn<int>("symbology");
1329 QTest::addColumn<int>("rotateAngles");
1330 QTest::addColumn<QString>("text");
1331
1332 QTest::newRow("symbology=BARCODE_DATAMATRIX rotateAngles=0 text=1234") << BARCODE_DATAMATRIX << 0 << "1234";
1333 QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=0 text=Hello%20World") << BARCODE_QRCODE << 0 << "Hello%20World";
1334 QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=90 text=Hello%20World") << BARCODE_QRCODE << 90 << "Hello%20World";
1335 QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=180 text=Hello%20World") << BARCODE_QRCODE << 180 << "Hello%20World";
1336 QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=270 text=Hello%20World") << BARCODE_QRCODE << 270 << "Hello%20World";
1337 }
1338
1339 void qZintAndLibZintEqualTest()
1340 {
1341 QFETCH(int, symbology);
1342 QFETCH(int, rotateAngles);
1343 QFETCH(QString, text);
1344 QString fileName("test_qZintAndLibZintEqual_%1.gif");
1345 QString fileNameForLibZint(fileName.arg("libZint"));
1346 QString fileNameForQZint(fileName.arg("qZint"));
1347
1348 Zint::QZint bc;
1349 QSharedPointer<zint_symbol> symbol(ZBarcode_Create(), ZBarcode_Delete);
1350
1351 bc.setSymbol(symbology);
1352 symbol->symbology = symbology;
1353
1354 bc.setText(text);
1355 bc.setRotateAngleValue(rotateAngles);
1356
1357 qstrcpy(symbol->outfile, qUtf8Printable(fileNameForLibZint));
1358
1359 bc.save_to_file(fileNameForQZint);
1360 ZBarcode_Encode_and_Print(symbol.data(), reinterpret_cast<const unsigned char*>(qUtf8Printable(text)), 0, rotateAngles);
1361
1362 QImage imageWrittenByVanilla(fileNameForLibZint);
1363 QImage imageWrittenByQZint(fileNameForQZint);
1364
1365 QCOMPARE(imageWrittenByQZint.isNull(), false);
1366 QCOMPARE(imageWrittenByVanilla.isNull(), false);
1367
1368 QCOMPARE(imageWrittenByQZint == imageWrittenByVanilla, true);
1369
1370 QFile::remove(fileNameForLibZint);
1371 QFile::remove(fileNameForQZint);
1372 }
1373
1374 void barcodeNameTest_data()
1375 {
1376 QTest::addColumn<int>("symbology");
1377 QTest::addColumn<QString>("expected_name");
1378
1379 QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "BARCODE_MAXICODE";
1380 QTest::newRow("BARCODE_CODE128AB") << BARCODE_CODE128AB << "BARCODE_CODE128AB";
1381 QTest::newRow("BARCODE_CODE128B") << BARCODE_CODE128B << "BARCODE_CODE128AB";
1382 }
1383
1384 void barcodeNameTest()
1385 {
1386 QFETCH(int, symbology);
1387 QFETCH(QString, expected_name);
1388
1389 QString name = Zint::QZint::barcodeName(symbology);
1390 QCOMPARE(name, expected_name);
1391 }
1392 };
1393
1394 #ifdef TESTQZINT_GUILESS
1395 QTEST_GUILESS_MAIN(TestQZint)
1396 #else
1397 QTEST_MAIN(TestQZint)
1398 #endif
1399 #include "test_qzint.moc"
1400
1401 /* vim: set ts=4 sw=4 et : */