mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Test suite: add testRun allowing args; testSkip; haveIdentify/etc; general tidy-up
This commit is contained in:
@ -31,19 +31,19 @@
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
static void test_utf8_to_unicode(void)
|
||||
{
|
||||
static void test_utf8_to_unicode(int index, int debug) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
unsigned char* data;
|
||||
unsigned char *data;
|
||||
int length;
|
||||
int disallow_4byte;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
int expected_vals[20];
|
||||
char* comment;
|
||||
char *comment;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
@ -57,9 +57,12 @@ static void test_utf8_to_unicode(void)
|
||||
|
||||
int vals[20];
|
||||
struct zint_symbol symbol;
|
||||
symbol.debug |= debug;
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
|
||||
@ -76,15 +79,15 @@ static void test_utf8_to_unicode(void)
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_debug_test_codeword_dump_int(void)
|
||||
{
|
||||
static void test_debug_test_codeword_dump_int(int index, int debug) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int codewords[50];
|
||||
int length;
|
||||
char* expected;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
@ -94,9 +97,12 @@ static void test_debug_test_codeword_dump_int(void)
|
||||
int data_size = sizeof(data) / sizeof(struct item);
|
||||
|
||||
struct zint_symbol symbol;
|
||||
symbol.debug |= debug;
|
||||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
debug_test_codeword_dump_int(&symbol, data[i].codewords, data[i].length);
|
||||
assert_nonzero(strlen(symbol.errtxt) < 92, "i:%d strlen(%s) >= 92 (%zu)\n", i, symbol.errtxt, strlen(symbol.errtxt));
|
||||
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (%zu, %zu)\n", i, symbol.errtxt, data[i].expected, strlen(symbol.errtxt), strlen(data[i].expected));
|
||||
@ -105,10 +111,14 @@ static void test_debug_test_codeword_dump_int(void)
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_utf8_to_unicode();
|
||||
test_debug_test_codeword_dump_int();
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_utf8_to_unicode", test_utf8_to_unicode, 1, 0, 1 },
|
||||
{ "test_debug_test_codeword_dump_int", test_debug_test_codeword_dump_int, 1, 0, 1 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
||||
testReport();
|
||||
|
||||
|
Reference in New Issue
Block a user