CODABAR: fix [69c1b4] errtxt; CLI: _WIN32, fuller error messages; win32/README: Administrat-or

This commit is contained in:
gitlost 2021-06-12 16:01:16 +01:00
parent 69c1b4cbf0
commit 8ff15d805a
6 changed files with 118 additions and 112 deletions

View file

@ -67,12 +67,12 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
char dest[64]; /* 17 * 2 + 1 */
if (length > 6) {
strcpy(symbol->errtxt, "350: Input too long (6 character maximum");
strcpy(symbol->errtxt, "350: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "351: Invalid characters in data");
strcpy(symbol->errtxt, "351: Invalid characters in data (digits only)");
return error_number;
}
@ -167,7 +167,7 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "355: Invalid characters in data");
strcpy(symbol->errtxt, "355: Invalid characters in data (digits only)");
return error_number;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
@ -277,7 +277,7 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "361: Invalid characters in data");
strcpy(symbol->errtxt, "361: Invalid characters in data (digits only)");
return error_number;
}

View file

@ -345,7 +345,9 @@ static void test_encode_file_empty(void) {
(void)remove(filename); // In case junk hanging around
fstream = fopen(filename, "w+");
fclose(fstream);
assert_nonnull(fstream, "fopen(%s) failed (%d)\n", filename, ferror(fstream));
ret = fclose(fstream);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
ret = ZBarcode_Encode_File(symbol, filename);
assert_equal(ret, ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File empty ret %d != ZINT_ERROR_INVALID_DATA (%s)\n", ret, symbol->errtxt);
@ -372,9 +374,11 @@ static void test_encode_file_too_large(void) {
(void)remove(filename); // In case junk hanging around
fstream = fopen(filename, "w+");
assert_nonnull(fstream, "fopen(%s) failed (%d)\n", filename, ferror(fstream));
ret = fwrite(buf, 1, sizeof(buf), fstream);
assert_equal(ret, sizeof(buf), "fwrite retun value: %d != %d\n", ret, (int)sizeof(buf));
fclose(fstream);
assert_equal(ret, sizeof(buf), "fwrite return value: %d != %d\n", ret, (int)sizeof(buf));
ret = fclose(fstream);
assert_zero(ret, "fclose(%s) %d != 0\n", filename, ret);
ret = ZBarcode_Encode_File(symbol, filename);
assert_equal(ret, ZINT_ERROR_TOO_LONG, "ZBarcode_Encode_File too large ret %d != ZINT_ERROR_TOO_LONG (%s)\n", ret, symbol->errtxt);

View file

@ -143,35 +143,36 @@ static void test_input(int index, int debug) {
int ret;
int expected_rows;
int expected_width;
const char *expected_errtxt;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABAR, "A1234B", 0, 1, 62 },
/* 1*/ { BARCODE_CODABAR, "1234B", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_CODABAR, "A1234", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { BARCODE_CODABAR, "A1234E", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_CODABAR, "C123.D", 0, 1, 63 },
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_CODABAR, "D:C", 0, 1, 33 },
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 8*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { BARCODE_PHARMA, "131070", 0, 1, 78 },
/* 10*/ { BARCODE_PHARMA, "131071", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 11*/ { BARCODE_PHARMA, "3", 0, 1, 4 },
/* 12*/ { BARCODE_PHARMA, "2", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 13*/ { BARCODE_PHARMA, "1", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 14*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 15*/ { BARCODE_PHARMA_TWO, "64570080", 0, 2, 31 },
/* 16*/ { BARCODE_PHARMA_TWO, "64570081", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 17*/ { BARCODE_PHARMA_TWO, "4", 0, 2, 3 },
/* 18*/ { BARCODE_PHARMA_TWO, "3", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 19*/ { BARCODE_PHARMA_TWO, "2", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 20*/ { BARCODE_PHARMA_TWO, "1", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 21*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 22*/ { BARCODE_CODE32, "12345678", 0, 1, 103 },
/* 22*/ { BARCODE_CODE32, "9", 0, 1, 103 },
/* 22*/ { BARCODE_CODE32, "0", 0, 1, 103 },
/* 22*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 0*/ { BARCODE_CODABAR, "A1234B", 0, 1, 62, "" },
/* 1*/ { BARCODE_CODABAR, "1234B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 358: Does not begin with \"A\", \"B\", \"C\" or \"D\"" },
/* 2*/ { BARCODE_CODABAR, "A1234", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"" },
/* 3*/ { BARCODE_CODABAR, "A1234E", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"" },
/* 4*/ { BARCODE_CODABAR, "C123.D", 0, 1, 63, "" },
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid characters in data" },
/* 6*/ { BARCODE_CODABAR, "D:C", 0, 1, 33, "" },
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Cannot contain \"A\", \"B\", \"C\" or \"D\"" },
/* 8*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1, "Error 362: Input too short (3 character minimum)" },
/* 9*/ { BARCODE_PHARMA, "131070", 0, 1, 78, "" },
/* 10*/ { BARCODE_PHARMA, "131071", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)" },
/* 11*/ { BARCODE_PHARMA, "3", 0, 1, 4, "" },
/* 12*/ { BARCODE_PHARMA, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)" },
/* 13*/ { BARCODE_PHARMA, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)" },
/* 14*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 351: Invalid characters in data (digits only)" },
/* 15*/ { BARCODE_PHARMA_TWO, "64570080", 0, 2, 31, "" },
/* 16*/ { BARCODE_PHARMA_TWO, "64570081", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
/* 17*/ { BARCODE_PHARMA_TWO, "4", 0, 2, 3, "" },
/* 18*/ { BARCODE_PHARMA_TWO, "3", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
/* 19*/ { BARCODE_PHARMA_TWO, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
/* 20*/ { BARCODE_PHARMA_TWO, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)" },
/* 21*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 355: Invalid characters in data (digits only)" },
/* 22*/ { BARCODE_CODE32, "12345678", 0, 1, 103, "" },
/* 23*/ { BARCODE_CODE32, "9", 0, 1, 103, "" },
/* 24*/ { BARCODE_CODE32, "0", 0, 1, 103, "" },
/* 25*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 361: Invalid characters in data (digits only)" },
};
int data_size = ARRAY_SIZE(data);
@ -191,6 +192,7 @@ static void test_input(int index, int debug) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}