mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-15 23:54:34 -04:00
Test suite: add testRun allowing args; testSkip; haveIdentify/etc; general tidy-up
This commit is contained in:
parent
3fea67890b
commit
5eafa2e094
38 changed files with 2211 additions and 1518 deletions
|
@ -32,33 +32,33 @@
|
|||
#include "testcommon.h"
|
||||
|
||||
// #181 Nico Gunkel OSS-Fuzz
|
||||
static void test_fuzz(void)
|
||||
{
|
||||
static void test_fuzz(int index, int debug) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int symbology;
|
||||
unsigned char* data;
|
||||
unsigned char *data;
|
||||
int length;
|
||||
int ret;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODEONE, "3333P33B\035333V3333333333333\0363", -1, 0 },
|
||||
/* 0*/ { "3333P33B\035333V3333333333333\0363", -1, 0 },
|
||||
};
|
||||
int data_size = sizeof(data) / sizeof(struct item);
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
struct zint_symbol* symbol = ZBarcode_Create();
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
struct zint_symbol *symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
symbol->symbology = data[i].symbology;
|
||||
int length = data[i].length;
|
||||
if (length == -1) {
|
||||
length = strlen(data[i].data);
|
||||
}
|
||||
symbol->symbology = BARCODE_CODEONE;
|
||||
symbol->debug |= debug;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
|
||||
ret = ZBarcode_Encode(symbol, data[i].data, length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
@ -69,9 +69,13 @@ static void test_fuzz(void)
|
|||
testFinish();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_fuzz();
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_fuzz", test_fuzz, 1, 0, 1 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
||||
testReport();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue