test suite: convert to use test context p_ctx instead of individual

args; new -x exclude option and ranges; no longer use getopt();
  make C89 compat
This commit is contained in:
gitlost 2022-09-12 19:26:04 +01:00
parent 0d4aa6cce3
commit 90dfbdb5d9
58 changed files with 2822 additions and 2340 deletions

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -27,11 +27,12 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
static void test_print(int index, int generate, int debug) {
static void test_print(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
@ -47,7 +48,7 @@ static void test_print(int index, int generate, int debug) {
char *data;
char *expected_file;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_GRIDMATRIX, -1, -1, -1, -1, -1, -1, "C3C3C3", "", 0.75, "Grid Matrix", "gridmatrix_fg_0.75.pcx" },
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890", "codeblockf_reverse.pcx" },
@ -68,7 +69,7 @@ static void test_print(int index, int generate, int debug) {
testStart("test_pcx");
if (generate) {
if (p_ctx->generate) {
char data_dir_path[1024];
assert_nonzero(testUtilDataPath(data_dir_path, sizeof(data_dir_path), data_dir, NULL), "testUtilDataPath(%s) == 0\n", data_dir);
if (!testUtilDirExists(data_dir_path)) {
@ -79,7 +80,7 @@ static void test_print(int index, int generate, int debug) {
for (i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -114,7 +115,7 @@ static void test_print(int index, int generate, int debug) {
assert_nonzero(testUtilDataPath(expected_file, sizeof(expected_file), data_dir, data[i].expected_file), "i:%d testUtilDataPath == 0\n", i);
if (generate) {
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n",
i, testUtilBarcodeName(data[i].symbology), data[i].border_width, testUtilOutputOptionsName(data[i].output_options),
data[i].whitespace_width, data[i].whitespace_height,
@ -143,11 +144,13 @@ static void test_print(int index, int generate, int debug) {
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
static void test_outfile(void) {
static void test_outfile(const testCtx *const p_ctx) {
int ret;
struct zint_symbol symbol = {0};
unsigned char data[] = { "1" };
(void)p_ctx;
testStart("test_outfile");
symbol.symbology = BARCODE_CODE128;
@ -170,9 +173,9 @@ static void test_outfile(void) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_print", test_print, 1, 1, 1 },
{ "test_outfile", test_outfile, 0, 0, 0 },
testFunction funcs[] = { /* name, func */
{ "test_print", test_print },
{ "test_outfile", test_outfile },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
@ -181,3 +184,5 @@ int main(int argc, char *argv[]) {
return 0;
}
/* vim: set ts=4 sw=4 et : */