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

@ -34,7 +34,8 @@
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf);
static void test_pixel_plot(int index, int debug) {
static void test_pixel_plot(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int width;
@ -71,7 +72,7 @@ static void test_pixel_plot(int index, int debug) {
for (i = 0; i < data_size; i++) {
int size;
if (index != -1 && i != index) continue;
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -123,7 +124,8 @@ static void test_pixel_plot(int index, int debug) {
testFinish();
}
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;
@ -158,7 +160,7 @@ static void test_print(int index, int generate, int debug) {
testStart("test_print");
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)) {
@ -169,7 +171,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");
@ -200,7 +202,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,
@ -227,11 +229,13 @@ static void test_print(int index, int generate, int debug) {
testFinish();
}
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;
@ -254,10 +258,10 @@ static void test_outfile(void) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_pixel_plot", test_pixel_plot, 1, 0, 1 },
{ "test_print", test_print, 1, 1, 1 },
{ "test_outfile", test_outfile, 0, 0, 0 },
testFunction funcs[] = { /* name, func */
{ "test_pixel_plot", test_pixel_plot },
{ "test_print", test_print },
{ "test_outfile", test_outfile },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));