44#define ZINT_DEBUG_TEST_PRINT 16
45#define ZINT_DEBUG_TEST_LESS_NOISY 32
46#define ZINT_DEBUG_TEST_KEEP_OUTFILE 64
47#define ZINT_DEBUG_TEST_BWIPP 128
48#define ZINT_DEBUG_TEST_PERFORMANCE 256
49#define ZINT_DEBUG_TEST_ZXINGCPP 512
50#define ZINT_DEBUG_TEST_BWIPP_ZXINGCPP 1024
51#define ZINT_DEBUG_TEST_AZTEC_SKIP_ALL 2048
54#define ZINT_TESTUTIL_SANITIZEM_INIT = {0}
55#define ZINT_TESTUTIL_SANITIZEM_INIT_2D = {{0}}
57#define ZINT_TESTUTIL_SANITIZEM_INIT
58#define ZINT_TESTUTIL_SANITIZEM_INIT_2D
62#define ZINT_TESTUTIL_GS1CARET (1 << 24)
69#define testutil_popen(command, mode) _popen(command, mode)
70#define testutil_pclose(stream) _pclose(stream)
74extern FILE *popen(
const char *command,
const char *type);
75extern int pclose(FILE *stream);
77#define testutil_popen(command, mode) popen(command, mode)
78#define testutil_pclose(stream) pclose(stream)
82# pragma GCC diagnostic ignored "-Woverlength-strings"
83#elif defined(_MSC_VER)
84# pragma warning(disable: 4305)
85# pragma warning(disable: 4702)
88extern int testAssertFailed;
89extern int testAssertNum;
91extern const char *testAssertFilename;
93#if defined(_MSC_VER) && _MSC_VER < 1900
94#define testStart(name) (testStartReal("", name, NULL))
95#define testStartSymbol(name, pp_symbol) (testStartReal("", name, pp_symbol))
97#define testStart(name) (ZEXT testStartReal(__func__, name, NULL))
98#define testStartSymbol(name, pp_symbol) (ZEXT testStartReal(__func__, name, pp_symbol))
100void testStartReal(
const char *
func,
const char *name,
struct zint_symbol **pp_symbol);
101void testFinish(
void);
102void testSkip(
const char *msg);
103void testReport(
void);
105#define ZINT_TEST_CTX_EXC_MAX 32
107 const char *func_name;
110 int exclude[ZINT_TEST_CTX_EXC_MAX];
111 int exclude_end[ZINT_TEST_CTX_EXC_MAX];
116typedef void (*testFunc_t)(
const testCtx *
const p_ctx);
118 const char *name; testFunc_t func;
120void testRun(
int argc,
char *argv[],
testFunction funcs[],
int funcs_size);
121int testContinue(
const testCtx *
const p_ctx,
const int i);
123#if (defined(_MSC_VER) &&_MSC_VER <= 1200) || defined(ZINT_IS_C89)
124void assert_zero(
int exp,
const char *fmt, ...);
125void assert_nonzero(
int exp,
const char *fmt, ...);
126void assert_null(
const void *exp,
const char *fmt, ...);
127void assert_nonnull(
const void *exp,
const char *fmt, ...);
128void assert_equal(
int e1,
int e2,
const char *fmt, ...);
129void assert_equalu64(uint64_t e1, uint64_t e2,
const char *fmt, ...);
130void assert_notequal(
int e1,
int e2,
const char *fmt, ...);
132#define assert_exp(exp, ...) \
133 { testAssertNum++; if (!(exp)) { testAssertFailed++; printf("%s:%d ", testAssertFilename, __LINE__); \
134 printf(__VA_ARGS__); testFinish(); \
135 if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; } return; } }
137#define assert_zero(exp, ...) assert_exp((exp) == 0, __VA_ARGS__)
138#define assert_nonzero(exp, ...) assert_exp((exp) != 0, __VA_ARGS__)
139#define assert_null(ptr, ...) assert_exp((ptr) == NULL, __VA_ARGS__)
140#define assert_nonnull(ptr, ...) assert_exp((ptr) != NULL, __VA_ARGS__)
141#define assert_equal(e1, e2, ...) assert_exp((e1) == (e2), __VA_ARGS__)
142#define assert_equalu64 assert_equal
143#define assert_notequal(e1, e2, ...) assert_exp((e1) != (e2), __VA_ARGS__)
147#define TU(p) ((unsigned char *) (p))
148#define TCU(p) ((const unsigned char *) (p))
149#define TCC(p) ((const char *) (p))
151INTERNAL
void vector_free(
struct zint_symbol *symbol);
153int testUtilSetSymbol(
struct zint_symbol *symbol,
int symbology,
int input_mode,
int eci,
154 int option_1,
int option_2,
int option_3,
int output_options,
const char *data,
int length,
int debug);
156const char *testUtilBarcodeName(
int symbology);
157const char *testUtilErrorName(
int error_number);
158const char *testUtilInputModeName(
int input_mode);
159const char *testUtilOption3Name(
int symbology,
int option_3);
160const char *testUtilOutputOptionsName(
int output_options);
162int testUtilDAFTConvert(
const struct zint_symbol *symbol,
char *buffer,
const int buffer_size);
163int testUtilIsValidUTF8(
const unsigned char str[],
const int length);
164char *testUtilEscape(
const char *buffer,
const int length,
char *escaped,
const int escaped_size);
165const char *testUtilReadCSVField(
const char *buffer,
char *field,
const int field_size);
166void testUtilStrCpyRepeat(
char *buffer,
const char *repeat,
const int size);
172int testUtilModulesDump(
const struct zint_symbol *symbol,
char dump[],
int dump_size);
173void testUtilModulesPrint(
const struct zint_symbol *symbol,
const char *prefix,
const char *postfix);
174void testUtilModulesPrintRow(
const struct zint_symbol *symbol,
int row,
const char *prefix,
const char *postfix);
175int testUtilModulesCmp(
const struct zint_symbol *symbol,
const char *expected,
int *width,
int *row);
176int testUtilModulesCmpRow(
const struct zint_symbol *symbol,
int row,
const char *expected,
int *width);
177char *testUtilUIntArrayDump(
const unsigned int *array,
const int size,
char *dump,
const int dump_size);
178char *testUtilUCharArrayDump(
const unsigned char *array,
const int size,
char *dump,
const int dump_size);
180void testUtilBitmapPrint(
const struct zint_symbol *symbol,
const char *prefix,
const char *postfix);
181int testUtilBitmapCmp(
const struct zint_symbol *symbol,
const char *expected,
int *row,
int *column);
183void testUtilVectorPrint(
const struct zint_symbol *symbol);
185int testUtilDataPath(
char *buffer,
int buffer_size,
const char *subdir,
const char *filename);
186FILE *testUtilOpen(
const char *filename,
const char *mode);
187int testUtilExists(
const char *filename);
188int testUtilRemove(
const char *filename);
189int testUtilDirExists(
const char *dirname);
190int testUtilMkDir(
const char *dirname);
191int testUtilRmDir(
const char *dirname);
192int testUtilRename(
const char *oldpath,
const char *newpath);
193int testUtilCreateROFile(
const char *filename);
194int testUtilRmROFile(
const char *filename);
195int testUtilReadFile(
const char *filename,
unsigned char *buffer,
int buffer_size,
int *p_size);
196int testUtilWriteFile(
const char *filename,
const unsigned char *buffer,
const int buffer_size,
const char *mode);
198int testUtilCmpPngs(
const char *file1,
const char *file2);
199int testUtilCmpTxts(
const char *txt1,
const char *txt2);
200int testUtilCmpBins(
const char *bin1,
const char *bin2);
201int testUtilCmpSvgs(
const char *svg1,
const char *svg2);
202int testUtilCmpEpss(
const char *eps1,
const char *eps2);
204const char *testUtilHaveIdentify(
void);
205int testUtilVerifyIdentify(
const char *
const prog,
const char *filename,
int debug);
206int testUtilHaveLibreOffice(
void);
207int testUtilVerifyLibreOffice(
const char *filename,
int debug);
208int testUtilHaveGhostscript(
void);
209int testUtilVerifyGhostscript(
const char *filename,
int debug);
210int testUtilHaveVnu(
void);
211int testUtilVerifyVnu(
const char *filename,
int debug);
212int testUtilHaveTiffInfo(
void);
213int testUtilVerifyTiffInfo(
const char *filename,
int debug);
215int testUtilCanBwipp(
int index,
const struct zint_symbol *symbol,
int option_1,
int option_2,
int option_3,
217int testUtilBwipp(
int index,
const struct zint_symbol *symbol,
int option_1,
int option_2,
int option_3,
218 const char *data,
int length,
const char *primary,
char *buffer,
int buffer_size,
const int *p_parsefnc);
219int testUtilBwippSegs(
int index,
struct zint_symbol *symbol,
int option_1,
int option_2,
int option_3,
220 const struct zint_seg segs[],
const int seg_count,
const char *primary,
char *buffer,
int buffer_size);
221int testUtilBwippCmp(
const struct zint_symbol *symbol,
char *msg,
char *cmp_buf,
const char *expected);
222int testUtilBwippCmpRow(
const struct zint_symbol *symbol,
int row,
char *msg,
const char *cmp_buf,
223 const char *expected);
225int testUtilHaveZXingCPPDecoder(
void);
226int testUtilCanZXingCPP(
int index,
const struct zint_symbol *symbol,
const char *data,
const int length,
228int testUtilZXingCPP(
int index,
struct zint_symbol *symbol,
const char *source,
const int length,
const char *bits,
229 const int zxingcpp_cmp,
char *buffer,
const int buffer_size,
int *p_cmp_len);
230int testUtilZXingCPPCmp(
struct zint_symbol *symbol,
char *msg,
char *cmp_buf,
int cmp_len,
const char *expected,
231 int expected_len,
const char *primary,
char *ret_buf,
int *p_ret_len);
232int testUtilZXingCPPCmpSegs(
struct zint_symbol *symbol,
char *msg,
char *cmp_buf,
int cmp_len,
233 const struct zint_seg segs[],
const int seg_count,
const char *primary,
char *ret_buf,
int *p_ret_len);
void func()
function in group 1
Definition: group.cpp:13
Definition: testcommon.h:106
Definition: testcommon.h:117