CODEONE/ULTRA overrun fixes; TELEPEN fixes; CODEONE/LOGMARS/VIN/CODABAR options; GUI updates; tests

This commit is contained in:
gitlost 2020-06-04 18:45:25 +01:00
parent 8131471573
commit 6242e02638
80 changed files with 6393 additions and 2179 deletions

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -31,9 +31,7 @@
*/
/* vim: set ts=4 sw=4 et : */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#ifdef _MSC_VER
#include <malloc.h>
@ -203,19 +201,19 @@ INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, const unsigned
return error_number;
}
ustrcpy(temp, (unsigned char *) "");
ustrcpy(temp, "");
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
if an odd number of characters has been entered then add a leading zero */
if (length & 1) {
ustrcpy(temp, (unsigned char *) "0");
ustrcpy(temp, "0");
length++;
}
strcat((char*) temp, (char*) source);
ustrcat(temp, source);
/* start character */
strcpy(dest, "1111");
for (i = 0; i < length; i += 2) {
for (i = 0; i < (int) length; i += 2) {
int k = 0;
/* look up the bars and the spaces and put them in two strings */
strcpy(bars, "");
@ -267,7 +265,7 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
for (i = 0; i < zeroes; i++) {
localstr[i] = '0';
}
strcpy(localstr + zeroes, (char *) source);
ustrcpy(localstr + zeroes, source);
/* Calculate the check digit - the same method used for EAN-13 */
for (i = 12; i >= 0; i--) {
@ -280,7 +278,7 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
localstr[13] = check_digit(count);
localstr[14] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
ustrcpy(symbol->text, localstr);
return error_number;
}
@ -305,7 +303,7 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
zeroes = 13 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
ustrcpy(localstr + zeroes, source);
for (i = 12; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
@ -317,7 +315,7 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
localstr[13] = check_digit(count);
localstr[14] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
ustrcpy(symbol->text, localstr);
return error_number;
}
@ -341,7 +339,7 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
zeroes = 11 - length;
for (i = 0; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
ustrcpy(localstr + zeroes, source);
for (i = 10; i >= 0; i--) {
count += 4 * ctoi(localstr[i]);
@ -353,6 +351,6 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
localstr[11] = check_digit(count);
localstr[12] = '\0';
error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char*) localstr);
ustrcpy(symbol->text, localstr);
return error_number;
}

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -32,34 +32,37 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "bmp.h" /* Bitmap header structure */
#include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
#define SSET "0123456789ABCDEF"
INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
int i, row, column;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
unsigned int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row_size;
unsigned int data_size;
unsigned int data_offset, data_size, file_size;
unsigned char *bitmap_file_start, *bmp_posn;
char *bitmap;
unsigned char *bitmap;
FILE *bmp_file;
bitmap_file_header_t file_header;
bitmap_info_header_t info_header;
if (symbol->bitmap != NULL)
free(symbol->bitmap);
row_size = 4 * ((24 * symbol->bitmap_width + 31) / 32);
data_size = symbol->bitmap_height * row_size;
data_offset = sizeof (bitmap_file_header_t) + sizeof (bitmap_info_header_t);
file_size = data_offset + data_size;
row_size = 4 * floor((24.0 * symbol->bitmap_width + 31) / 32);
bitmap = (char *) malloc(row_size * symbol->bitmap_height);
bitmap_file_start = malloc(file_size);
if (bitmap_file_start == NULL) {
strcpy(symbol->errtxt, "602: Out of memory");
return ZINT_ERROR_MEMORY;
}
memset(bitmap_file_start, 0, file_size); /* Not required but keeps padding bytes consistent */
bitmap = bitmap_file_start + data_offset;
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
@ -69,7 +72,6 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]);
/* Pixel Plotting */
i = 0;
for (row = 0; row < symbol->bitmap_height; row++) {
for (column = 0; column < symbol->bitmap_width; column++) {
i = (3 * column) + (row * row_size);
@ -129,13 +131,12 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
}
}
data_size = symbol->bitmap_height * row_size;
symbol->bitmap_byte_length = data_size;
file_header.header_field = 0x4d42; // "BM"
file_header.file_size = sizeof (bitmap_file_header_t) + sizeof (bitmap_info_header_t) + data_size;
file_header.file_size = file_size;
file_header.reserved = 0;
file_header.data_offset = sizeof (bitmap_file_header_t) + sizeof (bitmap_info_header_t);
file_header.data_offset = data_offset;
info_header.header_size = sizeof (bitmap_info_header_t);
info_header.width = symbol->bitmap_width;
@ -149,15 +150,10 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
info_header.colours = 0;
info_header.important_colours = 0;
bitmap_file_start = (unsigned char*) malloc(file_header.file_size);
memset(bitmap_file_start, 0xff, file_header.file_size);
bmp_posn = bitmap_file_start;
memcpy(bitmap_file_start, &file_header, sizeof (bitmap_file_header_t));
bmp_posn += sizeof (bitmap_file_header_t);
memcpy(bmp_posn, &info_header, sizeof (bitmap_info_header_t));
bmp_posn += sizeof (bitmap_info_header_t);
memcpy(bmp_posn, bitmap, data_size);
/* Open output file in binary mode */
if ((symbol->output_options & BARCODE_STDOUT) != 0) {
@ -165,7 +161,6 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
strcpy(symbol->errtxt, "600: Can't open output file");
free(bitmap_file_start);
free(bitmap);
return ZINT_ERROR_FILE_ACCESS;
}
#endif
@ -173,7 +168,6 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
} else {
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
free(bitmap_file_start);
free(bitmap);
strcpy(symbol->errtxt, "601: Can't open output file");
return ZINT_ERROR_FILE_ACCESS;
}
@ -183,6 +177,5 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
fclose(bmp_file);
free(bitmap_file_start);
free(bitmap);
return 0;
}

View File

@ -1,8 +1,11 @@
/* code.c - Handles Code 11, 39, 39+ and 93 */
/* code.c - Handles Code 11, 39, 39+, 93, PZN, Channel and VIN */
/* LOGMARS MIL-STD-1189 Rev. B https://apps.dtic.mil/dtic/tr/fulltext/u2/a473534.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA_Info_Code_39_EN.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -33,13 +36,12 @@
/* In version 0.5 this file was 1,553 lines long! */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "common.h"
#define SODIUM "0123456789-"
#define SILVER "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd"
#define SODIUM "0123456789-"
#define SILVER "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd"
#define ARSENIC "0123456789ABCDEFGHJKLMNPRSTUVWXYZ"
static const char *C11Table[11] = {
@ -108,11 +110,15 @@ static void NextB(int Chan, int i, int MaxB, int MaxS);
/* *********************** CODE 11 ******************** */
INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 11 */
unsigned int i;
int i;
int h, c_digit, c_weight, c_count, k_digit, k_weight, k_count;
int weight[128], error_number;
char dest[1024]; /* 6 + 121 * 6 + 2 * 6 + 5 + 1 ~ 1024*/
int weight[122], error_number;
char dest[750]; /* 6 + 121 * 6 + 2 * 6 + 5 + 1 == 750 */
char checkstr[3];
int num_check_digits;
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warning */
assert(length > 0);
if (length > 121) {
strcpy(symbol->errtxt, "320: Input too long");
@ -123,6 +129,19 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(symbol->errtxt, "321: Invalid characters in data");
return error_number;
}
if (symbol->option_2 < 0 || symbol->option_2 > 2) {
strcpy(symbol->errtxt, "339: Invalid check digit version");
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->option_2 == 2) {
num_check_digits = 0;
} else if (symbol->option_2 == 1) {
num_check_digits = 1;
} else {
num_check_digits = 2;
}
c_weight = 1;
c_count = 0;
k_weight = 1;
@ -132,7 +151,7 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(dest, "112211");
/* Draw main body of barcode */
for (i = 0; i < (unsigned int) length; i++) {
for (i = 0; i < length; i++) {
lookup(SODIUM, C11Table, source[i], dest);
if (source[i] == '-')
weight[i] = 10;
@ -140,41 +159,52 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
weight[i] = ctoi(source[i]);
}
/* Calculate C checksum */
for (h = length - 1; h >= 0; h--) {
c_count += (c_weight * weight[h]);
c_weight++;
if (num_check_digits) {
/* Calculate C checksum */
for (h = length - 1; h >= 0; h--) {
c_count += (c_weight * weight[h]);
c_weight++;
if (c_weight > 10) {
c_weight = 1;
if (c_weight > 10) {
c_weight = 1;
}
}
c_digit = c_count % 11;
if (num_check_digits == 1) {
checkstr[0] = itoc(c_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
checkstr[1] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
} else {
weight[length] = c_digit;
/* Calculate K checksum */
for (h = length; h >= 0; h--) {
k_count += (k_weight * weight[h]);
k_weight++;
if (k_weight > 9) {
k_weight = 1;
}
}
k_digit = k_count % 11;
checkstr[0] = itoc(c_digit);
checkstr[1] = itoc(k_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
if (checkstr[1] == 'A') {
checkstr[1] = '-';
}
checkstr[2] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
lookup(SODIUM, C11Table, checkstr[1], dest);
}
}
c_digit = c_count % 11;
weight[length] = c_digit;
/* Calculate K checksum */
for (h = length; h >= 0; h--) {
k_count += (k_weight * weight[h]);
k_weight++;
if (k_weight > 9) {
k_weight = 1;
}
}
k_digit = k_count % 11;
checkstr[0] = itoc(c_digit);
checkstr[1] = itoc(k_digit);
if (checkstr[0] == 'A') {
checkstr[0] = '-';
}
if (checkstr[1] == 'A') {
checkstr[1] = '-';
}
checkstr[2] = '\0';
lookup(SODIUM, C11Table, checkstr[0], dest);
lookup(SODIUM, C11Table, checkstr[1], dest);
/* Stop character */
strcat(dest, "11221");
@ -182,16 +212,18 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
expand(symbol, dest);
ustrcpy(symbol->text, source);
strcat((char*) symbol->text, checkstr);
if (num_check_digits) {
ustrcat(symbol->text, checkstr);
}
return error_number;
}
/* Code 39 */
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
unsigned int i;
unsigned int counter;
int i;
int counter;
int error_number;
char dest[775];
char dest[880]; /* 10 (Start) + 85 * 10 + 10 (Check) + 9 (Stop) + 1 = 880 */
char localstr[2] = {0};
counter = 0;
@ -200,10 +232,13 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
symbol->option_2 = 0;
}
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 59)) {
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 30)) { /* MIL-STD-1189 Rev. B Section 5.2.6.2 */
strcpy(symbol->errtxt, "322: Input too long");
return ZINT_ERROR_TOO_LONG;
} else if (length > 74) {
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 68)) { /* Prevent encoded_data out-of-bounds >= 143 due to wider 'wide' bars */
strcpy(symbol->errtxt, "319: Input too long"); /* Note use 319 (2of5 range) as 340 taken by CODE128 */
return ZINT_ERROR_TOO_LONG;
} else if (length > 85) {
strcpy(symbol->errtxt, "323: Input too long");
return ZINT_ERROR_TOO_LONG;
}
@ -217,12 +252,12 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
/* Start character */
strcpy(dest, "1211212111");
for (i = 0; i < (unsigned int) length; i++) {
for (i = 0; i < (int) length; i++) {
lookup(SILVER, C39Table, source[i], dest);
counter += posn(SILVER, source[i]);
}
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->option_2 == 1)) {
if (symbol->option_2 == 1) {
char check_digit;
counter = counter % 43;
@ -268,7 +303,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
if ((symbol->symbology == BARCODE_LOGMARS) || (symbol->symbology == BARCODE_HIBC_39)) {
/* LOGMARS uses wider 'wide' bars than normal Code 39 */
counter = (unsigned int) strlen(dest);
counter = strlen(dest);
for (i = 0; i < counter; i++) {
if (dest[i] == '2') {
dest[i] = '3';
@ -279,13 +314,13 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_
expand(symbol, dest);
if (symbol->symbology == BARCODE_CODE39) {
strcpy((char*) symbol->text, "*");
strcat((char*) symbol->text, (char*) source);
strcat((char*) symbol->text, localstr);
strcat((char*) symbol->text, "*");
ustrcpy(symbol->text, "*");
ustrcat(symbol->text, source);
ustrcat(symbol->text, localstr);
ustrcat(symbol->text, "*");
} else {
strcpy((char*) symbol->text, (char*) source);
strcat((char*) symbol->text, localstr);
ustrcpy(symbol->text, source);
ustrcat(symbol->text, localstr);
}
return error_number;
}
@ -297,7 +332,6 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
unsigned int count, check_digit;
char localstr[11];
count = 0;
if (length > 7) {
strcpy(symbol->errtxt, "325: Input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -312,54 +346,57 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
zeroes = 7 - length + 1;
for (i = 1; i < zeroes; i++)
localstr[i] = '0';
strcpy(localstr + zeroes, (char *) source);
ustrcpy(localstr + zeroes, source);
count = 0;
for (i = 1; i < 8; i++) {
count += i * ctoi(localstr[i]);
}
check_digit = count % 11;
if (check_digit == 11) {
check_digit = 0;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("PZN: %s, check digit %d\n", localstr, check_digit);
}
localstr[8] = itoc(check_digit);
localstr[9] = '\0';
if (localstr[8] == 'A') {
if (check_digit == 10) {
strcpy(symbol->errtxt, "327: Invalid PZN Data");
return ZINT_ERROR_INVALID_DATA;
}
localstr[8] = itoc(check_digit);
localstr[9] = '\0';
error_number = c39(symbol, (unsigned char *) localstr, strlen(localstr));
ustrcpy(symbol->text, (unsigned char *) "PZN");
strcat((char*) symbol->text, localstr);
ustrcpy(symbol->text, "PZN ");
ustrcat(symbol->text, localstr);
return error_number;
}
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned char buffer[150] = {0};
unsigned int i;
unsigned char buffer[85 * 2 + 1] = {0};
int i;
int error_number;
if (length > 74) {
if (length > 85) {
strcpy(symbol->errtxt, "328: Input too long");
return ZINT_ERROR_TOO_LONG;
}
/* Creates a buffer string and places control characters into it */
for (i = 0; i < (unsigned int) length; i++) {
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "329: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
strcat((char*) buffer, EC39Ctrl[source[i]]);
ustrcat(buffer, EC39Ctrl[source[i]]);
}
/* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer, ustrlen(buffer));
for (i = 0; i < (unsigned int) length; i++)
for (i = 0; i < length; i++)
symbol->text[i] = source[i] ? source[i] : ' ';
symbol->text[length] = '\0';
@ -587,8 +624,8 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
zeroes = 0;
}
memset(hrt, '0', zeroes);
strcpy(hrt + zeroes, (char *) source);
ustrcpy(symbol->text, (unsigned char *) hrt);
ustrcpy(hrt + zeroes, source);
ustrcpy(symbol->text, hrt);
expand(symbol, pattern);
@ -601,7 +638,6 @@ INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const
/* This code verifies the check digit present in North American VIN codes */
int zeros;
char local_source[18];
char dest[200];
char input_check;
@ -613,82 +649,77 @@ INTERNAL int vin(struct zint_symbol *symbol, const unsigned char source[], const
int length = (int) in_length;
// Check length
if (length > 17) {
strcpy(symbol->errtxt, "336: Input too long");
if (length != 17) {
strcpy(symbol->errtxt, "336: Input wrong length, 17 characters required");
return ZINT_ERROR_TOO_LONG;
}
// Pad with zeros
zeros = 17 - length;
for (i = 0; i < 17; i++) {
local_source[i] = '0';
}
local_source[17] = '\0';
for (i = 0; i < length; i++) {
local_source[zeros + i] = source[i];
}
to_upper((unsigned char *) local_source);
// Check input characters, I, O and Q are not allowed
if (is_sane(ARSENIC, (unsigned char *) local_source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(ARSENIC, source, length) == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "337: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
}
input_check = local_source[8];
ustrcpy(local_source, source);
for (i = 0; i < 17; i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
value[i] = local_source[i] - '0';
to_upper((unsigned char *) local_source);
// Check digit only valid for North America
if (local_source[0] >= '1' && local_source[0] <= '5') {
input_check = local_source[8];
for (i = 0; i < 17; i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
value[i] = local_source[i] - '0';
} else if ((local_source[i] >= 'A') && (local_source[i] <= 'I')) {
value[i] = (local_source[i] - 'A') + 1;
} else if ((local_source[i] >= 'J') && (local_source[i] <= 'R')) {
value[i] = (local_source[i] - 'J') + 1;
} else if ((local_source[i] >= 'S') && (local_source[i] <= 'Z')) {
value[i] = (local_source[i] - 'S') + 2;
}
}
if ((local_source[i] >= 'A') && (local_source[i] <= 'I')) {
value[i] = (local_source[i] - 'A') + 1;
sum = 0;
for (i = 0; i < 17; i++) {
sum += value[i] * weight[i];
}
if ((local_source[i] >= 'J') && (local_source[i] <= 'R')) {
value[i] = (local_source[i] - 'J') + 1;
output_check = '0' + (sum % 11);
if (output_check == ':') {
// Check digit was 10
output_check = 'X';
}
if ((local_source[i] >= 'S') && (local_source[i] <= 'Z')) {
value[i] = (local_source[i] - 'S') + 2;
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Producing VIN code: %s\n", local_source);
printf("Input check was %c, calculated check is %c\n", input_check, output_check);
}
}
sum = 0;
for (i = 0; i < 17; i++) {
sum += value[i] * weight[i];
}
output_check = '0' + (sum % 11);
if (output_check == ':') {
// Check digit was 10
output_check = 'X';
}
if (symbol->debug) {
printf("Producing VIN code: %s\n", local_source);
printf("Input check was %c, calculated check is %c\n", input_check, output_check);
}
if (input_check != output_check) {
strcpy(symbol->errtxt, "338: Invalid check digit in input data");
return ZINT_ERROR_INVALID_DATA;
if (input_check != output_check) {
strcpy(symbol->errtxt, "338: Invalid check digit in input data");
return ZINT_ERROR_INVALID_DATA;
}
}
/* Start character */
strcpy(dest, "1211212111");
/* Import character 'I' prefix? */
if (symbol->option_2 & 1) {
strcat(dest, "1121122111");
}
// Copy glyphs to symbol
for (i = 0; i < 17; i++) {
lookup(SILVER, C39Table, local_source[i], dest);
}
/* Stop character */
strcat(dest, "121121211");
ustrcpy(symbol->text, (unsigned char *) local_source);
ustrcpy(symbol->text, local_source);
expand(symbol, dest);
return 0;

View File

@ -36,7 +36,6 @@
#include "reedsol.h"
#include "large.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
static void horiz(struct zint_symbol *symbol, int row_no, int full) {
@ -121,12 +120,16 @@ static int isedi(unsigned char input) {
static int dq4bi(unsigned char source[], int sourcelen, int position) {
int i;
for (i = position; isedi(source[position + i]) && ((position + i) < sourcelen); i++);
for (i = 0; ((position + i) < sourcelen) && isedi(source[position + i]); i++);
if ((position + i) == sourcelen) {
/* Reached end of input */
return 0;
}
if (i == 0) {
/* Not EDI */
return 0;
}
if (source[position + i - 1] == 13) {
return 1;
@ -320,7 +323,6 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio
if (c40_count < edi_count) {
best_scheme = C1_C40;
} else {
done = 0;
if (c40_count == edi_count) {
if (dq4bi(source, sourcelen, position)) {
best_scheme = C1_EDI;
@ -361,7 +363,6 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
sp = 0;
tp = 0;
latch = 0;
memset(c40_buffer, 0, sizeof(*c40_buffer));
c40_p = 0;
memset(text_buffer, 0, sizeof(*text_buffer));
@ -455,7 +456,7 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne
}
if (next_mode == C1_ASCII) { /* Step B3 */
if (istwodigits(source, sp) && ((sp + 1) != length)) {
if (istwodigits(source, length, sp)) {
target[tp] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130;
tp++;
sp += 2;
@ -1304,14 +1305,17 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
if (symbol->option_2 == 10) {
/* Version T */
unsigned int data[40], ecc[25];
unsigned int stream[65];
unsigned int data[80] = {0}; /* Allow for doubled digits */
unsigned int ecc[22];
unsigned int stream[60];
int data_length;
int data_cw, ecc_cw, block_width;
for (i = 0; i < 40; i++) {
data[i] = 0;
if (length > 80) {
strcpy(symbol->errtxt, "519: Input data too long");
return ZINT_ERROR_TOO_LONG;
}
data_length = c1_encode(symbol, source, data, length);
if (data_length == 0) {

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -30,18 +30,12 @@
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include <string.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
/* Local replacement for strlen() with unsigned char strings */
INTERNAL size_t ustrlen(const unsigned char data[]) {
return strlen((const char*) data);
}
/* Converts a character 0-9 to its equivalent integer value */
INTERNAL int ctoi(const char source) {
if ((source >= '0') && (source <= '9'))
@ -153,23 +147,28 @@ INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, cons
return count;
}
/* Return true (1) if a module is dark/black, otherwise false (0) */
/* Return true (1) if a module is dark/black/colour, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
if (symbol->symbology == BARCODE_ULTRA) {
return symbol->encoded_data[y_coord][x_coord];
} else {
return (symbol->encoded_data[y_coord][x_coord / 7] >> (x_coord % 7)) & 1;
return (symbol->encoded_data[y_coord][x_coord / 8] >> (x_coord % 8)) & 1;
}
}
/* Set a module to dark/black */
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord / 7] |= 1 << (x_coord % 7);
symbol->encoded_data[y_coord][x_coord / 8] |= 1 << (x_coord % 8);
}
/* Set a module to a colour */
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord, const int colour) {
symbol->encoded_data[y_coord][x_coord] = colour;
}
/* Set (or unset) a module to white */
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord / 7] &= ~(1 << (x_coord % 7));
symbol->encoded_data[y_coord][x_coord / 8] &= ~(1 << (x_coord % 8));
}
/* Expands from a width pattern to a bit pattern */
@ -263,11 +262,10 @@ INTERNAL int is_composite(int symbology) {
return symbology >= BARCODE_EANX_CC && symbology <= BARCODE_RSS_EXPSTACK_CC;
}
INTERNAL int istwodigits(const unsigned char source[], const size_t position) {
if ((source[position] >= '0') && (source[position] <= '9')) {
if ((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
return 1;
}
INTERNAL int istwodigits(const unsigned char source[], const int length, const int position) {
if ((position + 1 < length) && (source[position] >= '0') && (source[position] <= '9')
&& (source[position + 1] >= '0') && (source[position + 1] <= '9')) {
return 1;
}
return 0;

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -36,20 +36,24 @@
#define __COMMON_H
#ifndef FALSE
#define FALSE 0
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#define TRUE 1
#endif
/* The most commonly used set */
#define NEON "0123456789"
#define NEON "0123456789"
#include "zint.h"
#include <stdlib.h>
#include <string.h>
#define ustrcpy(target,source) strcpy((char*)target,(const char*)source)
/* Helpers to cast away char pointer signedness */
#define ustrlen(source) strlen((const char *) (source))
#define ustrcpy(target, source) strcpy((char *) (target), (const char *) (source))
#define ustrcat(target, source) strcat((char *) (target), (const char *) (source))
#if defined(__GNUC__) && !defined(ZINT_TEST)
#define INTERNAL __attribute__ ((visibility ("hidden")))
@ -61,7 +65,6 @@
extern "C" {
#endif /* __cplusplus */
INTERNAL size_t ustrlen(const unsigned char data[]);
INTERNAL int ctoi(const char source);
INTERNAL char itoc(const int source);
INTERNAL void to_upper(unsigned char source[]);
@ -73,12 +76,13 @@ extern "C" {
INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, const unsigned char c);
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL int istwodigits(const unsigned char source[], const size_t position);
INTERNAL void expand(struct zint_symbol *symbol, const char data[]);
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord, const int colour);
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
INTERNAL void expand(struct zint_symbol *symbol, const char data[]);
INTERNAL int is_stackable(const int symbology);
INTERNAL int is_extendable(const int symbology);
INTERNAL int is_composite(const int symbology);
INTERNAL int istwodigits(const unsigned char source[], int length, const int position);
INTERNAL unsigned int decode_utf8(unsigned int* state, unsigned int* codep, const unsigned char byte);
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[], size_t *length, int disallow_4byte);
INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_height);

View File

@ -571,7 +571,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
if (symbol->output_options & READER_INIT) {
if (gs1) {
strcpy(symbol->errtxt, "519: Cannot encode in GS1 mode and Reader Initialisation at the same time");
strcpy(symbol->errtxt, "521: Cannot encode in GS1 mode and Reader Initialisation at the same time");
return ZINT_ERROR_INVALID_OPTION;
} else {
target[tp] = 234;
@ -643,7 +643,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
if (current_mode == DM_ASCII) {
next_mode = DM_ASCII;
if (istwodigits(source, sp) && ((sp + 1) != inputlen)) {
if (istwodigits(source, inputlen, sp)) {
target[tp] = (unsigned char) ((10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130);
if (debug) printf("N%d ", target[tp] - 130);
tp++;

View File

@ -31,7 +31,6 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#ifdef _MSC_VER
#include <malloc.h>
@ -39,7 +38,7 @@
#include "common.h"
#include "gs1.h"
#define TECHNETIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
#define TECHNETIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
struct zint_symbol *ZBarcode_Create() {
struct zint_symbol *symbol;
@ -65,14 +64,12 @@ struct zint_symbol *ZBarcode_Create() {
symbol->show_hrt = 1; // Show human readable text
symbol->fontsize = 8;
symbol->input_mode = DATA_MODE;
strcpy(symbol->primary, "");
memset(&(symbol->encoded_data[0][0]), 0, sizeof (symbol->encoded_data));
memset(&(symbol->row_height[0]), 0, sizeof (symbol->row_height));
symbol->bitmap = NULL;
symbol->bitmap_width = 0;
symbol->bitmap_height = 0;
symbol->eci = 0; // Default 0 uses ECI 3
symbol->dot_size = 4.0 / 5.0;
symbol->vector = NULL;
symbol->debug = 0;
return symbol;
}
@ -1339,6 +1336,14 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
if (!(is_matrix(symbol->symbology))) {
strcpy(symbol->errtxt, "237: Selected symbology cannot be rendered as dots");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
return ZINT_ERROR_INVALID_OPTION;
}
}
error_number = plot_raster(symbol, rotate_angle, OUT_BUFFER);
error_tag(symbol->errtxt, error_number);
return error_number;
@ -1359,6 +1364,14 @@ int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->output_options & BARCODE_DOTTY_MODE) {
if (!(is_matrix(symbol->symbology))) {
strcpy(symbol->errtxt, "238: Selected symbology cannot be rendered as dots");
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
return ZINT_ERROR_INVALID_OPTION;
}
}
error_number = plot_vector(symbol, rotate_angle, OUT_BUFFER);
error_tag(symbol->errtxt, error_number);
return error_number;

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -32,15 +32,14 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], const size_t length);
/* Codabar table checked against EN 798:1995 */
#define CALCIUM "0123456789-$:/.+ABCD"
#define CALCIUM "0123456789-$:/.+ABCD"
#define CALCIUM_INNER "0123456789-$:/.+"
static const char *CodaTable[20] = {
"11111221", "11112211", "11121121", "22111111", "11211211", "21111211",
@ -198,6 +197,7 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
int i, error_number;
char dest[512];
int add_checksum, count, checksum;
strcpy(dest, "");
@ -205,26 +205,52 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(symbol->errtxt, "356: Input too long");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(CALCIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "357: Invalid characters in data");
return error_number;
/* BS EN 798:1995 4.2 "'Codabar' symbols shall consist of ... b) start character;
* c) one or more symbol characters representing data ... d) stop character ..." */
if (length < 3) {
strcpy(symbol->errtxt, "362: Input too short");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
/* Codabar must begin and end with the characters A, B, C or D */
if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C')
&& (source[0] != 'D')) {
strcpy(symbol->errtxt, "358: Invalid characters in data");
strcpy(symbol->errtxt, "358: Does not begin with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Does not end with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Invalid characters in data");
return ZINT_ERROR_INVALID_DATA;
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
error_number = is_sane(CALCIUM_INNER, source + 1, length - 2);
if (error_number) {
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
return error_number;
}
add_checksum = symbol->option_2 == 1;
if (add_checksum) {
count = 0;
}
for (i = 0; i < length; i++) {
if (add_checksum) {
count += strchr(CALCIUM, source[i]) - CALCIUM;
if (i + 1 == length) {
checksum = count % 16;
if (checksum) {
checksum = 16 - checksum;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codabar: %s, count %d, checksum %d\n", source, count, checksum);
}
strcat(dest, CodaTable[checksum]);
}
}
lookup(CALCIUM, CodaTable, source[i], dest);
}
@ -255,11 +281,10 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
/* Add leading zeros as required */
zeroes = 8 - length;
memset(localstr, '0', zeroes);
strcpy(localstr + zeroes, (char*) source);
ustrcpy(localstr + zeroes, source);
/* Calculate the check digit */
checksum = 0;
checkpart = 0;
for (i = 0; i < 4; i++) {
checkpart = ctoi(localstr[i * 2]);
checksum += checkpart;
@ -302,8 +327,8 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
}
/* Override the normal text output with the Pharmacode number */
strcpy((char*) symbol->text, "A");
strcat((char*) symbol->text, (char*) localstr);
ustrcpy(symbol->text, "A");
ustrcat(symbol->text, localstr);
return error_number;
}

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -32,12 +32,10 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#define SSET "0123456789ABCDEF"
#define SSET "0123456789ABCDEF"
static const char *PlessTable[16] = {
"13131313", "31131313", "13311313", "31311313", "13133113", "31133113",
"13313113", "31313113", "13131331", "31131331", "13311331", "31311331", "13133131",
@ -112,9 +110,9 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], const s
}
/* Plain MSI Plessey - does not calculate any check character */
static int msi_plessey(struct zint_symbol *symbol, unsigned char source[], const size_t length) {
static int msi_plessey(struct zint_symbol *symbol, unsigned char source[], const int length) {
size_t i;
int i;
char dest[512]; /* 2 + 55 * 8 + 3 + 1 ~ 512 */
if (length > 55) {
@ -141,8 +139,8 @@ static int msi_plessey(struct zint_symbol *symbol, unsigned char source[], const
* http://www.barcodeisland.com/ */
static int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned long i, wright, dau, pedwar, pump, n;
int i, wright, pump, n;
unsigned long dau, pedwar;
char un[200], tri[32];
int error_number, h;
char dest[1000];
@ -206,10 +204,10 @@ static int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[],
/* MSI Plessey with two Modulo 10 check digits - algorithm from
* Barcode Island http://www.barcodeisland.com/ */
static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], const int src_len) {
unsigned long i, n, wright, dau, pedwar, pump, chwech;
int i, n, wright, pump;
unsigned long dau, pedwar, chwech;
char un[16], tri[32];
int error_number, h;
char dest[1000];
@ -310,9 +308,10 @@ static int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[
/* Calculate a Modulo 11 check digit using the system discussed on Wikipedia -
see http://en.wikipedia.org/wiki/Talk:MSI_Barcode */
static int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
static int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[], const int src_len) {
/* uses the IBM weight system */
int i, weight, x, check;
int i, weight, check;
unsigned long x;
int error_number;
char dest[1000];
@ -368,16 +367,17 @@ static int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[],
/* Combining the Barcode Island and Wikipedia code
* Verified against http://www.bokai.com/BarcodeJSP/applet/BarcodeSampleApplet.htm */
static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len) {
static int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], const int src_len) {
/* Weighted using the IBM system */
unsigned long i, weight, x, check, wright, dau, pedwar, pump;
size_t h;
long si;
int i, weight, check, wright, pump;
unsigned long x, dau, pedwar;
int h;
int si;
char un[16], tri[16];
int error_number;
char dest[1000];
unsigned char temp[32];
unsigned int temp_len;
int temp_len;
error_number = 0;

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Including bug fixes by Bryan Hatton
Redistribution and use in source and binary forms, with or without
@ -32,15 +32,13 @@
*/
/* vim: set ts=4 sw=4 et : */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#define DAFTSET "DAFT"
#define DAFTSET "DAFT"
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define KASUTSET "1234567890-abcdefgh"
#define CHKASUTSET "0123456789-abcdefgh"
@ -87,11 +85,9 @@ static const char *JapanTable[19] = {
/* Handles the PostNet system used for Zip codes in the US */
static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
unsigned int i, sum, check_digit;
int i, sum, check_digit;
int error_number;
error_number = 0;
if (length != 5 && length != 9 && length != 11) {
strcpy(symbol->errtxt, "480: Input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -127,8 +123,6 @@ INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int l
int writer;
int error_number;
error_number = 0;
error_number = postnet(symbol, source, height_pattern, length);
if (error_number != 0) {
return error_number;
@ -153,11 +147,9 @@ INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int l
/* Handles the PLANET system used for item tracking in the US */
static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
unsigned int i, sum, check_digit;
int i, sum, check_digit;
int error_number;
error_number = 0;
if (length != 11 && length != 13) {
strcpy(symbol->errtxt, "482: Input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -193,8 +185,6 @@ INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int
int writer;
int error_number;
error_number = 0;
error_number = planet(symbol, source, height_pattern, length);
if (error_number != 0) {
return error_number;
@ -221,7 +211,6 @@ INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int
int total, loop, check, zeroes, error_number;
char localstr[8], dest[80];
error_number = 0;
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long");
return ZINT_ERROR_TOO_LONG;
@ -259,7 +248,6 @@ INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int
glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */
INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length) {
char dest[16] = {0};
if (length > 1) {
@ -296,7 +284,7 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
/* Handles the 4 State barcodes used in the UK by Royal Mail */
static char rm4scc(char source[], unsigned char dest[], int length) {
unsigned int i;
int i;
int top, bottom, row, column, check_digit;
char values[3], set_copy[] = KRSET;
@ -334,13 +322,11 @@ static char rm4scc(char source[], unsigned char dest[], int length) {
/* Puts RM4SCC into the data matrix */
INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[210];
unsigned int loopey, h;
int loopey, h;
int writer;
int error_number;
strcpy(height_pattern, "");
error_number = 0;
if (length > 50) {
strcpy(symbol->errtxt, "488: Input too long");
return ZINT_ERROR_TOO_LONG;
@ -380,13 +366,11 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
Specification at http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx */
INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[75], localstr[20];
unsigned int loopey;
int loopey;
int writer, i, h;
int error_number; /* zeroes; */
int error_number;
strcpy(height_pattern, "");
error_number = 0;
if (length > 18) {
strcpy(symbol->errtxt, "490: Input too long");
return ZINT_ERROR_TOO_LONG;
@ -434,7 +418,6 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
int writer, i, error_number;
strcpy(height_pattern, "");
error_number = 0;
if (length > 50) {
strcpy(symbol->errtxt, "492: Input too long");
return ZINT_ERROR_TOO_LONG;
@ -489,8 +472,6 @@ INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], i
int loop, error_number;
char dest[512]; /* 90 * 4 + 1 ~ */
error_number = 0;
if (length > 90) {
strcpy(symbol->errtxt, "494: Input too long");
return ZINT_ERROR_TOO_LONG;
@ -528,7 +509,6 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
return ZINT_ERROR_TOO_LONG;
}
inter_posn = 0;
error_number = 0;
strcpy(local_source, (char*) source);

View File

@ -61,12 +61,20 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
static const char ultra_colour[] = "WCBMRYGK";
static void buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
/* Place pixelbuffer into symbol */
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row, column, i;
if (symbol->bitmap != NULL) {
free(symbol->bitmap);
symbol->bitmap = NULL;
}
symbol->bitmap = (unsigned char *) malloc(symbol->bitmap_width * symbol->bitmap_height * 3);
if (symbol->bitmap == NULL) {
strcpy(symbol->errtxt, "661: Insufficient memory for bitmap buffer");
return ZINT_ERROR_MEMORY;
}
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);
@ -133,6 +141,8 @@ static void buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
}
}
}
return 0;
}
static int save_raster_image_to_file(struct zint_symbol *symbol, int image_height, int image_width, char *pixelbuf, int rotate_angle, int image_type) {
@ -194,8 +204,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, int image_heigh
switch (image_type) {
case OUT_BUFFER:
buffer_plot(symbol, rotated_pixbuf);
error_number = 0;
error_number = buffer_plot(symbol, rotated_pixbuf);
break;
case OUT_PNG_FILE:
#ifndef NO_PNG

View File

@ -31,15 +31,15 @@
*/
/* vim: set ts=4 sw=4 et : */
#define SODIUM "0123456789X"
/* Telepen Barcode Symbology information and History (BSiH) https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */
#define SODIUM "0123456789X"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
static char *TeleTable[] = {
"1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31313131", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
"31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111",
@ -49,18 +49,18 @@ static char *TeleTable[] = {
"3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131",
"3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133",
"313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111",
"31311133", "1131331111", "33331111", " 1111311133", "3111331111", "11331133", "13131133", "111111331111",
"31311133", "1131331111", "33331111", "1111311133", "3111331111", "11331133", "13131133", "111111331111",
"3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133",
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113"
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113", "1111111111111111",
};
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
unsigned int i, count, check_digit;
int error_number;
char dest[521]; /* 12 (start) + 30 * 16 (max for nuls) + 16 (check digit) + 12 (stop) + 1 = 521 */
char dest[521]; /* 12 (start) + 30 * 16 (max for DELs) + 16 (check digit) + 12 (stop) + 1 = 521 */
error_number = 0;
@ -74,7 +74,7 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const s
strcpy(dest, TeleTable['_']);
for (i = 0; i < src_len; i++) {
if (source[i] > 126) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "391: Invalid characters in input data");
return ZINT_ERROR_INVALID_DATA;
@ -107,8 +107,8 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], const s
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], const size_t src_len) {
unsigned int count, check_digit, glyph;
int error_number;
size_t i,temp_length = src_len;
char dest[521]; /* 12 (start) + 30 * 16 (max for nuls) + 16 (check digit) + 12 (stop) + 1 = 521 */
size_t i, temp_length = src_len;
char dest[521]; /* 12 (start) + 30 * 16 (max for DELs) + 16 (check digit) + 12 (stop) + 1 = 521 */
unsigned char temp[64];
count = 0;

View File

@ -50,10 +50,13 @@ macro(zint_add_test test_name test_command)
add_test(${test_name} ${test_command})
endmacro(zint_add_test)
zint_add_test(2of5, test_2of5)
zint_add_test(auspost, test_auspost)
zint_add_test(aztec, test_aztec)
zint_add_test(bmp, test_bmp)
zint_add_test(channel, test_channel)
zint_add_test(codablock, test_codablock)
zint_add_test(code, test_code)
zint_add_test(code1, test_code1)
zint_add_test(code128, test_code128)
zint_add_test(code16k, test_code16k)
@ -74,8 +77,10 @@ zint_add_test(imail, test_imail)
zint_add_test(library, test_library)
zint_add_test(mailmark, test_mailmark)
zint_add_test(maxicode, test_maxicode)
zint_add_test(medical, test_medical)
zint_add_test(pcx, test_pcx)
zint_add_test(pdf417, test_pdf417)
zint_add_test(plessey, test_plessey)
zint_add_test(png, test_png)
zint_add_test(postal, test_postal)
zint_add_test(print, test_print)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

307
backend/tests/test_2of5.c Normal file
View File

@ -0,0 +1,307 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_C25MATRIX, "1", 80, 0, 1, 817 },
/* 1*/ { BARCODE_C25MATRIX, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_C25INTER, "1", 89, 0, 1, 819 },
/* 3*/ { BARCODE_C25INTER, "1", 90, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_C25IATA, "1", 45, 0, 1, 639 },
/* 5*/ { BARCODE_C25IATA, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_C25LOGIC, "1", 80, 0, 1, 809 },
/* 7*/ { BARCODE_C25LOGIC, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_C25IND, "1", 45, 0, 1, 649 },
/* 9*/ { BARCODE_C25IND, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_DPLEIT, "1", 13, 0, 1, 135 },
/* 11*/ { BARCODE_DPLEIT, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_DPIDENT, "1", 11, 0, 1, 117 },
/* 13*/ { BARCODE_DPIDENT, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_ITF14, "1", 13, 0, 1, 135 },
/* 15*/ { BARCODE_ITF14, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_C25MATRIX, "123456789", "123456789" },
/* 1*/ { BARCODE_C25INTER, "123456789", "0123456789" }, // Adds leading zero if odd
/* 2*/ { BARCODE_C25IATA, "123456789", "123456789" },
/* 3*/ { BARCODE_C25LOGIC, "123456789", "123456789" },
/* 4*/ { BARCODE_C25IND, "123456789", "123456789" },
/* 5*/ { BARCODE_DPLEIT, "123456789", "00001234567890" }, // Leading zeroes added to make 13 + appended checksum
/* 6*/ { BARCODE_DPLEIT, "1234567890123", "12345678901236" },
/* 7*/ { BARCODE_DPIDENT, "123456789", "001234567890" }, // Leading zeroes added to make 11 + appended checksum
/* 8*/ { BARCODE_DPIDENT, "12345678901", "123456789016" },
/* 9*/ { BARCODE_ITF14, "123456789", "00001234567895" }, // Leading zeroes added to make 13 + appended checksum
/* 10*/ { BARCODE_ITF14, "1234567890123", "12345678901231" },
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_C25MATRIX, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 1*/ { BARCODE_C25INTER, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_C25IATA, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { BARCODE_C25LOGIC, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_C25IND, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 5*/ { BARCODE_DPLEIT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_DPIDENT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 7*/ { BARCODE_ITF14, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
// BARCODE_ITF14 examples verified manually against GS1 General Specifications 20.0
struct item data[] = {
/* 0*/ { BARCODE_C25MATRIX, "87654321", 0, 1, 97, "Standard Code 2 of 5; verified manually against bwipp and tec-it",
"1111010101110100010101000111010001110101110111010101110111011100010101000101110111010111011110101"
},
/* 1*/ { BARCODE_C25INTER, "87654321", 0, 1, 81, "Interleaved Code 2 of 5; verified manually against bwipp and tec-it",
"101011101010111000100010001110111000101010001000111010111010001110101011100011101"
},
/* 2*/ { BARCODE_C25INTER, "602003", 0, 1, 63, "DX cartridge barcode https://en.wikipedia.org/wiki/Interleaved_2_of_5 example",
"101010111011100010001010111010001000111010001000111011101011101"
},
/* 3*/ { BARCODE_C25IATA, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against bwipp and tec-it",
"1010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111011101"
},
/* 4*/ { BARCODE_C25LOGIC, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against bwipp and tec-it",
"10101110100010101000111010001110101110111010101110111011100010101000101110111010111011101"
},
/* 5*/ { BARCODE_C25IND, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against bwipp and tec-it",
"11101110101110101011101010101011101110101110111010101110101110101010101110101110111011101010101011101010111011101010101110111010111"
},
/* 6*/ { BARCODE_DPLEIT, "87654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against bwipp and tec-it (0000087654321)",
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
},
/* 7*/ { BARCODE_DPLEIT, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example",
"101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101"
},
/* 8*/ { BARCODE_DPIDENT, "87654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against bwipp and tec-it (00087654321)",
"101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101"
},
/* 9*/ { BARCODE_DPIDENT, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example",
"101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101"
},
/* 10*/ { BARCODE_ITF14, "87654321", 0, 1, 135, "ITF-14; verified manually against bwipp and tec-it (0000087654321)",
"101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101"
},
/* 11*/ { BARCODE_ITF14, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2",
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001010001000111011101011101"
},
/* 12*/ { BARCODE_ITF14, "1540014128876", 0, 1, 135, "GS1 General Specifications Figure 5.3.2.4-1",
"101011100010100010111010101110001000111010001011101110100010001011101011100010001110101000111011101010111000100010001110001110101011101"
},
/* 13*/ { BARCODE_ITF14, "0950110153001", 0, 1, 135, "GS1 General Specifications Figure 5.3.6-1",
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

View File

@ -31,6 +31,245 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133 },
/* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133 },
/* 3*/ { BARCODE_AUSPOST, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_AUSPOST, "1", 16, 0, 3, 103 },
/* 5*/ { BARCODE_AUSPOST, "1", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_AUSPOST, "1", 13, 0, 3, 103 },
/* 7*/ { BARCODE_AUSPOST, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_AUSPOST, "1", 8, 0, 3, 73 },
/* 9*/ { BARCODE_AUSPOST, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_AUSREPLY, "1", 8, 0, 3, 73 },
/* 11*/ { BARCODE_AUSREPLY, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_AUSROUTE, "1", 8, 0, 3, 73 },
/* 13*/ { BARCODE_AUSROUTE, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73 },
/* 15*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[64];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "12345678901234567890123", "" }, // None
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73 },
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103 },
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103 },
/* 5*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103 },
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133 }, // Length 18
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133 },
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 10*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73 },
/* 11*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73 }, // Leading zeroes added
/* 12*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73 },
/* 13*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73 },
/* 14*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73 },
/* 15*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73 },
/* 16*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73 },
/* 17*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1 }, // No leading zeroes added
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// Australia Post Customer Barcoding Technical Specifications (Revised Aug 2012)
// https://auspost.com.au/content/dam/auspost_corp/media/documents/customer-barcode-technical-specifications-aug2012.pdf
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "119618420932573854", 0, 3, 133, "Australia Post Customer Barcoding Tech Specs Diagram 1; verified manually against tec-it",
"1000001010001010101000100010101000001010100000000000000000100000101000101000001000100000001000101000101000101000101000001000100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010101000100000101010100010100000101010101000101000101000100000000000101000101000100000000000001000000010100010001010101000000"
},
/* 1*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "Verified manually against tec-it",
"1000101010001010100010101010100000100010000000001000001000000000100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000000000101000101000100000001010101000101000000000100010101000101000000"
},
/* 2*/ { BARCODE_AUSROUTE, "34567890", 0, 3, 73, "Verified manually against tec-it",
"1000000000101010101010000010001000000010101000100010101010000000101000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010000010000000101010100010100010101000100010101010001010001000000"
},
/* 3*/ { BARCODE_AUSREDIRECT, "98765432", 0, 3, 73, "Verified manually against tec-it",
"1000001010000010000000100010100010101010100000101010101000100010100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001010100010101010001010001000000010101000000000001010101000001010000"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// #181 Christian Hartlage OSS-Fuzz
static void test_fuzz(int index, int debug) {
@ -81,6 +320,10 @@ static void test_fuzz(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
};

View File

@ -66,7 +66,7 @@ static void test_encode(int index, int generate, int debug) {
"110001010010001"
"101011110101010"
"100010001000101"
},
},
/* 1*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, "Aztec Code is a public domain 2D matrix barcode symbology of nominally square symbols built on a square grid with a distinctive square bullseye pattern at their center.", 0, 41, 41, "ISO/IEC 24778:2008 Figure 1 (right) NOTE: Not the same but down to single encoding mode difference (UPPER space rather than LOWER space after 2D)",
"00001100110010010010111000010100001011000"
"01000110010110110001000000100101101000001"
@ -109,7 +109,7 @@ static void test_encode(int index, int generate, int debug) {
"10101101110100001100111100110101001010001"
"00010010010011001011011010000110001000101"
"10001000001010100110100000001001001110000"
},
},
/* 2*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, "Code 2D!", 0, 15, 15, "ISO/IEC 24778:2008 Figure G.2",
"000110001100000"
"000000110000010"
@ -126,7 +126,7 @@ static void test_encode(int index, int generate, int debug) {
"010001100010010"
"011000011011010"
"111001101100000"
},
},
/* 3*/ { BARCODE_AZTEC, UNICODE_MODE, -1, 1, "Code 2D!", 0, 15, 15, "ISO/IEC 24778:2008 Figure G.2; specify size",
"000110001100000"
"000000110000010"
@ -143,7 +143,7 @@ static void test_encode(int index, int generate, int debug) {
"010001100010010"
"011000011011010"
"111001101100000"
},
},
/* 4*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", 0, 53, 53, "**NOT SAME** ISO/IEC 24778:2008 Figure I.1 (left) TODO: investigate",
"00010101011010101010101010110101010101010110101010101"
"00101010100101010101010101001010101010101001010101010"
@ -198,7 +198,7 @@ static void test_encode(int index, int generate, int debug) {
"01101010101101010101010101101010101010101011010100101"
"01010101010010101010101010010101010101010100101010110"
"10101010101101010101010101101010101010101011010101001"
},
},
/* 5*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, "3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333", 0, 53, 53, "**NOT SAME** ISO/IEC 24778:2008 Figure I.1 (right) TODO: investigate",
"00111111111111111111111111111111111111111111111111111"
"00000000000000000000000000000000000000000000000000000"
@ -253,7 +253,7 @@ static void test_encode(int index, int generate, int debug) {
"10111111111111111111111111111111111111111111111110101"
"00000000000000000000000000000000000000000000000000001"
"11111111111111111111111111111111111111111111111111101"
},
},
/* 6*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, "[01]03453120000011[17]120508[10]ABCD1234[410]9501101020917", 0, 23, 23, "#189 Follow embedded FLG(n) with FLG(0)",
"00100000101111000100100"
"00011101100110001010000"
@ -278,7 +278,7 @@ static void test_encode(int index, int generate, int debug) {
"11000101000100100000100"
"00010001010101010101011"
"11101100000000000010110"
},
},
/* 7*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, "[01]95012345678903[3103]000123", 0, 19, 19, "#189 Follow embedded FLG(n) with FLG(0)",
"0000000100001010101"
"0001101111011000000"
@ -299,7 +299,7 @@ static void test_encode(int index, int generate, int debug) {
"0111000111101011001"
"1000110111011000101"
"1010100000101101001"
},
},
/* 8*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, "[01]04610044273252[21]LRFX)k<C7ApWJ[91]003A[92]K8rNAqdvjmdxsmCVuj3FhaoNzQuq7Uff0sHXfz1TT/doiMaGQqNF+VPwMvwVbm1fxjzuDt6jxLCcc8o/tqbEDA==", 0, 45, 45, "#189 Follow embedded FLG(n) with FLG(0)",
"000000101110011010101010010110011000001010111"
"000110001111011100111101101110110000000000011"
@ -346,8 +346,29 @@ static void test_encode(int index, int generate, int debug) {
"101101111001110100000011101110110100011101011"
"000011010110101110000101110100000111000011010"
"101001110101010110100011010010001111001101101"
},
/* 9*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "0", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (1st)",
},
/* 9*/ { BARCODE_HIBC_AZTEC, UNICODE_MODE, -1, -1, "H123ABC01234567890", 0, 19, 19, "**NOT SAME** ANSI/HIBC 2.6 - 2016 Figure C1 TODO: investigate",
"0001100111110111011"
"0010111100111110001"
"0111011000010101001"
"1010010100011110000"
"0010110101001010011"
"0110111111111110001"
"0110110000000101001"
"0011110111110111001"
"1101010100010101010"
"1111010101010100101"
"1011110100010111000"
"0011110111110100101"
"1101010000000101011"
"0101011111111110110"
"0000000000010001101"
"0111000100111000010"
"0101000000100011010"
"1001001001100001110"
"1100001010110101000"
},
/* 10*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "0", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (1st)",
"11101010101"
"11111111111"
"01000000010"
@ -359,8 +380,8 @@ static void test_encode(int index, int generate, int debug) {
"01000000010"
"01111111111"
"00101010100"
},
/* 10*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "25", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (2nd)",
},
/* 11*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "25", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (2nd)",
"11101100101"
"11111111111"
"01000000011"
@ -372,8 +393,8 @@ static void test_encode(int index, int generate, int debug) {
"11000000011"
"01111111111"
"00100100000"
},
/* 11*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "125", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (3rd)",
},
/* 12*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "125", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (3rd)",
"11110101101"
"11111111111"
"11000000011"
@ -385,8 +406,8 @@ static void test_encode(int index, int generate, int debug) {
"11000000010"
"01111111111"
"00111101000"
},
/* 12*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "255", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (4th)",
},
/* 13*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, "255", 0, 11, 11, "ISO/IEC 24778:2008 Figure A.1 (4th)",
"11110101001"
"11111111111"
"01000000011"
@ -398,7 +419,7 @@ static void test_encode(int index, int generate, int debug) {
"11000000010"
"01111111111"
"00110011100"
},
},
};
int data_size = sizeof(data) / sizeof(struct item);
@ -431,7 +452,7 @@ static void test_encode(int index, int generate, int debug) {
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2,
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);

126
backend/tests/test_bmp.c Normal file
View File

@ -0,0 +1,126 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
#include <sys/stat.h>
extern int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf);
static void test_pixel_plot(int index, int debug) {
testStart("");
if (!testUtilHaveIdentify()) {
testSkip("ImageMagick identify not available");
return;
}
int ret;
struct item {
int width;
int height;
unsigned char *pattern;
int repeat;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { 1, 1, "1", 0 },
/* 1*/ { 2, 1, "11", 0 },
/* 2*/ { 2, 2, "10", 1 },
/* 3*/ { 3, 1, "101", 0 },
/* 4*/ { 3, 2, "101010", 0 },
/* 5*/ { 3, 3, "101010101", 0 },
/* 6*/ { 4, 1, "1001", 0 },
/* 7*/ { 4, 3, "1001", 1 },
/* 8*/ { 5, 1, "10101", 0 },
/* 9*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0 },
};
int data_size = ARRAY_SIZE(data);
char *bmp = "out.bmp";
char escaped[1024];
int escaped_size = 1024;
char data_buf[8 * 2 + 1];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
strcpy(symbol->outfile, bmp);
symbol->bitmap_width = data[i].width;
symbol->bitmap_height = data[i].height;
symbol->debug |= debug;
int size = data[i].width * data[i].height;
assert_nonzero(size < (int) sizeof(data_buf), "i:%d bmp_pixel_plot size %d < sizeof(data_buf) %d\n", i, size, (int) sizeof(data_buf));
if (data[i].repeat) {
testUtilStrCpyRepeat(data_buf, data[i].pattern, size);
} else {
strcpy(data_buf, data[i].pattern);
}
assert_equal(size, (int) strlen(data_buf), "i:%d bmp_pixel_plot size %d != strlen(data_buf) %d\n", i, size, (int) strlen(data_buf));
symbol->bitmap = data_buf;
ret = bmp_pixel_plot(symbol, data_buf);
assert_zero(ret, "i:%d bmp_pixel_plot ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
ret = testUtilVerifyIdentify(symbol->outfile, debug);
assert_zero(ret, "i:%d identify %s ret %d != 0\n", i, symbol->outfile, ret);
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
symbol->bitmap = NULL;
ZBarcode_Delete(symbol);
}
testFinish();
}
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 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

392
backend/tests/test_code.c Normal file
View File

@ -0,0 +1,392 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "1", 121, 0, 1, 999 }, // 8 (Start) + 121*8 + 2*8 (Checks) + 7 (Stop) == 999
/* 1*/ { BARCODE_CODE11, -1, "1", 122, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_CODE39, -1, "1", 85, 0, 1, 1130 }, // 13 (Start) + 85*13 + 12 (Stop) == 1130
/* 3*/ { BARCODE_CODE39, -1, "1", 86, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_EXCODE39, -1, "1", 85, 0, 1, 1130 },
/* 5*/ { BARCODE_EXCODE39, -1, "1", 86, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_EXCODE39, -1, "a", 42, 0, 1, 1117 }, // Takes 2 encoding chars per char
/* 7*/ { BARCODE_EXCODE39, -1, "a", 43, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_EXCODE39, -1, "a", 85, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { BARCODE_LOGMARS, -1, "1", 30, 0, 1, 511 }, // 16 (Start) + 30*16 + 15 (Stop) == 511
/* 10*/ { BARCODE_LOGMARS, -1, "1", 31, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { BARCODE_CODE93, -1, "1", 107, 0, 1, 1000 }, // 9 (Start) + 107*9 + 2*9 (Checks) + 10 (Stop) == 1000
/* 12*/ { BARCODE_CODE93, -1, "1", 108, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { BARCODE_CODE93, -1, "a", 53, 0, 1, 991 }, // Takes 2 encoding chars per char
/* 14*/ { BARCODE_CODE93, -1, "a", 54, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { BARCODE_CODE93, -1, "a", 107, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_PZN, -1, "1", 7, 0, 1, 142 },
/* 17*/ { BARCODE_PZN, -1, "1", 8, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { BARCODE_VIN, -1, "1", 17, 0, 1, 246 },
/* 19*/ { BARCODE_VIN, -1, "1", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { BARCODE_VIN, -1, "1", 16, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 21*/ { BARCODE_HIBC_39, -1, "1", 66, 0, 1, 1119 }, // 68 - 2 ('+' and check digit)
/* 22*/ { BARCODE_HIBC_39, -1, "1", 67, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int length;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, "123-4552" }, // 2 checksums
/* 1*/ { BARCODE_CODE11, 1, "123-45", -1, "123-455" }, // 1 checksum
/* 2*/ { BARCODE_CODE11, 2, "123-45", -1, "123-45" }, // No checksums
/* 3*/ { BARCODE_CODE39, -1, "ABC1234", -1, "*ABC1234*" },
/* 4*/ { BARCODE_CODE39, -1, "abc1234", -1, "*ABC1234*" }, // Converts to upper
/* 5*/ { BARCODE_CODE39, -1, "123456789", -1, "*123456789*" },
/* 6*/ { BARCODE_CODE39, 1, "123456789", -1, "*1234567892*" }, // With checksum
/* 7*/ { BARCODE_EXCODE39, -1, "ABC1234", -1, "ABC1234" },
/* 8*/ { BARCODE_EXCODE39, -1, "abc1234", -1, "abc1234" },
/* 9*/ { BARCODE_EXCODE39, 1, "abc1234", -1, "abc1234" }, // With checksum (not displayed)
/* 10*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z\033\037!+/\\@A~", 16, "a% \001$\177z\033\037!+/\\@A~" }, // NUL replaced with space
/* 11*/ { BARCODE_LOGMARS, -1, "ABC1234", -1, "ABC1234" },
/* 12*/ { BARCODE_LOGMARS, -1, "abc1234", -1, "ABC1234" }, // Converts to upper
/* 13*/ { BARCODE_LOGMARS, 1, "abc1234", -1, "ABC12340" }, // With checksum
/* 14*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, "12345/ABCDET" }, // With checksum
/* 15*/ { BARCODE_CODE93, -1, "ABC1234", -1, "ABC1234S5" }, // 2 checksums added (note check digits not shown by bwipp or tec-it)
/* 16*/ { BARCODE_CODE93, -1, "abc1234", -1, "abc1234ZG" },
/* 17*/ { BARCODE_CODE93, -1, "A\001a\000b\177d\037e", 9, "A\001a b\177d\037e1R" }, // NUL replaced with space
/* 18*/ { BARCODE_PZN, -1, "12345", -1, "PZN -00123458" }, // Pads with zeroes if length < 7
/* 19*/ { BARCODE_PZN, -1, "123456", -1, "PZN -01234562" },
/* 20*/ { BARCODE_PZN, -1, "1234567", -1, "PZN -12345678" },
/* 21*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, "1FTCR10UXTPA78180" },
/* 22*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, "2FTPX28L0XCA15511" }, // Include Import char - no change
/* 23*/ { BARCODE_HIBC_39, -1, "ABC1234", -1, "*+ABC1234+*" },
/* 24*/ { BARCODE_HIBC_39, -1, "abc1234", -1, "*+ABC1234+*" }, // Converts to upper
/* 25*/ { BARCODE_HIBC_39, -1, "123456789", -1, "*+1234567890*" },
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "-", -1, 0, 1, 37 },
/* 1*/ { BARCODE_CODE11, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_CODE39, -1, "a", -1, 0, 1, 38 }, // Converts to upper
/* 3*/ { BARCODE_CODE39, -1, ",", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_CODE39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 5*/ { BARCODE_EXCODE39, -1, "A", -1, 0, 1, 38 },
/* 6*/ { BARCODE_EXCODE39, -1, "a", -1, 0, 1, 51 },
/* 7*/ { BARCODE_EXCODE39, -1, ",", -1, 0, 1, 51 },
/* 8*/ { BARCODE_EXCODE39, -1, "\000", 1, 0, 1, 51 },
/* 9*/ { BARCODE_EXCODE39, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 10*/ { BARCODE_LOGMARS, -1, "A", -1, 0, 1, 47 },
/* 11*/ { BARCODE_LOGMARS, -1, "a", -1, 0, 1, 47 },
/* 12*/ { BARCODE_LOGMARS, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 13*/ { BARCODE_LOGMARS, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 14*/ { BARCODE_CODE93, -1, "A", -1, 0, 1, 46 },
/* 15*/ { BARCODE_CODE93, -1, "a", -1, 0, 1, 55 },
/* 16*/ { BARCODE_CODE93, -1, ",", -1, 0, 1, 55 },
/* 17*/ { BARCODE_CODE93, -1, "\000", 1, 0, 1, 55 },
/* 18*/ { BARCODE_CODE93, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 19*/ { BARCODE_PZN, -1, "1", -1, 0, 1, 142 },
/* 20*/ { BARCODE_PZN, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 21*/ { BARCODE_PZN, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // Check digit == 10 so can't be used
/* 22*/ { BARCODE_VIN, -1, "5GZCZ43D13S812715", -1, 0, 1, 246 },
/* 23*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // North American with invalid check character
/* 24*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246 }, // Not North American so no check
/* 25*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, // Converts to upper
/* 26*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 27*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, 0, 1, 78, "2 check digits (52); verified manually against tec-it",
"101100101101011010010110110010101011010101101101101101011011010100101101011001"
},
/* 1*/ { BARCODE_CODE11, 1, "123-455", -1, 0, 1, 78, "1 check digit (2); verified manually against tec-it",
"101100101101011010010110110010101011010101101101101101011011010100101101011001"
},
/* 2*/ { BARCODE_CODE11, 2, "123-4552", -1, 0, 1, 78, "0 check digits; verified manually against bwipp and tec-it",
"101100101101011010010110110010101011010101101101101101011011010100101101011001"
},
/* 3*/ { BARCODE_CODE11, 1, "123-45", -1, 0, 1, 70, "1 check digit; verified manually against tec-it",
"1011001011010110100101101100101010110101011011011011010110110101011001"
},
/* 4*/ { BARCODE_CODE11, 2, "123-45", -1, 0, 1, 62, "0 check digits; verified manually against bwipp and tec-it",
"10110010110101101001011011001010101101010110110110110101011001"
},
/* 5*/ { BARCODE_CODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1",
"100101101101011010010101101101010010110100101101101"
},
/* 6*/ { BARCODE_CODE39, 1, "1A", -1, 0, 1, 64, "With checksum",
"1001011011010110100101011011010100101101011010010110100101101101"
},
/* 7*/ { BARCODE_CODE39, -1, "+A/E%U$A/D%T+Z", -1, 0, 1, 207, "Same as BARCODE_EXCODE39 'a%\000\001$\177z' below",
"100101101101010010100100101101010010110100100101001011010110010101010010010010110010101011010010010010101101010010110100100101001010101100101101010010010010101011011001010010100100101001101101010100101101101"
},
/* 8*/ { BARCODE_EXCODE39, -1, "1A", -1, 0, 1, 51, "ISO/IEC 16388:2007 Figure 1",
"100101101101011010010101101101010010110100101101101"
},
/* 9*/ { BARCODE_EXCODE39, 1, "1A", -1, 0, 1, 64, "With checksum",
"1001011011010110100101011011010100101101011010010110100101101101"
},
/* 10*/ { BARCODE_EXCODE39, -1, "a%\000\001$\177z", 7, 0, 1, 207, "Verified manually against bwipp and tec-it",
"100101101101010010100100101101010010110100100101001011010110010101010010010010110010101011010010010010101101010010110100100101001010101100101101010010010010101011011001010010100100101001101101010100101101101"
},
/* 11*/ { BARCODE_EXCODE39, -1, "\033\037!+/\\@A~", -1, 0, 1, 246, "Verified manually against bwipp and tec-it",
"100101101101010100100100101101010010110101001001001011010110010101001001010010110101001011010010010100101101010100110100100101001011010110100101010010010010101101010011010100100100101001101010110110101001011010100100100101011010110010100101101101"
},
/* 12*/ { BARCODE_LOGMARS, -1, "1A", -1, 0, 1, 63, "Verified manually against tec-it",
"100010111011101011101000101011101110101000101110100010111011101"
},
/* 13*/ { BARCODE_LOGMARS, 1, "1A", -1, 0, 1, 79, "With checksum; verified manually against tec-it",
"1000101110111010111010001010111011101010001011101011101000101110100010111011101"
},
/* 14*/ { BARCODE_LOGMARS, -1, "ABC", -1, 0, 1, 79, "MIL-STD-1189 Rev. B Figure 1",
"1000101110111010111010100010111010111010001011101110111010001010100010111011101"
},
/* 15*/ { BARCODE_LOGMARS, -1, "SAMPLE 1", -1, 0, 1, 159, "MIL-STD-1189 Rev. B Figure 2 top",
"100010111011101010111010111000101110101000101110111011101010001010111011101000101011101010001110111010111000101010001110101110101110100010101110100010111011101"
},
/* 16*/ { BARCODE_LOGMARS, 1, "12345/ABCDE", -1, 0, 1, 223, "MIL-STD-1189 Rev. B Section 6.2.1 check character example; verified manually against tec-it",
"1000101110111010111010001010111010111000101011101110111000101010101000111010111011101000111010101000100010100010111010100010111010111010001011101110111010001010101011100010111011101011100010101010111011100010100010111011101"
},
/* 17*/ { BARCODE_CODE93, -1, "1A", -1, 0, 1, 55, "Verified manually against bwipp (includecheck) and tec-it",
"1010111101010010001101010001101000101001110101010111101"
},
/* 18*/ { BARCODE_CODE93, -1, "TEST93", -1, 0, 1, 91, "Verified manually against bwipp (includecheck) and tec-it",
"1010111101101001101100100101101011001101001101000010101010000101011101101001000101010111101"
},
/* 19*/ { BARCODE_CODE93, -1, "\000a\177", 3, 0, 1, 91, "Verified manually against bwipp (code93ext, includecheck) and tec-it",
"1010111101110110101100101101001100101101010001110110101101001101011011101010010001010111101"
},
/* 20*/ { BARCODE_PZN, -1, "1234567", -1, 0, 1, 142, "Example from IFA Info Code 39 EN V2.1; verified manually against bwipp (pzn8) and tec-it",
"1001011011010100101011011011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010100101101101"
},
/* 21*/ { BARCODE_PZN, -1, "2758089", -1, 0, 1, 142, "Example from IFA Info Check Digit Calculations EN 15 July 2019; verified manually against bwipp (pzn8) and tec-it",
"1001011011010100101011011010110010101101010010110110110100110101011010010110101010011011010110100101101010110010110101011001011010100101101101"
},
/* 22*/ { BARCODE_VIN, -1, "1FTCR10UXTPA78180", -1, 0, 1, 246, "https://www.vinquery.com/img/vinbarcode/vinbarcode4.jpg",
"100101101101011010010101101011011001010101011011001011011010010101101010110010110100101011010100110110101100101010110100101101011010101101100101011011010010110101001011010100101101101101001011010110100101011011010010110101010011011010100101101101"
},
/* 23*/ { BARCODE_VIN, 1, "2FTPX28L0XCA15511", -1, 0, 1, 259, "With Import 'I' prefix; https://www.vinquery.com/img/vinbarcode/vinbarcode1.jpg",
"1001011011010101101001101010110010101101011011001010101011011001010110110100101001011010110101100101011011010010110101011010100110101001101101010010110101101101101001010110101001011011010010101101101001101010110100110101011010010101101101001010110100101101101"
},
/* 24*/ { BARCODE_HIBC_39, -1, "A123BJC5D6E71", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 2, same",
"1000101110111010100010100010001011101010001011101110100010101110101110001010111011101110001010101011101000101110101011100011101011101110100010101110100011101010101011100010111010111000111010101110101110001010101000101110111011101000101011101010100011101110100010111011101"
},
/* 25*/ { BARCODE_HIBC_39, -1, "$$52001510X3G", -1, 0, 1, 271, "ANSI/HIBC 2.6 - 2016 Figure 6, same",
"1000101110111010100010100010001010001000100010101000100010001010111010001110101010111000101011101010001110111010101000111011101011101000101011101110100011101010111010001010111010100011101110101000101110101110111011100010101010101000111011101010111000101110100010111011101"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

View File

@ -31,6 +31,215 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int option_2;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { -1, "1", 2955, 0, 148, 134 },
/* 1*/ { -1, "1", 2956, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, "A", 2217, 0, 148, 134 },
/* 3*/ { -1, "A", 2218, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { -1, "\001", 1480, 0, 148, 134 },
/* 5*/ { -1, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { 1, "1", 12, 0, 16, 18 },
/* 7*/ { 1, "1", 13, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { 2, "1", 33, 0, 22, 22 },
/* 9*/ { 2, "1", 34, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { 3, "1", 75, 0, 28, 32 },
/* 11*/ { 3, "1", 76, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { 4, "1", 177, 0, 40, 42 },
/* 13*/ { 4, "1", 178, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { 5, "1", 360, 0, 52, 54 },
/* 15*/ { 5, "1", 361, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { 6, "1", 732, 0, 70, 76 },
/* 17*/ { 6, "1", 733, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { 7, "1", 1452, 0, 104, 98 },
/* 19*/ { 7, "1", 1453, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { 8, "1", 2955, 0, 148, 134 },
/* 21*/ { 8, "1", 2956, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 22*/ { 9, "1", 18, 0, 8, 31 },
/* 23*/ { 9, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { 10, "1", 69, 0, 16, 49 },
/* 25*/ { 10, "1", 70, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 26*/ { 10, "A", 54, 0, 16, 49 },
/* 27*/ { 10, "A", 55, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 28*/ { 10, "\001", 38, 0, 16, 49 },
/* 29*/ { 10, "\001", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
int option_2;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { -1, -1, "123456789012ABCDEFGHI", -1, 0, 22, 22 },
/* 1*/ { -1, -1, "123456789012ABCDEFGHIJ", -1, 0, 22, 22 },
/* 2*/ { -1, -1, "1", -1, 0, 16, 18 },
/* 3*/ { -1, 0, "1", -1, 0, 16, 18 },
/* 4*/ { -1, 1, "1", -1, 0, 16, 18 },
/* 5*/ { -1, 11, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 6*/ { -1, 9, "123456789012345678", -1, 0, 8, 31 },
/* 7*/ { -1, 9, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 8*/ { -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789", -1, 0, 16, 49 },
/* 9*/ { -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49 },
/* 12*/ { -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { -1, 10, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int option_2;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { -1, "123456789012", -1, 0, 16, 18, "Verified manually against bwipp",
"100011101010111101"
"111010010010100000"
"110110100010001000"
"110010111000010001"
"100010100011010100"
"000010000000100000"
"111111111111111111"
"000000000000000000"
"011111111111111110"
"010000000000000010"
"011111111111111110"
"000100010100100101"
"011001001110101101"
"011010010010101111"
"010111110100100111"
"100010001101111100"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (generate) {
printf(" /*%3d*/ { %d, \"%s\", %d, %s, %d, %d, \"%s\",\n",
i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// #181 Nico Gunkel OSS-Fuzz
static void test_fuzz(int index, int debug) {
@ -72,6 +281,9 @@ static void test_fuzz(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
};

View File

@ -64,6 +64,8 @@ static void test_large(int index, int debug) {
/* 13*/ { BARCODE_EAN14, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1 },
/* 14*/ { BARCODE_NVE18, "12345678901234567", -1, 0, 156 },
/* 15*/ { BARCODE_NVE18, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1 },
/* 16*/ { BARCODE_HIBC_128, "1", 110, 0, 684 },
/* 17*/ { BARCODE_HIBC_128, "1", 111, ZINT_ERROR_TOO_LONG, -1 },
};
int data_size = ARRAY_SIZE(data);
@ -122,6 +124,8 @@ static void test_hrt(int index, int debug) {
/* 5*/ { BARCODE_CODE128, DATA_MODE, "abcd\351", -1, "abcd\351" },
/* 6*/ { BARCODE_CODE128B, UNICODE_MODE, "abcdé", -1, "abcdé" },
/* 7*/ { BARCODE_CODE128B, DATA_MODE, "abcd\351", -1, "abcd\351" },
/* 8*/ { BARCODE_HIBC_128, UNICODE_MODE, "1234567890", -1, "*+12345678900*" },
/* 9*/ { BARCODE_HIBC_128, UNICODE_MODE, "a99912345", -1, "*+A999123457*" }, // Converts to upper
// BARCODE_EAN128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c
};
int data_size = ARRAY_SIZE(data);
@ -171,6 +175,7 @@ static void test_reader_init(int index, int generate, int debug) {
/* 3*/ { BARCODE_EAN128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 25 30 106", "StartC FNC1 01 00 (5) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 25 80 106", "StartC FNC1 00 (8) 01 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 6*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartA FNC3 + A 8 (check) (Not sensible, use CODE128)" },
};
int data_size = ARRAY_SIZE(data);
@ -372,6 +377,57 @@ static void test_ean128_input(int index, int generate, int debug) {
testFinish();
}
static void test_hibc_input(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
int ret;
int expected_width;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, "", "" },
/* 1*/ { "A99912345/$$52001510X3", 0, 255, "(23) 104 11 33 99 99 91 23 45 100 15 4 4 99 52 0 15 10 100 56 19 19 53 106", "Check digit 3" },
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_HIBC_128, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < 5) {
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
@ -459,12 +515,27 @@ static void test_encode(int index, int generate, int debug) {
/* 22*/ { BARCODE_EAN128, GS1_MODE, "[8005]000365[10]123456", 0, 1, 156, "GS1 General Specifications Figure 7.8.5.2-2",
"110100111001111010111010100111100100010011001101100110010010011000100101100001111010111011001000100101100111001000101100011100010110101100001001100011101011"
},
/* 23*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, "Verified manually against bwipp and tec-it",
/* 23*/ { BARCODE_EAN128, GS1_MODE, "[403]27653113+99000900090010", 0, 1, 222, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
"110100111001111010111011000101000110001101101100101000011011101110110001001001011110111011001011100110001001001011101111010111011110110110011001100100100011011001100110010010001101100110011001000100110001000101100011101011"
},
/* 24*/ { BARCODE_EAN128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
"110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011"
},
/* 25*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, "Verified manually against bwipp and tec-it",
"11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011"
},
/* 24*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, "Verified manually against bwipp (sscc18) and tec-it",
/* 26*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, "Verified manually against bwipp (sscc18) and tec-it",
"110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011"
},
/* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)",
"1101001000011000100100111010011001011101111011000110110110000101001011110111010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100111101010001100011101011"
},
/* 28*/ { BARCODE_HIBC_128, UNICODE_MODE, "A123BJC5D6E71", 0, 1, 200, "ANSI/HIBC 2.6 - 2016 Figure 1, same",
"11010010000110001001001010001100010011100110110011100101100101110010001011000101101110001000100011011011100100101100010001100111010010001101000111011011101001110011011010001000110001101101100011101011"
},
/* 29*/ { BARCODE_HIBC_128, UNICODE_MODE, "$$52001510X3G", 0, 1, 178, "ANSI/HIBC 2.6 - 2016 Figure 5, same",
"1101001000011000100100100100011001001000110010111011110110111000101101100110010111001100110010001001011110111011100010110110010111001101000100010110001000100011110101100011101011"
},
};
int data_size = sizeof(data) / sizeof(struct item);
@ -515,6 +586,7 @@ int main(int argc, char *argv[]) {
{ "test_reader_init", test_reader_init, 1, 1, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_ean128_input", test_ean128_input, 1, 1, 1 },
{ "test_hibc_input", test_hibc_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};

View File

@ -31,6 +31,60 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, "1", 3116, 0, 144, 144 },
/* 1*/ { BARCODE_DATAMATRIX, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_DATAMATRIX, "A", 2335, 0, 144, 144 },
/* 3*/ { BARCODE_DATAMATRIX, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_DATAMATRIX, "\200", 1555, 0, 144, 144 },
/* 5*/ { BARCODE_DATAMATRIX, "\200", 1556, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_HIBC_DM, "1", 110, 0, 32, 32 },
/* 7*/ { BARCODE_HIBC_DM, "1", 111, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[3118];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// Note need ZINT_SANITIZE set for these
static void test_buffer(int index, int debug) {
@ -82,6 +136,8 @@ static void test_encode(int index, int generate, int debug) {
int ret;
struct item {
int symbology;
int input_mode;
unsigned char *data;
int ret;
@ -91,7 +147,7 @@ static void test_encode(int index, int generate, int debug) {
char *expected;
};
struct item data[] = {
/* 0*/ { "1234abcd", 0, 14, 14, "",
/* 0*/ { BARCODE_DATAMATRIX, -1, "1234abcd", 0, 14, 14, "",
"10101010101010"
"11001010001111"
"11000101100100"
@ -106,8 +162,8 @@ static void test_encode(int index, int generate, int debug) {
"11010010100101"
"10011111000100"
"11111111111111"
},
/* 1*/ { "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, "ISO 16022:2006 Figure 1",
},
/* 1*/ { BARCODE_DATAMATRIX, -1, "A1B2C3D4E5F6G7H8I9J0K1L2", 0, 18, 18, "ISO 16022:2006 Figure 1",
"101010101010101010"
"101000101010001111"
"101100000111000010"
@ -126,8 +182,8 @@ static void test_encode(int index, int generate, int debug) {
"100010011001011011"
"100011000000100100"
"111111111111111111"
},
/* 2*/ { "123456", 0, 10, 10, "ISO 16022:2006 Figure O.2",
},
/* 2*/ { BARCODE_DATAMATRIX, -1, "123456", 0, 10, 10, "ISO 16022:2006 Figure O.2",
"1010101010"
"1100101101"
"1100000100"
@ -138,8 +194,8 @@ static void test_encode(int index, int generate, int debug) {
"1111011001"
"1001110100"
"1111111111"
},
/* 3*/ { "30Q324343430794<OQQ", 0, 16, 16, "ISO 16022:2006 Figure R.1",
},
/* 3*/ { BARCODE_DATAMATRIX, -1, "30Q324343430794<OQQ", 0, 16, 16, "ISO 16022:2006 Figure R.1",
"1010101010101010"
"1010101010000001"
"1010101011101100"
@ -156,9 +212,163 @@ static void test_encode(int index, int generate, int debug) {
"1110010111100101"
"1110010010100010"
"1111111111111111"
},
},
/* 4*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]09501101530003[17]150119[10]AB-123", 0, 20, 20, "GS1 General Specfications 20.0 Figure 2.6.14-3",
"10101010101010101010"
"11001111010100000111"
"10001010001001010100"
"10110011010100010001"
"11101010000001101010"
"10000100111011010111"
"10011010101101010110"
"11010001001110101001"
"11101000110100101100"
"11001111010111001101"
"10001010000001100000"
"11010000100010111011"
"10110010011000001000"
"10011010000011010011"
"11111010101110100110"
"11010010111011100001"
"11010100101100111110"
"11000001110010010101"
"10011011100101011010"
"11111111111111111111"
},
/* 5*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]04012345678901[21]ABCDEFG123456789", 0, 20, 20, "GS1 General Specfications 20.0 Figure 2.6.14-4",
"10101010101010101010"
"11011000001101000111"
"10001001100001110100"
"10110110110000010001"
"11100010000111110110"
"10101010110011101101"
"11111000100000100010"
"10010010001011110001"
"10101010110011010110"
"11011110011010001111"
"10001010011101010010"
"10111111011110110011"
"11110100101101011000"
"11010111011100100111"
"10000000011001100000"
"11101111110100001011"
"11010001001000101010"
"11010011101000100101"
"10001000100001111010"
"11111111111111111111"
},
/* 6*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]04012345678901[17]170101[10]ABC123", 0, 20, 20, "GS1 General Specfications 20.0 Figure 4.15-1",
"10101010101010101010"
"11011000010100000111"
"10001001100001010100"
"10110111001100000001"
"11100010000101101110"
"10101100110001010101"
"11111010101000100110"
"10010011001000100011"
"10101000110010111010"
"11001111001010101111"
"10001010000111000010"
"10110000010101000011"
"11110010000001011000"
"11011000000110101111"
"11111010111011110110"
"11001001001110101111"
"11011010000001110010"
"11010111010111101101"
"10001000000101111010"
"11111111111111111111"
},
/* 7*/ { BARCODE_DATAMATRIX, GS1_MODE, "[01]09504000059101[21]12345678p901[10]1234567p[17]141120[8200]http://www.gs1.org/demo/", 0, 32, 32, "GS1 General Specfications 20.0 Figure 4.15.1-2 **NOT SMAE** TODO: investigate",
"10101010101010101010101010101010"
"11001111010000111101100000101001"
"10001010011111001011011001000010"
"10111011001001111101111101000101"
"11100101000010001000011011011110"
"10000101001101111010111000100101"
"10010001110100101000000010011110"
"10010110101101011000101100101111"
"11101010000010001100011100110100"
"11011100110110111101010000001001"
"10001010000101001100000111011010"
"10110011010101111000011001111001"
"11101100100110101110010100010110"
"11100100000001111000101100010101"
"10100010111011101100011101011010"
"11111111111111111111111111111111"
"10101010101010101010101010101010"
"11111011100111111011101011111111"
"11010100001100001001011001001010"
"10100011010010011101010101001101"
"11101011010000101011001110001110"
"10010000011001111110010000110111"
"11000101110110101010001111101000"
"10000010110111111010001011110011"
"10110011100010101010001011101000"
"10111010000000111100111100110001"
"10010000110001101101001110110110"
"11101001001110011001101111101001"
"10000000111100001100000010010000"
"11001101001100011110110001010101"
"10110100011001101010010100011000"
"11111111111111111111111111111111"
},
/* 8*/ { BARCODE_HIBC_DM, -1, "A123BJC5D6E71", 0, 16, 16, "**NOT SAME** ANSI/HIBC 2.6 - 2016 Figure 3 TODO: investigate",
"1010101010101010"
"1110000011011011"
"1100001110001000"
"1110101011011111"
"1100110100001000"
"1011000001001001"
"1100010011110100"
"1000101001010101"
"1010110011110000"
"1011000001001111"
"1000010001001110"
"1001111110001111"
"1000110101010010"
"1101101110100101"
"1100101101000010"
"1111111111111111"
},
/* 9*/ { BARCODE_HIBC_DM, -1, "A123BJC5D6E71/$$52001510X3", 0, 20, 20, "**NOT SAME** ANSI/HIBC 2.6 - 2016 Section 4.3.3 TODO: investigate",
"10101010101010101010"
"11100000100101100001"
"11000011111010101100"
"11101011100011000101"
"11001100011011000100"
"10110010010000101011"
"11000000100101100010"
"10000110010100000101"
"10111010001100001110"
"11111100101000000011"
"11110110001001111110"
"11100111110010000011"
"11000010001110101000"
"10110110001001010001"
"11100011101111010110"
"10000010110000110001"
"10000100001100100110"
"10111011000001111101"
"10110110110000011010"
"11111111111111111111"
},
/* 10*/ { BARCODE_HIBC_DM, -1, "H123ABC01234567890", 0, 12, 26, "ANSI/HIBC 2.6 - 2016 Figure C2, same",
"10101010101010101010101010"
"10111011011011110101001101"
"10010110000001001100110100"
"10010001010100001011110001"
"11010101011010110100111100"
"10000101110000001110001101"
"11011011110011001011100000"
"10010001101011100010001001"
"10000001101101100110101010"
"11001111011110011111010001"
"10010010001100110000011010"
"11111111111111111111111111"
},
};
int data_size = sizeof(data) / sizeof(struct item);
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
@ -167,18 +377,17 @@ static void test_encode(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = BARCODE_DATAMATRIX;
symbol->debug |= debug;
int length = strlen(data[i].data);
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n", i, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
@ -201,6 +410,7 @@ static void test_encode(int index, int generate, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_buffer", test_buffer, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};

View File

@ -137,7 +137,7 @@ static void test_reduced_charset_input(int index, int debug) {
/* 2*/ { BARCODE_CODE39, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "ASCII subset only" },
/* 3*/ { BARCODE_EXCODE39, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "ASCII only" },
/* 4*/ { BARCODE_EANX, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "Numbers only" },
/* 5*/ { BARCODE_CODABAR, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "ASCII subset only" },
/* 5*/ { BARCODE_CODABAR, UNICODE_MODE, 0, "AéB", ZINT_ERROR_INVALID_DATA, -1, "ASCII subset only" },
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, 0, "é", 0, 0, "" },
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" },
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" },

View File

@ -31,6 +31,57 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "1", 2751, 0, 162, 162 },
/* 1*/ { "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 1*/ { "A", 1836, 0, 162, 162 },
/* 2*/ { "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 3*/ { "\200", 1143, 0, 162, 162 },
/* 4*/ { "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[2753];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_GRIDMATRIX, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_options(int index, int debug) {
testStart("");
@ -375,6 +426,7 @@ static void test_encode(int index, int generate, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_options", test_options, 1, 0, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },

View File

@ -31,6 +31,57 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "1", 7827, 0, 189, 189 },
/* 1*/ { "1", 7828, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 1*/ { "A", 4349, 0, 189, 189 }, // TODO: should be 4350 according to spec, investigate
/* 2*/ { "A", 4351, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 3*/ { "\200", 3260, 0, 189, 189 }, // TODO: should be 3261 according to spec, investigate
/* 4*/ { "\200", 3262, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[7829];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_HANXIN, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_options(int index, int debug) {
testStart("");
@ -419,6 +470,7 @@ static void test_encode(int index, int generate, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_options", test_options, 1, 0, 1 },
{ "test_input", test_input, 1, 1, 1 },
{ "test_encode", test_encode, 1, 1, 1 },

View File

@ -34,7 +34,7 @@
#include "testcommon.h"
#define TEST_IMAIL_CSV_MAX 500
#define TEST_IMAIL_CSV_MAX 300
static void test_csv(int index, int debug) {
@ -124,10 +124,164 @@ static void test_csv(int index, int debug) {
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "53379777234994544928-51135759461", "" }, // None
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_ONECODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "53379777234994544928-51135759461", 0, 3, 129 },
/* 1*/ { "123456789012345678901234567890123", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { "12345678901234567890", 0, 3, 129 }, // Tracker only, no ZIP
/* 4*/ { "12355678901234567890", 0, 3, 129 }, // Tracker 4th char > 4
/* 5*/ { "1234567890123456789", ZINT_ERROR_INVALID_DATA, -1, -1 }, // Tracker 20 chars
/* 6*/ { "12345678901234567890-1234", ZINT_ERROR_INVALID_DATA, -1, -1 }, // ZIP wrong len
/* 7*/ { "12345678901234567890-12345", 0, 3, 129 },
/* 8*/ { "12345678901234567890-123456", ZINT_ERROR_INVALID_DATA, -1, -1 }, // ZIP wrong len
/* 9*/ { "12345678901234567890-12345678", ZINT_ERROR_INVALID_DATA, -1, -1 }, // ZIP wrong len
/* 10*/ { "12345678901234567890-123456789", 0, 3, 129 },
/* 11*/ { "12345678901234567890-1234567890", ZINT_ERROR_INVALID_DATA, -1, -1 }, // ZIP wrong len
/* 12*/ { "12345678901234567890-12345678901", 0, 3, 129 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_ONECODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { "01234567094987654321-01234567891", 0, 3, 129, "USPS-B-3200 Rev. H (2015) Figure 5",
"101000001010001000001000001010001010001000000000101010000000000000001010100010000000001010100000000000100010101010001000001010001"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"000010001010101000100010000000100000001010001010000000101000100000100010001000101010001010101010000000001010000000101000100000100"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_ONECODE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_csv", test_csv, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View File

@ -30,6 +30,61 @@
#include "testcommon.h"
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { "41038422416563762XY11 ", 0, 3, 155 },
/* 1*/ { "41038422416563762XY11 ", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "41038422416563762xy11 ", 0, 3, 155 }, // Case insensitive
/* 3*/ { "41038422416563762xy11 .", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { "0100000000000AA000AA0A", 0, 3, 131, }, // Length 22, Mailmark C (2 digit chain id)
/* 5*/ { "5100000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 1st char format 0-4 only
/* 6*/ { "0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 2nd char version id 1-4 only
/* 7*/ { "01F0000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 3rd char class 0-9A-E only
/* 8*/ { "0100A00000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 4-5th chars chain id 2 digits
/* 9*/ { "010000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 6-13th chars item id 8 digits
/* 10*/ { "010000000000 AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // Remaining chars post code, TODO: test various types
/* 11*/ { "01000000000000000AA000AA0A", 0, 3, 155, }, // Length 26, Mailmark L (6 digit chain id)
/* 12*/ { "010A0000000000000AA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // 4-9th chars chain id 6 digits
/* 13*/ { "010A000000000000AAA000AA0A", ZINT_ERROR_INVALID_DATA, -1, -1 }, // Post code
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_MAILMARK, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// Royal Mail Mailmark barcode L encoding and decoding (Sep 2015) RMMBLED
// https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-L-encoding-and-decoding-instructions-Sept-2015.pdf
static void test_encode_vector(int index, int debug) {
testStart("");
@ -49,8 +104,8 @@ static void test_encode_vector(int index, int debug) {
/* 1*/ { "0100000000009JA500AA0A", 0, 100, 30, 0, "TAFTTDADATTFDTFDFDFDTAATADADTTTATTFTDDDDTATDATDFTFFATAFFAFADAFFTDT" },
/* 2*/ { "1100000000000XY11 ", 0, 100, 30, 0, "TTDTTATTDTAATTDTAATTDTAATTDTTDDAATAADDATAATDDFAFTDDTAADDDTAAFDFAFF" },
/* 3*/ { "21B2254800659JW5O9QA6Y", 0, 100, 30, 0, "DAATATTTADTAATTFADDDDTTFTFDDDDFFDFDAFTADDTFFTDDATADTTFATTDAFDTFDDA" },
/* 4*/ { "11000000000000000XY11 ", 0, 100, 30, 0, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" },
/* 5*/ { "41038422416563762EF61AH8T", 0, 100, 30, 0, "DTTFATTDDTATTTATFTDFFFTFDFDAFTTTADTTFDTFDDDTDFDDFTFAADTFDTDTDTFAATAFDDTAATTDTT" },
/* 4*/ { "11000000000000000XY11 ", 0, 100, 30, 0, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" }, // Example from RMMBLED
/* 5*/ { "41038422416563762EF61AH8T", 0, 100, 30, 0, "DTTFATTDDTATTTATFTDFFFTFDFDAFTTTADTTFDTFDDDTDFDDFTFAADTFDTDTDTFAATAFDDTAATTDTT" }, // Example from RMMBLED
};
int data_size = sizeof(data) / sizeof(struct item);
@ -89,6 +144,7 @@ static void test_encode_vector(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode_vector", test_encode_vector, 1, 0, 1 },
};

View File

@ -31,6 +31,193 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int option_1;
unsigned char *pattern;
int length;
char* primary;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { -1, "1", 132, "", 0, 33, 30 }, // 138 according to ISO/IEC 16023:2000 TODO: investigate (see also test_fuzz)
/* 1*/ { -1, "1", 133, "", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, "A", 93, "", 0, 33, 30 },
/* 3*/ { -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { -1, "\001", 91, "", 0, 33, 30 },
/* 5*/ { -1, "\001", 92, "", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { -1, "\200", 91, "", 0, 33, 30 },
/* 7*/ { -1, "\200", 92, "", ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[256];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
strcpy(symbol->primary, data[i].primary);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int input_mode;
int option_1;
unsigned char *data;
char* primary;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { -1, -1, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "", 0, 33, 30, "ISO/IEC 16023:2000 Figure 2",
"011111010000001000001000100111"
"000100000001000000001010000000"
"001011001100100110110010010010"
"100000010001100010010000000000"
"001011000000101000001010110011"
"111010001000001011001000111100"
"100000000110000010010000000000"
"000010100010010010001001111100"
"111011100000001000000110000000"
"000000011011000000010100011000"
"101111000001010110001100000011"
"001110001010000000111010001110"
"000111100000000000100001011000"
"100010000000000000000111001000"
"100000001000000000011000001000"
"000010111000000000000010000010"
"111000001000000000001000001101"
"011000000000000000001000100100"
"000000101100000000001001010001"
"101010001000000000100111001100"
"001000011000000000011100001010"
"000000000000000000110000100000"
"101011001010100001000101010001"
"100011110010101001101010001010"
"011010000000000101011010011111"
"000001110011111111111100010100"
"001110100111000101011000011100"
"110111011100100001101001010110"
"000001011011101010010111001100"
"111000110111100010001111011110"
"101111010111111000010110111001"
"001001101111101101101010011100"
"001011000000111101100100001000"
},
/* 1*/ { -1, 4, "MaxiCode (19 chars)", "", 0, 33, 30, "ISO/IEC 16023:2000 Figure H1 **NOT SAME** TODO: investigate",
"001101011111011100000010101111"
"101100010001001100010000001100"
"101100001010001111001001111101"
"010101010101010101010101010100"
"000000000000000000000000000111"
"101010101010101010101010101000"
"010101010101010101010101010111"
"000000000000000000000000000010"
"101010101010101010101010101000"
"010101011111111100000001010100"
"000000000011110110001000000000"
"101010101110000000111010101000"
"010101100010000000001101010101"
"000000101000000000001000000000"
"101010000000000000011010101000"
"010101010000000000001101010100"
"000000001000000000001000000011"
"101010110000000000001010101010"
"010101101100000000010101010111"
"000000100000000000000000000000"
"101010010110000000000110101011"
"010101010110000000001001010100"
"000000000110001011000000000010"
"101010100110111001010010101000"
"010101010101010101010000101111"
"000000000000000000001100100000"
"101010101010101010100101000001"
"000011000111010110101100010000"
"111001111110111110011000111111"
"000001110010000010110001100100"
"000111000000001111011000010010"
"010110010110001110100000010100"
"010011110011000001010111100111"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, BARCODE_MAXICODE, data[i].input_mode, -1 /*eci*/, data[i].option_1, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
strcpy(symbol->primary, data[i].primary);
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);
if (generate) {
printf(" /*%3d*/ { %s, %d, \"%s\", \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].primary,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_best_supported_set(int index, int generate, int debug) {
testStart("");
@ -176,6 +363,8 @@ static void test_fuzz(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
{ "test_best_supported_set", test_best_supported_set, 1, 1, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
};

View File

@ -0,0 +1,308 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A1234567890123456789012345678901234567890123456789012345678B", 60, 0, 1, 602 },
/* 1*/ { BARCODE_CODABAR, -1, "A12345678901234567890123456789012345678901234567890123456789B", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_CODABAR, 1, "A1234567890123456789012345678901234567890123456789012345678B", 60, 0, 1, 612 },
/* 3*/ { BARCODE_CODABAR, 1, "A12345678901234567890123456789012345678901234567890123456789B", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_PHARMA, -1, "131070", 6, 0, 1, 78 },
/* 5*/ { BARCODE_PHARMA, -1, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_PHARMA_TWO, -1, "64570080", 8, 0, 2, 31 },
/* 7*/ { BARCODE_PHARMA_TWO, -1, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_CODE32, -1, "1", 8, 0, 1, 103 },
/* 9*/ { BARCODE_CODE32, -1, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[64];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A1234B", "A1234B" },
/* 1*/ { BARCODE_CODABAR, -1, "a1234c", "A1234C" }, // Converts to upper
/* 2*/ { BARCODE_CODABAR, 1, "A1234B", "A1234B" }, // Check not included
/* 3*/ { BARCODE_PHARMA, -1, "123456", "" }, // None
/* 4*/ { BARCODE_PHARMA_TWO, -1, "123456", "" }, // None
/* 5*/ { BARCODE_CODE32, -1, "123456", "A001234564" },
/* 6*/ { BARCODE_CODE32, -1, "12345678", "A123456788" },
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// 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 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A37859B", 0, 1, 72, "BS EN 798:1995 Figure 1",
"101100100101100101010100101101010011010101101010010110100101010010010110"
},
/* 1*/ { BARCODE_CODABAR, -1, "A0123456789-$:/.+D", 0, 1, 186, "Verified manually against bwipp and tec-it",
"101100100101010100110101011001010100101101100101010101101001011010100101001010110100101101010011010101101001010101001101010110010101101011011011011010110110110110101011011011010100110010"
},
/* 2*/ { BARCODE_CODABAR, 1, "A1B", 0, 1, 43, "Verified manually against bwipp and tect-it",
"1011001001010101100101101101101010010010110"
},
/* 3*/ { BARCODE_CODABAR, 1, "A+B", 0, 1, 43, "Verified manually against bwipp and tect-it",
"1011001001010110110110101010011010010010110"
},
/* 4*/ { BARCODE_CODABAR, 1, "B0123456789-$:/.+B", 0, 1, 196, "Verified manually against bwipp and tec-it",
"1001001011010101001101010110010101001011011001010101011010010110101001010010101101001011010100110101011010010101010011010101100101011010110110110110101101101101101010110110110100101011010010010110"
},
/* 5*/ { BARCODE_PHARMA, -1, "131070", 0, 1, 78, "Verified manually against bwipp and tec-it",
"111001110011100111001110011100111001110011100111001110011100111001110011100111"
},
/* 6*/ { BARCODE_PHARMA, -1, "123456", 0, 1, 58, "Verified manually against bwipp and tec-it",
"1110011100111001001001001110010010011100100100100100100111"
},
/* 7*/ { BARCODE_PHARMA_TWO, -1, "64570080", 0, 2, 31, "Verified manually against bwipp and tec-it",
"1010101010101010101010101010101"
"1010101010101010101010101010101"
},
/* 8*/ { BARCODE_PHARMA_TWO, -1, "29876543", 0, 2, 31, "Verified manually against bwipp and tec-it",
"0010100010001010001010001000101"
"1000101010100000100000101010000"
},
/* 9*/ { BARCODE_CODE32, -1, "34567890", 0, 1, 103, "Verified manually against bwipp and tec-it",
"1001011011010101101001011010110010110101011011010010101100101101011010010101101010101100110100101101101"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

View File

@ -0,0 +1,287 @@
/*
libzint - the open source barcode library
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "9", 55, 0, 1, 667 },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "9", 56, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "9", 18, 0, 1, 235 }, // 1 mod-10 check digit
/* 3*/ { BARCODE_MSI_PLESSEY, 1, "9", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_MSI_PLESSEY, 2, "9", 18, 0, 1, 247 }, // 2 mod-10 check digits
/* 5*/ { BARCODE_MSI_PLESSEY, 2, "9", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_MSI_PLESSEY, 3, "9", 55, 0, 1, 679 }, // 1 mod-11 check digit
/* 7*/ { BARCODE_MSI_PLESSEY, 3, "9", 56, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_MSI_PLESSEY, 4, "9", 18, 0, 1, 247 }, // 1 mod-11 and 1 mod-10 check digit
/* 9*/ { BARCODE_MSI_PLESSEY, 4, "9", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_PLESSEY, -1, "A", 65, 0, 1, 1107 },
/* 11*/ { BARCODE_PLESSEY, -1, "A", 66, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567", "1234567" },
/* 1*/ { BARCODE_MSI_PLESSEY, 0, "1234567", "1234567" },
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "1234567", "12345674" },
/* 3*/ { BARCODE_MSI_PLESSEY, 2, "1234567", "123456741" },
/* 4*/ { BARCODE_MSI_PLESSEY, 3, "1234567", "12345674" },
/* 5*/ { BARCODE_MSI_PLESSEY, 4, "1234567", "123456741" },
/* 6*/ { BARCODE_MSI_PLESSEY, 1, "123456", "1234566" },
/* 7*/ { BARCODE_MSI_PLESSEY, 2, "123456", "12345666" },
/* 8*/ { BARCODE_MSI_PLESSEY, 3, "123456", "1234560" },
/* 9*/ { BARCODE_MSI_PLESSEY, 4, "123456", "12345609" },
/* 10*/ { BARCODE_MSI_PLESSEY, 3, "2211", "221110" }, // Mod-11 check digit '10'
/* 11*/ { BARCODE_MSI_PLESSEY, 4, "2211", "2211100" },
/* 12*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", "0123456789ABCDEF" },
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1", 0, 1, 19 },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_PLESSEY, -1, "A", 0, 1, 83 },
/* 3*/ { BARCODE_PLESSEY, -1, "G", ZINT_ERROR_INVALID_DATA, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "Verified manually against bwipp and tec-it",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001"
},
/* 1*/ { BARCODE_MSI_PLESSEY, 1, "1234567890", 0, 1, 139, "Verified manually against bwipp and tec-it",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001"
},
/* 2*/ { BARCODE_MSI_PLESSEY, 2, "1234567890", 0, 1, 151, "Verified manually against bwipp and tec-it",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001001001101001"
},
/* 3*/ { BARCODE_MSI_PLESSEY, 3, "1234567890", 0, 1, 139, "Verified manually against bwipp",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001"
},
/* 4*/ { BARCODE_MSI_PLESSEY, 4, "1234567890", 0, 1, 151, "Verified manually against bwipp",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001001101101001001001101001"
},
/* 5*/ { BARCODE_MSI_PLESSEY, 3, "2211", 0, 1, 79, "Produces mod-11 '10' check digit; verified manually against bwipp (badmod11)",
"1101001001101001001001101001001001001101001001001101001001001101001001001001001"
},
/* 6*/ { BARCODE_MSI_PLESSEY, 4, "2211", 0, 1, 91, "Verified manually against bwipp (badmod11)",
"1101001001101001001001101001001001001101001001001101001001001101001001001001001001001001001"
},
/* 7*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", 0, 1, 323, "Verified manually against bwipp",
"11101110100011101000100010001000111010001000100010001110100010001110111010001000100010001110100011101000111010001000111011101000111011101110100010001000100011101110100010001110100011101000111011101110100011101000100011101110111010001110111010001110111011101110111011101110111010001000111010001000100010001110001000101110111"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}

View File

@ -29,8 +29,76 @@
*/
/* vim: set ts=4 sw=4 et : */
// USPS Publication 25 (July 2003) Designing Letter and Reply Mail https://web.archive.org/web/20050118015758/http://www.siemons.com/forms/pdf/designing_letter_reply_mail.pdf
// USPS DMM Domestic Mail Manual https://pe.usps.com/DMM300
// USPS Publication 197 (Sept 2004) Confirm User Guide https://web.archive.org/web/20060505214851/https://mailtracking.usps.com/mtr/resources/documents/Guide.pdf
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1", 90, 0, 1, 810 },
/* 1*/ { BARCODE_FLAT, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_POSTNET, "1", 11, 0, 2, 185 },
/* 3*/ { BARCODE_POSTNET, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_FIM, "D", 1, 0, 1, 17 },
/* 5*/ { BARCODE_FIM, "D", 2, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_RM4SCC, "1", 50, 0, 3, 411 },
/* 7*/ { BARCODE_RM4SCC, "1", 51, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_JAPANPOST, "1", 20, 0, 3, 133 },
/* 9*/ { BARCODE_JAPANPOST, "1", 21, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_KOREAPOST, "1", 6, 0, 1, 162 },
/* 11*/ { BARCODE_KOREAPOST, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_PLANET, "1", 13, 0, 2, 215 },
/* 13*/ { BARCODE_PLANET, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_KIX, "1", 18, 0, 3, 143 },
/* 15*/ { BARCODE_KIX, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_DAFT, "D", 50, 0, 3, 99 },
/* 17*/ { BARCODE_DAFT, "D", 51, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[4096];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_koreapost(int index, int debug) {
testStart("");
@ -132,11 +200,212 @@ static void test_japanpost(int index, int debug) {
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1234567890", 0, 1, 90 },
/* 1*/ { BARCODE_FLAT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_POSTNET, "12345", 0, 2, 95 },
/* 3*/ { BARCODE_POSTNET, "123457689", 0, 2, 155 },
/* 4*/ { BARCODE_POSTNET, "12345768901", 0, 2, 185 },
/* 5*/ { BARCODE_POSTNET, "1234", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_POSTNET, "123456", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 7*/ { BARCODE_POSTNET, "123456789012", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_POSTNET, "1234A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 9*/ { BARCODE_FIM, "a", 0, 1, 17 },
/* 10*/ { BARCODE_FIM, "b", 0, 1, 17 },
/* 11*/ { BARCODE_FIM, "c", 0, 1, 17 },
/* 12*/ { BARCODE_FIM, "d", 0, 1, 17 },
/* 13*/ { BARCODE_FIM, "ad", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_FIM, "e", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 15*/ { BARCODE_RM4SCC, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 3, 299 },
/* 16*/ { BARCODE_RM4SCC, "a", 0, 3, 19 }, // Converts to upper
/* 17*/ { BARCODE_RM4SCC, ",", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 18*/ { BARCODE_JAPANPOST, "1234567890-ABCDEFGH", 0, 3, 133 },
/* 19*/ { BARCODE_JAPANPOST, "a", 0, 3, 133 }, // Converts to upper
/* 20*/ { BARCODE_JAPANPOST, ",", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 21*/ { BARCODE_KOREAPOST, "123456", 0, 1, 167 },
/* 22*/ { BARCODE_KOREAPOST, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 23*/ { BARCODE_PLANET, "12345678901", 0, 2, 185 },
/* 24*/ { BARCODE_PLANET, "1234567890123", 0, 2, 215 },
/* 25*/ { BARCODE_PLANET, "1234567890", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 26*/ { BARCODE_PLANET, "123456789012", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 27*/ { BARCODE_PLANET, "12345678901234", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 28*/ { BARCODE_PLANET, "1234567890A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 29*/ { BARCODE_KIX, "0123456789ABCDEFGH", 0, 3, 143 },
/* 30*/ { BARCODE_KIX, "a", 0, 3, 7 }, // Converts to upper
/* 31*/ { BARCODE_KIX, ",", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 32*/ { BARCODE_DAFT, "DAFT", 0, 3, 7 },
/* 33*/ { BARCODE_DAFT, "a", 0, 3, 1 }, // Converts to upper
/* 34*/ { BARCODE_DAFT, "B", ZINT_ERROR_INVALID_DATA, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1304056", 0, 1, 63, "Verified manually against bwipp and tec-it",
"100000000001000000000000000000100000000000000000010000000001000"
},
/* 1*/ { BARCODE_POSTNET, "12345678901", 0, 2, 185, "USPS Publication 25 (2003) Exhibit 4-1",
"10000000000010010000000010000010000000010010000000010000000010000010000010000000010010000000010000000000010010000000010000010000010000000010010000000000000000000010010000010000000010010"
"10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
},
/* 2*/ { BARCODE_POSTNET, "555551237", 0, 2, 155, "Verified manually against bwipp and tec-it",
"10000010000010000000010000010000000010000010000000010000010000000010000010000000000000010010000000010000010000000010010000010000000000010000000010000010010"
"10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
},
/* 3*/ { BARCODE_FIM, "C", 0, 1, 17, "USPS DMM Exhibit 8.2.0 FIM C",
"10100010001000101"
},
/* 4*/ { BARCODE_RM4SCC, "BX11LT1A", 0, 3, 75, "Verified manually against bwipp and tec-it",
"100010001010100000000010100000101010000010100010000000101000100010100000101"
"101010101010101010101010101010101010101010101010101010101010101010101010101"
"001010000010000010001000100010001010000010101000000010001010001000000010101"
},
/* 5*/ { BARCODE_RM4SCC, "W1J0TR01", 0, 3, 75, "Verified manually against bwipp and tec-it",
"101010000000001010100000100000101010001000100010000000101000001010101000001"
"101010101010101010101010101010101010101010101010101010101010101010101010101"
"000010100000100010001000100000101010100000100000100000101000100010001010001"
},
/* 6*/ { BARCODE_JAPANPOST, "12345671-2-3", 0, 3, 133, "Verified manually against bwipp and tec-it",
"1000101000100010001010101000100010001010101000101000001000100010001000001010000010000010000010000010000010000010000010000010100010001"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"1010101000101000101000100010100010100010001010101000001000101000001000101000001000001000001000001000001000001000001000001000100010101"
},
/* 7*/ { BARCODE_KOREAPOST, "010230", 0, 1, 167, "Verified manually against tec-it",
"10001000100000000000100010000000000010001000100000001000000010001000100010001000100000000000100000000001000100010001000100010001000000000001000000010001000000010001000"
},
/* 8*/ { BARCODE_PLANET, "4012345235636", 0, 2, 215, "USPS Publication 197 (2004) Exhibit 5; verified manually against bwipp and tec-it",
"10010000010010000000000010010010010010010000000010010000010000010010000000010010000010010000010000010000010010010000010000010010000000010010000010000010010000000010010010010000000010010000000010010010000000010010010"
"10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
},
/* 9*/ { BARCODE_PLANET, "40123452356", 0, 2, 185, "Verified manually against bwipp and tec-it",
"10010000010010000000000010010010010010010000000010010000010000010010000000010010000010010000010000010000010010010000010000010010000000010010000010000010010000000010010010000010000010010"
"10010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010010"
},
/* 10*/ { BARCODE_KIX, "2500GG30250", 0, 3, 87, "PostNL Handleiding KIX code Section 2.1 Example 1",
"000010100000101000001010000010100010100000101000000010100000101000001010000010100000101"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"001010001010000000001010000010101000100010001000100000100000101000101000101000000000101"
},
/* 11*/ { BARCODE_KIX, "2130VA80430", 0, 3, 87, "PostNL Handleiding KIX code Section 2.1 Example 2",
"000010100000101000001010000010101010000000100010001000100000101000001010000010100000101"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"001010000010001010000010000010100010001010001000001010000000101010001000100000100000101"
},
/* 12*/ { BARCODE_KIX, "1231GF156X2", 0, 3, 87, "PostNL Handleiding KIX code Section 2.1 Example 3",
"000010100000101000001010000010100010100000101000000010100000101000100010101000000000101"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"001000100010100010000010001000101000100010000010001000101010000000001010100000100010100"
},
/* 13*/ { BARCODE_KIX, "1231FZ13Xhs", 0, 3, 87, "PostNL Handleiding KIX code Section 2.1 Example 4",
"000010100000101000001010000010100010100010100000000010100000101010100000001010001000100"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"001000100010100010000010001000101000001010100000001000101000001010000010101000001000100"
},
/* 14*/ { BARCODE_DAFT, "DAFTTFADFATDTATFT", 0, 3, 33, "Verified manually against bwipp and tec-it",
"001010000010100010100000001000100"
"101010101010101010101010101010101"
"100010000010001010000010000000100"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_koreapost", test_koreapost, 1, 0, 1 },
{ "test_japanpost", test_japanpost, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View File

@ -169,7 +169,7 @@ static void test_print(int index, int generate, int debug) {
assert_zero(ret, "i:%d %s testUtilCmpBins(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, expected_file, ret);
}
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
if (index == -1) assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
}
ZBarcode_Delete(symbol);

View File

@ -470,7 +470,34 @@ static void test_qr_encode(int index, int generate, int debug) {
"100000100001110111000"
"111111101001011100101"
},
/* 1*/ { UNICODE_MODE, "12345678901234567890123456789012345678901", -1, -1, 0, 21, 21, "Max capacity ECC 1 Version 1 41 numbers",
/* 1*/ { GS1_MODE, "[01]09501101530003[8200]http://example.com", -1, -1, 0, 25, 25, "GS1 General Specifications 20.0 Figure 5.1-7 **NOT SAME** TODO: investigate",
"1111111001101101001111111"
"1000001000110001101000001"
"1011101011101000101011101"
"1011101001100000101011101"
"1011101000110111001011101"
"1000001001011001101000001"
"1111111010101010101111111"
"0000000011100011000000000"
"1110111110110000011000100"
"0100110000101101111100111"
"0111101101000111001011110"
"0010110100000111010101111"
"1110001000010010100010100"
"0010110001010001000110010"
"1001011110000111001100001"
"0100110011000110001010110"
"1011001000000100111110001"
"0000000010001001100011000"
"1111111010000111101010011"
"1000001010110011100010010"
"1011101011011011111110001"
"1011101000100100100000000"
"1011101010100110101110101"
"1000001010100111110101000"
"1111111011101100010010111"
},
/* 2*/ { UNICODE_MODE, "12345678901234567890123456789012345678901", -1, -1, 0, 21, 21, "Max capacity ECC 1 Version 1 41 numbers",
"111111100011001111111"
"100000100001001000001"
"101110101110001011101"
@ -493,7 +520,7 @@ static void test_qr_encode(int index, int generate, int debug) {
"100000101010111011000"
"111111101000100010101"
},
/* 2*/ { UNICODE_MODE, "12345678901234567890123456789012345678901", 2, -1, 0, 25, 25, "ECC 2 auto-sets version 2",
/* 3*/ { UNICODE_MODE, "12345678901234567890123456789012345678901", 2, -1, 0, 25, 25, "ECC 2 auto-sets version 2",
"1111111010111111001111111"
"1000001001001110001000001"
"1011101001000001101011101"
@ -520,7 +547,7 @@ static void test_qr_encode(int index, int generate, int debug) {
"1000001001110101001011000"
"1111111011101101111101001"
},
/* 3*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 10, 0, 57, 57, "Max capacity ECC 4 Version 10 74 kanji",
/* 4*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 10, 0, 57, 57, "Max capacity ECC 4 Version 10 74 kanji",
"111111101100111011000010011000100111001001000011001111111"
"100000101111111001101100110100110101110011011101001000001"
"101110101011001110000011101100101110111011110011001011101"
@ -579,7 +606,7 @@ static void test_qr_encode(int index, int generate, int debug) {
"100000100010000001101111010001101010110110010001011111000"
"111111100000011111000100011011010011011001011011001011001"
},
/* 4*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 27, 0, 125, 125, "Max capacity ECC 4 Version 27 385 kanji",
/* 5*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 27, 0, 125, 125, "Max capacity ECC 4 Version 27 385 kanji",
"11111110101001001100111100100011110001010011110000001100010110100011101010111000011101101001011111001111101101101001101111111"
"10000010110001101110011001101111000101001011011001100110101000101010011110000000101000100101101110110000011110100110001000001"
"10111010100000000100000101000101111001011001010100100100100000000101100011010001100111101010010101101101101101101101001011101"
@ -706,7 +733,7 @@ static void test_qr_encode(int index, int generate, int debug) {
"10000010010111001111010001100001010001010110110001100000111101011100000010010111101001001100101101111011011001000001101001110"
"11111110000000010001110110000001010111011111000000111111010101110100101000110111000101101011001100000101101101101001100111111"
},
/* 5*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 40, 0, 177, 177, "Max capacity ECC 4 Version 40 784 kanji",
/* 6*/ { UNICODE_MODE, "点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点点", 4, 40, 0, 177, 177, "Max capacity ECC 4 Version 40 784 kanji",
"111111101010001111111101101110111010110111001110101000010001011011011101001110110011111011010000010101001010011110010000010110111111001001011111101000010010111111001010001111111"
"100000101010110001001000101111011001001100100110110000000111110101111011110001101110000111000100101111010011001111100111111001001011011011110011011111111001000010010010101000001"
"101110101001001101111001110010010100000000111001001011111000001001111111101010000111011010011010010001111010111001100011000011110100101110001010110001011110011011011010001011101"

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -126,90 +126,109 @@ static void test_buffer(int index, int generate, int debug) {
/* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310, 118 },
/* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 230, 118 },
/* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 230, 118 },
/* 10*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 },
/* 11*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 },
/* 12*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 },
/* 13*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 },
/* 14*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 },
/* 15*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 },
/* 16*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 },
/* 17*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 },
/* 18*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 },
/* 19*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 },
/* 20*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 },
/* 21*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 },
/* 22*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 },
/* 23*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230, 118 },
/* 24*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230, 118 },
/* 25*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142, 118 },
/* 26*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142, 118 },
/* 27*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 28*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 },
/* 29*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 },
/* 30*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 207, 414, 118 },
/* 31*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 },
/* 32*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 },
/* 33*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 },
/* 34*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 },
/* 35*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 },
/* 36*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 300, 300 },
/* 37*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 38*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 },
/* 39*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
/* 40*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 },
/* 41*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 },
/* 42*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 },
/* 43*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230, 118 },
/* 44*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 },
/* 45*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 },
/* 46*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 },
/* 47*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 },
/* 48*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 },
/* 49*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 },
/* 50*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 },
/* 51*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 },
/* 52*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 },
/* 53*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 },
/* 54*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 },
/* 55*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 56*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 },
/* 57*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 },
/* 58*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 },
/* 59*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 },
/* 60*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382, 150 },
/* 61*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 },
/* 62*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 },
/* 63*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 },
/* 64*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 },
/* 65*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 },
/* 66*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 },
/* 67*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 },
/* 68*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 69*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 },
/* 70*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 },
/* 71*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 },
/* 72*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 },
/* 73*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 },
/* 74*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 },
/* 75*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 },
/* 76*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 },
/* 77*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 },
/* 78*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238, 118 },
/* 79*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 },
/* 80*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 },
/* 81*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 },
/* 82*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 },
/* 83*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238, 118 },
/* 84*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150, 118 },
/* 85*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 },
/* 86*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 },
/* 87*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 },
/* 88*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 },
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 },
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 },
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 },
/* 92*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 },
/* 93*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 },
/* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 124, 288, 118 },
/* 11*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 151, 342, 118 },
/* 12*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 134, 118 },
/* 13*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 96, 192, 118 },
/* 14*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 123, 246, 118 },
/* 15*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 94, 118 },
/* 16*/ { BARCODE_EANX, "12", "", 50, 1, 20, 40, 118 },
/* 17*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 },
/* 18*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 },
/* 19*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 },
/* 20*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 },
/* 21*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 },
/* 22*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 },
/* 23*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 },
/* 24*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 },
/* 25*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 },
/* 26*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 },
/* 27*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 },
/* 28*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 },
/* 29*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 },
/* 30*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230, 118 },
/* 31*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230, 118 },
/* 32*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 288, 118 },
/* 33*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 342, 118 },
/* 34*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142, 118 },
/* 35*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142, 118 },
/* 36*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 80, 200, 118 },
/* 37*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 107, 254, 118 },
/* 38*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 39*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 },
/* 40*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 },
/* 41*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382, 118 },
/* 42*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 },
/* 43*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 },
/* 44*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 },
/* 45*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 },
/* 46*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 },
/* 47*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 300, 300 },
/* 48*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 49*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 },
/* 50*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 },
/* 51*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 },
/* 52*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 },
/* 53*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 },
/* 54*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230, 118 },
/* 55*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 124, 288, 118 },
/* 56*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 151, 342, 118 },
/* 57*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 },
/* 58*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 },
/* 59*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 },
/* 60*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 },
/* 61*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 },
/* 62*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 },
/* 63*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 },
/* 64*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 },
/* 65*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 },
/* 66*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 },
/* 67*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 },
/* 68*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 },
/* 69*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 },
/* 70*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 },
/* 71*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 },
/* 72*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 },
/* 73*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382, 150 },
/* 74*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 },
/* 75*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 },
/* 76*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 },
/* 77*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 },
/* 78*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 },
/* 79*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 },
/* 80*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 },
/* 81*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 },
/* 82*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 },
/* 83*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 },
/* 84*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 },
/* 85*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 },
/* 86*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 },
/* 87*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 },
/* 88*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 },
/* 89*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 },
/* 90*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 },
/* 91*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238, 118 },
/* 92*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 128, 296, 118 },
/* 93*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 155, 350, 118 },
/* 94*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 },
/* 95*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 },
/* 96*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 },
/* 97*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 },
/* 98*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238, 118 },
/* 99*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 296, 118 },
/*100*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 350, 118 },
/*101*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150, 118 },
/*102*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 84, 208, 118 },
/*103*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 111, 262, 118 },
/*104*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 },
/*105*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 },
/*106*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 },
/*107*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 },
/*108*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 },
/*109*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 },
/*110*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 },
/*111*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 },
/*112*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 },
};
int data_size = ARRAY_SIZE(data);
@ -261,7 +280,7 @@ static void test_buffer(int index, int generate, int debug) {
testFinish();
}
static void test_chk_extendable(int index, int debug) {
static void test_upcean_hrt(int index, int debug) {
testStart("");
@ -277,17 +296,45 @@ static void test_chk_extendable(int index, int debug) {
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
int expected_text_row;
int expected_text_col;
int expected_text_len;
int expected_addon_text_row;
int expected_addon_text_col;
int expected_addon_text_len;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_EANX_CHK, -1, "1234567890128+12", 0, 50, 1, 124, 288, 118, 5, 224 },
/* 1*/ { BARCODE_UPCA_CHK, -1, "12345678905+12345", 0, 50, 1, 151, 342, 118, 5, 258 },
/* 2*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 80, 200, 118, 5, 147 },
/* 3*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 80, 200, 118, 5, 147 },
/* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13
/* 1*/ { BARCODE_EANX, 0, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13
/* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13
/* 3*/ { BARCODE_EANX_CHK, 0, "1234567890128", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13
/* 4*/ { BARCODE_EANX_CHK, -1, "1234567890128+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, // EAN-13 + EAN-2
/* 5*/ { BARCODE_EANX_CHK, 0, "1234567890128+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, // EAN-13 + EAN-2
/* 6*/ { BARCODE_EANX, -1, "1234567890128+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // EAN-13 + EAN-5
/* 7*/ { BARCODE_EANX, 0, "1234567890128+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // EAN-13 + EAN-5
/* 8*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // ISBNX + EAN-5
/* 9*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // ISBNX + EAN-5
/* 10*/ { BARCODE_EANX, -1, "123456", 0, 50, 1, 67, 134, 118, 103 /*text_row*/, 6, 58, -1, -1, -1 }, // EAN-8
/* 11*/ { BARCODE_EANX, 0, "123456", 0, 50, 1, 67, 134, 118, 103 /*text_row*/, 6, 58, -1, -1, -1 }, // EAN-8
/* 12*/ { BARCODE_EANX, -1, "123456+12", 0, 50, 1, 96, 192, 118, 103 /*text_row*/, 6, 58, 5, 134, 58 }, // EAN-8 + EAN-2
/* 13*/ { BARCODE_EANX, 0, "123456+12", 0, 50, 1, 96, 192, 118, 103 /*text_row*/, 6, 58, 5, 134, 58 }, // EAN-8 + EAN-2
/* 14*/ { BARCODE_EANX, -1, "123456+12345", 0, 50, 1, 123, 246, 118, 103 /*text_row*/, 6, 58, 5, 134, 112 }, // EAN-8 + EAN-5
/* 15*/ { BARCODE_EANX, 0, "123456+12345", 0, 50, 1, 123, 246, 118, 103 /*text_row*/, 6, 58, 5, 134, 112 }, // EAN-8 + EAN-5
/* 16*/ { BARCODE_UPCA, -1, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 },
/* 17*/ { BARCODE_UPCA, 0, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 },
/* 18*/ { BARCODE_UPCA, -1, "123456789012+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 },
/* 19*/ { BARCODE_UPCA, 0, "123456789012+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 },
/* 20*/ { BARCODE_UPCA_CHK, -1, "123456789012+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 },
/* 21*/ { BARCODE_UPCA_CHK, 0, "123456789012+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 },
/* 22*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 142, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 },
/* 23*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 142, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 },
/* 24*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 80, 200, 118, 103 /*text_row*/, 0, 20, 5, 122, 78 },
/* 25*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 80, 200, 118, 103 /*text_row*/, 0, 20, 5, 122, 78 },
/* 26*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 107, 254, 118, 103 /*text_row*/, 0, 20, 5, 122, 130 },
/* 27*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 107, 254, 118, 103 /*text_row*/, 0, 20, 5, 122, 130 },
};
int data_size = sizeof(data) / sizeof(struct item);
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
@ -308,24 +355,44 @@ static void test_chk_extendable(int index, int debug) {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology);
if (index != -1) testUtilBitmapPrint(symbol);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, data[i].symbology, symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, data[i].symbology, symbol->bitmap_height, data[i].expected_bitmap_height);
int addon_text_bits_set = 0;
int row = data[i].expected_addon_text_row;
for (int column = data[i].expected_addon_text_col; column < data[i].expected_addon_text_col + 48; column++) {
if (is_row_column_black(symbol, row, column)) {
addon_text_bits_set = 1;
break;
if (data[i].expected_text_row != -1) {
int text_bits_set = 0;
int row = data[i].expected_text_row;
for (int column = data[i].expected_text_col; column < data[i].expected_text_col + data[i].expected_text_len; column++) {
if (is_row_column_black(symbol, row, column)) {
text_bits_set = 1;
break;
}
}
if (symbol->show_hrt) {
assert_nonzero(text_bits_set, "i:%d (%s) text_bits_set zero\n", i, testUtilBarcodeName(data[i].symbology));
} else {
assert_zero(text_bits_set, "i:%d (%s) text_bits_set non-zero\n", i, testUtilBarcodeName(data[i].symbology));
}
}
if (symbol->show_hrt) {
assert_nonzero(addon_text_bits_set, "i:%d (%d) addon_text_bits_set zero\n", i, data[i].symbology);
} else {
assert_zero(addon_text_bits_set, "i:%d (%d) addon_text_bits_set non-zero\n", i, data[i].symbology);
if (data[i].expected_addon_text_row != -1) {
int addon_text_bits_set = 0;
int row = data[i].expected_addon_text_row;
for (int column = data[i].expected_addon_text_col; column < data[i].expected_addon_text_col + data[i].expected_addon_text_len; column++) {
if (is_row_column_black(symbol, row, column)) {
addon_text_bits_set = 1;
break;
}
}
if (symbol->show_hrt) {
assert_nonzero(addon_text_bits_set, "i:%d (%s) addon_text_bits_set zero\n", i, testUtilBarcodeName(data[i].symbology));
} else {
assert_zero(addon_text_bits_set, "i:%d (%s) addon_text_bits_set non-zero\n", i, testUtilBarcodeName(data[i].symbology));
}
}
ZBarcode_Delete(symbol);
@ -412,6 +479,121 @@ static void test_row_separator(int index, int debug) {
testFinish();
}
static void test_output_options(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int whitespace_width;
int border_width;
int output_options;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
int expected_set;
int expected_set_row;
int expected_set_col;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 0, 4 },
/* 1*/ { BARCODE_CODE128, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 0, 4 },
/* 2*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126, 1, 0, 4 },
/* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126, 0, 4, 4 },
/* 4*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 166, 126, 1, 4, 4 },
/* 5*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 0, 8 },
/* 6*/ { BARCODE_CODE128, 3, -1, -1, "A123", 0, 50, 1, 79, 170, 118, 1, 0, 8 },
/* 7*/ { BARCODE_CODE128, 3, 4, -1, "A123", 0, 50, 1, 79, 170, 118, 1, 0, 8 },
/* 8*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134, 1, 0, 0 },
/* 9*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134, 0, 8, 0 },
/* 10*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 186, 134, 1, 8, 0 },
/* 11*/ { BARCODE_CODE128, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
/* 12*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 },
/* 13*/ { BARCODE_QRCODE, -1, 3, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 },
/* 14*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 1, 2, 2 },
/* 15*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 20, 0 },
/* 16*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 20, 0 },
/* 17*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 },
/* 18*/ { BARCODE_QRCODE, 5, -1, -1, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 },
/* 19*/ { BARCODE_QRCODE, 5, 6, -1, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 },
/* 20*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 },
/* 21*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 },
/* 22*/ { BARCODE_QRCODE, 5, 6, BARCODE_BOX, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 },
/* 23*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 43, 43, -1, -1, -1 }, // TODO: investigate +1 size
/* 24*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 43, 43, -1, -1, -1 },
/* 25*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 43, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 26*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 63, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode)
/* 27*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 28*/ { BARCODE_MAXICODE, -1, 5, -1, "A123", 0, 165, 33, 30, 300, 300, 0, 0, 0 },
/* 29*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 300, 320, 1, 0, 0 },
/* 30*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 300, 320, 0, 10, 0 },
/* 31*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 320, 320, 1, 10, 0 },
/* 32*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 300, 300, 1, 0, 14 },
/* 33*/ { BARCODE_MAXICODE, 6, -1, -1, "A123", 0, 165, 33, 30, 324, 300, 0, 0, 14 },
/* 34*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 324, 320, 1, 10, 25 },
/* 35*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 324, 320, 0, 10, 9 },
/* 36*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 344, 320, 1, 10, 9 },
/* 37*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
if (data[i].whitespace_width != -1) {
symbol->whitespace_width = data[i].whitespace_width;
}
if (data[i].border_width != -1) {
symbol->border_width = data[i].border_width;
}
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer(symbol, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Buffer(%d) ret %d != %d\n", i, data[i].symbology, ret, data[i].ret);
if (ret < 5) {
assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology);
if (index != -1) testUtilBitmapPrint(symbol);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, data[i].symbology, symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, data[i].symbology, symbol->bitmap_height, data[i].expected_bitmap_height);
if (data[i].expected_set != -1) {
ret = is_row_column_black(symbol, data[i].expected_set_row, data[i].expected_set_col);
if (data[i].expected_set) {
assert_nonzero(ret, "i:%d (%d) is_row_column_black(%d, %d) non-zero\n", i, data[i].symbology, data[i].expected_set_row, data[i].expected_set_col);
} else {
assert_zero(ret, "i:%d (%d) is_row_column_black(%d, %d) zero\n", i, data[i].symbology, data[i].expected_set_row, data[i].expected_set_col);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_draw_string_wrap(int index, int debug) {
testStart("");
@ -485,83 +667,15 @@ static void test_draw_string_wrap(int index, int debug) {
testFinish();
}
static void test_border_whitespace(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int whitespace_width;
int border_width;
int output_options;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
int expected_bitmap_width;
int expected_bitmap_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118 },
/* 1*/ { BARCODE_CODE128, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118 },
/* 2*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 118 },
/* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 158, 118 },
/* 4*/ { BARCODE_CODE128, 3, -1, -1, "A123", 0, 50, 1, 79, 170, 118 },
/* 5*/ { BARCODE_CODE128, 3, 4, -1, "A123", 0, 50, 1, 79, 170, 118 },
/* 6*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 118 },
/* 7*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 170, 118 },
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
if (data[i].whitespace_width != -1) {
symbol->whitespace_width = data[i].whitespace_width;
}
if (data[i].border_width != -1) {
symbol->border_width = data[i].border_width;
}
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, data[i].symbology, symbol->bitmap_width, data[i].expected_bitmap_width);
assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, data[i].symbology, symbol->bitmap_height, data[i].expected_bitmap_height);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_options", test_options, 1, 0, 1 },
{ "test_buffer", test_buffer, 1, 1, 1 },
{ "test_chk_extendable", test_chk_extendable, 1, 0, 1 },
{ "test_upcean_hrt", test_upcean_hrt, 1, 0, 1 },
{ "test_row_separator", test_row_separator, 1, 0, 1 },
{ "test_output_options", test_output_options, 1, 0, 1 },
{ "test_draw_string_wrap", test_draw_string_wrap, 1, 0, 1 },
{ "test_border_whitespace", test_border_whitespace, 1, 0, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View File

@ -100,7 +100,7 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
testFinish();
}
// Replicate examples from GS1 General Specifications 19.1 and ISO/IEC 24724:2011
// Replicate examples from GS1 General Specifications 20.0 and ISO/IEC 24724:2011
static void test_examples(int index, int generate, int debug) {
testStart("");
@ -108,6 +108,7 @@ static void test_examples(int index, int generate, int debug) {
int ret;
struct item {
int symbology;
int option_2;
unsigned char *data;
int ret;
@ -116,79 +117,102 @@ static void test_examples(int index, int generate, int debug) {
char *comment;
unsigned char *expected;
};
// Verified manually against GS1 General Specifications 19.1 and ISO/IEC 24724:2011
// Verified manually against GS1 General Specifications 20.0 and ISO/IEC 24724:2011
struct item data[] = {
/* 0*/ { BARCODE_RSS14, "0950110153001", 0, 1, 96, "Figure 5.5.2.1.1-1. GS1 DataBar Omnidirectional",
/* 0*/ { BARCODE_RSS14, -1, "0950110153001", 0, 1, 96, "Figure 5.5.2.1.1-1. GS1 DataBar Omnidirectional",
"010000010100000101000111110000010111101101011100100011011101000101100000000111001110110111001101"
},
/* 1*/ { BARCODE_RSS_EXP, "[01]90614141000015[3202]000150", 0, 1, 151, "Figure 5.5.2.3.1-1. GS1 DataBar Expanded",
/* 1*/ { BARCODE_RSS_EXP, -1, "[01]90614141000015[3202]000150", 0, 1, 151, "Figure 5.5.2.3.1-1. GS1 DataBar Expanded",
"0101100011001100001011111111000010100100010000111101110011100010100010111100000011100111010111111011010100000100000110001111110000101000000100011010010"
},
/* 2*/ { BARCODE_RSS_EXPSTACK, "[01]90614141000015[3202]000150", 0, 5, 102, "Figure 5.5.2.3.2-1. GS1 DataBar Expanded Stacked",
/* 2*/ { BARCODE_RSS_EXPSTACK, -1, "[01]90614141000015[3202]000150", 0, 5, 102, "Figure 5.5.2.3.2-1. GS1 DataBar Expanded Stacked",
"010110001100110000101111111100001010010001000011110111001110001010001011110000001110011101011111101101"
"000001110011001111010000000010100101101110111100001000110001110101100100001010100001100010100000010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000001011111011111001010000001010010111111011100100000000000000000000000000000000000000000000000000000"
"001010100000100000110001111110000101000000100011010010000000000000000000000000000000000000000000000000"
},
/* 3*/ { BARCODE_RSS14, "2001234567890", 0, 1, 96, "24724:2011 Figure 1 — GS1 DataBar Omnidirectional",
/* 3*/ { BARCODE_RSS14, -1, "2001234567890", 0, 1, 96, "24724:2011 Figure 1 — GS1 DataBar Omnidirectional",
"010100011101000001001111111000010100110110111110110000010010100101100000000111000110110110001101"
},
/* 4*/ { BARCODE_RSS14, "0441234567890", 0, 1, 96, "24724:2011 Figure 2 — GS1 DataBar Omnidirectional",
/* 4*/ { BARCODE_RSS14, -1, "0441234567890", 0, 1, 96, "24724:2011 Figure 2 — GS1 DataBar Omnidirectional",
"010010001000010001000111000000010101000001100110101100100100000101111110000011000010100011100101"
},
/* 5*/ { BARCODE_RSS14, "0001234567890", 0, 1, 96, "24724:2011 Figure 4 — GS1 DataBar Truncated",
/* 5*/ { BARCODE_RSS14, -1, "0001234567890", 0, 1, 96, "24724:2011 Figure 4 — GS1 DataBar Truncated",
"010101001000000001001111111000010111001011011110111001010110000101111111000111001100111101110101"
},
/* 6*/ { BARCODE_RSS14STACK, "0001234567890", 0, 3, 50, "24724:2011 Figure 5 — GS1 DataBar Stacked",
/* 6*/ { BARCODE_RSS14STACK, -1, "0001234567890", 0, 3, 50, "24724:2011 Figure 5 — GS1 DataBar Stacked",
"01010100100000000100111111100001011100101101111010"
"00001010101011111010000000111010100011010010000000"
"10111001010110000101111111000111001100111101110101"
},
/* 7*/ { BARCODE_RSS14STACK_OMNI, "0003456789012", 0, 5, 50, "24724:2011 Figure 6 — GS1 DataBar Stacked Omnidirectional",
/* 7*/ { BARCODE_RSS14STACK_OMNI, -1, "0003456789012", 0, 5, 50, "24724:2011 Figure 6 — GS1 DataBar Stacked Omnidirectional",
"01010100100000000100111110000001010011100110011010"
"00001011011111111010000001010100101100011001100000"
"00000101010101010101010101010101010101010101010000"
"00001000100010111010010101010000111101001101110000"
"10110111011101000101100000000111000010110010001101"
},
/* 8*/ { BARCODE_RSS_LTD, "1501234567890", 0, 1, 74, "24724:2011 Figure 7 — GS1 DataBar Limited",
/* 8*/ { BARCODE_RSS_LTD, -1, "1501234567890", 0, 1, 74, "24724:2011 Figure 7 — GS1 DataBar Limited",
"01000110011000110110101001110100101011010011010010010110001101110011001101"
},
/* 9*/ { BARCODE_RSS_LTD, "0031234567890", 0, 1, 74, "24724:2011 Figure 8 — (a) GS1 DataBar Limited",
/* 9*/ { BARCODE_RSS_LTD, -1, "0031234567890", 0, 1, 74, "24724:2011 Figure 8 — (a) GS1 DataBar Limited",
"01010100000100100010000101110010101101101001010110000010100100101100000101"
},
/*10*/ { BARCODE_RSS_EXP, "[01]98898765432106[3202]012345[15]991231", 0, 1, 200, "24724:2011 Figure 10 — GS1 DataBar Expanded",
/*10*/ { BARCODE_RSS_EXP, -1, "[01]98898765432106[3202]012345[15]991231", 0, 1, 200, "24724:2011 Figure 10 — GS1 DataBar Expanded",
"01001000011000110110111111110000101110000110010100011010000001100010101111110000111010011100000010010100111110111001100011111100001011101100000100100100011110010110001011111111001110001101111010000101"
},
/*11*/ { BARCODE_RSS_EXP, "[01]90012345678908[3103]001750", 0, 1, 151, "24724:2011 Figure 11 — GS1 DataBar Expanded",
/*11*/ { BARCODE_RSS_EXP, -1, "[01]90012345678908[3103]001750", 0, 1, 151, "24724:2011 Figure 11 — GS1 DataBar Expanded",
"0101110010000010011011111111000010111000010011000101011110111001100010111100000011100101110001110111011110101111000110001111110000101011000010011111010"
},
/*12*/ { BARCODE_RSS_EXPSTACK, "[01]98898765432106[3202]012345[15]991231", 0, 5, 102, "24724:2011 Figure 12 — GS1 DataBar Expanded Stacked symbol",
/*12*/ { BARCODE_RSS_EXPSTACK, -1, "[01]98898765432106[3202]012345[15]991231", 0, 5, 102, "24724:2011 Figure 12 — GS1 DataBar Expanded Stacked symbol",
"010010000110001101101111111100001011100001100101000110100000011000101011111100001110100111000000100101"
"000001111001110010010000000010100100011110011010111001011111100111010100000010100001011000111111010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000011101000010011100001000000001011100101100001110110110111110010001001010000001010011000100000110000"
"101000010111101100011100111111110100011010011110001001001000001101110100001111110001100111011111001010"
},
/*13*/ { BARCODE_RSS_EXPSTACK, "[01]95012345678903[3103]000123", 0, 5, 102, "24724:2011 Figure 13 — GS1 DataBar Expanded Stacked",
/*13*/ { BARCODE_RSS_EXPSTACK, -1, "[01]95012345678903[3103]000123", 0, 5, 102, "24724:2011 Figure 13 — GS1 DataBar Expanded Stacked",
"010100010001111000101111111100001010111000001100010111000110001001101011110000001110010111000111011101"
"000011101110000111010000000010100101000111110011101000111001110110010100001010100001101000111000100000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000001010000111001010000001010010111011011111100000000000000000000000000000000000000000000000000000"
"001011110101111000110001111110000101000100100000011010000000000000000000000000000000000000000000000000"
},
/*14*/ { BARCODE_RSS_LTD, "0009876543210", 0, 1, 74, "24724:2011 Figure F.2 — GS1 DataBar Limited",
/*14*/ { BARCODE_RSS_LTD, -1, "0009876543210", 0, 1, 74, "24724:2011 Figure F.2 — GS1 DataBar Limited",
"01010100100100110000110000010101101001011001010001000101000100000100100101"
},
/*15*/ { BARCODE_RSS_EXP, "[10]12A", 0, 1, 102, "24724:2011 Figure F.3 — GS1 DataBar Expanded",
/*15*/ { BARCODE_RSS_EXP, -1, "[10]12A", 0, 1, 102, "24724:2011 Figure F.3 — GS1 DataBar Expanded",
"010100000110100000101111111100001010001000000010110101111100100111001011110000000010011101111111010101"
},
/*16*/ { BARCODE_RSS14STACK, "0000000000000", 0, 3, 50, "#183 GS1 DataBar Stacked separator alternation; verified manually against tec-it.com (bwipp differs)",
/*16*/ { BARCODE_RSS14STACK, -1, "0000000000000", 0, 3, 50, "#183 GS1 DataBar Stacked separator alternation; verified manually against tec-it.com (bwipp differs)",
"01010100100000000100011111111001011111110010101010"
"00000101011111111010100000001010100000001101010000"
"10101010110000000101111111110111011111111011010101"
},
/*17*/ { BARCODE_RSS_EXP, -1, "[255]95011015340010123456789", 0, 1, 232, "2.6.2.1 Example 1",
"0100011000110001011011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111011001000111100100101111111100111011111001100100110010011100010111100011110000001010"
},
/*18*/ { BARCODE_RSS_EXP, -1, "[255]95011015340010123456789[3900]000", 0, 1, 298, "2.6.2.1 Example 2",
"0101100011111010001011111111000010100001000001001101100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111011001000111100100101111111100111011111001100100110010011100010111100011000000001010111111011101000100001000110001101011111111100110011110010010001101"
},
/*19*/ { BARCODE_RSS_EXP, -1, "[255]9501101534001[17]160531[3902]050", 0, 1, 281, "2.6.2.1 Example 3",
"01011001000110011110111111110000101000000101011000011000011001110010101111100000011001000011101000010010000110111110100011111100001010010111111001110111000010010100001011111111001110000100001100110100010000001101001000110000000010111010011110011101110010110001100010111111111001101"
},
/*20*/ { BARCODE_RSS_EXPSTACK, 3, "[255]9501101534001012345[8111]0500", 0, 5, 151, "2.6.2.1 Example 4 **NOT SAME** separator bar differs TODO: investigate",
"0101100111100011001011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111010"
"0000011000011100110100000000101001011111101010011110011110011000110101000001010100011011110001011110110111100100000101010000001010010110100000011000000"
"0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000"
"0000110111000011010010000000010000100000100111011001100001100100010010100101010100101110110001111001011101100011101100100000000010000000000000000000000"
"1011001000111100100101111111100111011111011000100110011110011011101100011000000001010001001110000110100010011100010001011111111100110100000000000000000"
},
/*21*/ { BARCODE_RSS_EXPSTACK, 3, "[255]9501101534001[3941]0035", 0, 5, 151, "2.6.2.1 Example 5 **NOT SAME** separator bar differs TODO: investigate",
"0100001101011000011011111111000010100000010101100001100001100111001010111110000001100100001110100001001000011011111010001111110000101001011111100111010"
"0000110010100111100100000000101001011111101010011110011110011000110101000001010100011011110001011110110111100100000101010000001010010110100000011000000"
"0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000"
"0000011011111011110010000000010000111100101011111001000100011100111010100001010100000000000000000000000000000000000000000000000000000000000000000000000"
"1010100100000100000101111111100111000011010100000110111011100011000100011110000001010000000000000000000000000000000000000000000000000000000000000000000"
},
};
int data_size = sizeof(data) / sizeof(struct item);
@ -199,18 +223,15 @@ static void test_examples(int index, int generate, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
symbol->debug |= debug;
int length = strlen(data[i].data);
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d %s\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
if (ret == 0) {
printf(" /*%2d*/ { %s, \"%s\", %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(symbol->symbology), data[i].data, ret, symbol->rows, symbol->width, data[i].comment);
printf(" /*%2d*/ { %s, %d, \"%s\", %d, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(symbol->symbology), data[i].option_2, data[i].data, ret, symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {

View File

@ -31,6 +31,241 @@
#include "testcommon.h"
static void test_large(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *pattern;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "\177", 30, 0, 1, 528 },
/* 1*/ { BARCODE_TELEPEN, "\177", 31, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_TELEPEN_NUM, "1", 60, 0, 1, 528 },
/* 3*/ { BARCODE_TELEPEN_NUM, "1", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
char data_buf[64];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int length;
unsigned char *expected;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "ABC1234.;$", -1, "ABC1234.;$" },
/* 1*/ { BARCODE_TELEPEN, "abc1234.;$", -1, "abc1234.;$" },
/* 2*/ { BARCODE_TELEPEN, "ABC1234\001", -1, "ABC1234\001" },
/* 3*/ { BARCODE_TELEPEN, "ABC\0001234", 8, "ABC 1234" },
/* 4*/ { BARCODE_TELEPEN_NUM, "1234", -1, "1234" },
/* 5*/ { BARCODE_TELEPEN_NUM, "123X", -1, "123X" },
/* 6*/ { BARCODE_TELEPEN_NUM, "123x", -1, "123X" }, // Converts to upper
/* 7*/ { BARCODE_TELEPEN_NUM, "12345", -1, "012345" }, // Adds leading zero if odd
};
int data_size = ARRAY_SIZE(data);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_zero(strcmp(symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_input(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512 },
/* 1*/ { BARCODE_TELEPEN, "AZaz\176\001", -1, 0, 1, 144 },
/* 2*/ { BARCODE_TELEPEN, "\000\177", 2, 0, 1, 80 },
/* 3*/ { BARCODE_TELEPEN, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128 },
/* 5*/ { BARCODE_TELEPEN_NUM, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_TELEPEN_NUM, "123456789X", -1, 0, 1, 128 }, // [0-9]X allowed
/* 7*/ { BARCODE_TELEPEN_NUM, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, // X[0-9] not allowed
/* 8*/ { BARCODE_TELEPEN_NUM, "1X34567X9X", -1, 0, 1, 128 }, // [0-9]X allowed multiple times
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (ret < 5) {
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// Telepen Barcode Symbology information and History (BSiH) https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf
// E2326U: SB Telepen Barcode Fonts Guide Issue 2 (Apr 2009) https://telepen.co.uk/wp-content/uploads/2018/09/SB-Telepen-Barcode-Fonts-V2.pdf
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same",
"10101010101110001011101000100010101110111011100010100010001110101110001010101010"
},
/* 1*/ { BARCODE_TELEPEN, "ABC", -1, 0, 1, 96, "Telepen E2326U Example, same",
"101010101011100010111011101110001110001110111000101011101110101011101000101000101110001010101010"
},
/* 2*/ { BARCODE_TELEPEN, "RST", -1, 0, 1, 96, "Verified manually against bwipp and tec-it",
"101010101011100011100011100010101010111010111000111010111000101010111000111011101110001010101010"
},
/* 3*/ { BARCODE_TELEPEN, "?@", -1, 0, 1, 80, "ASCII count 127, check 0; verified manually against bwipp and tec-it",
"10101010101110001010101010101110111011101110101011101110111011101110001010101010"
},
/* 4*/ { BARCODE_TELEPEN, "\000", 1, 0, 1, 64, "Verified manually against bwipp and tec-it",
"1010101010111000111011101110111011101110111011101110001010101010"
},
/* 5*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "Verified manually against bwipp and tec-it",
"10101010101110001010101110101110101000101010001010101110101110001011101010001000101110001010101010101011101010101110001010101010"
},
/* 6*/ { BARCODE_TELEPEN_NUM, "123456789", -1, 0, 1, 128, "Verified manually against bwipp (012345679) and tec-it (012345679)",
"10101010101110001110101010111010111000100010001011101110001110001000101010001010111010100010100010111000101110101110001010101010"
},
/* 7*/ { BARCODE_TELEPEN_NUM, "123X", -1, 0, 1, 80, "Verified manually against bwipp and tec-it",
"10101010101110001010101110101110111010111000111011101011101110001110001010101010"
},
/* 8*/ { BARCODE_TELEPEN_NUM, "1X3X", -1, 0, 1, 80, "Verified manually against bwipp and tec-it",
"10101010101110001110001110001110111010111000111010111010101110001110001010101010"
},
};
int data_size = ARRAY_SIZE(data);
char escaped[1024];
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
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);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// #181 Nico Gunkel OSS-Fuzz
static void test_fuzz(int index, int debug) {
@ -43,6 +278,7 @@ static void test_fuzz(int index, int debug) {
int length;
int ret;
};
// Note NULs where using DELs code (16 binary characters wide)
// s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 30, 0 },
@ -79,6 +315,10 @@ static void test_fuzz(int index, int debug) {
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_large", test_large, 1, 0, 1 },
{ "test_hrt", test_hrt, 1, 0, 1 },
{ "test_input", test_input, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
};

View File

@ -49,45 +49,49 @@ static void test_input(int index, int generate, int debug) {
struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, "A", 0, "(2) 257 65", "" },
/* 1*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "A", 0, "(2) 272 65", "" },
/* 2*/ { UNICODE_MODE, 0, -1, -1, "ABC", 0, "(4) 257 65 66 67", "" },
/* 3*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ABC", 0, "(4) 272 65 66 67", "" },
/* 4*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ULTRACODE_123456789!", 0, "(17) 272 85 76 84 82 65 67 79 68 69 95 140 162 184 206 57 33", "" },
/* 5*/ { UNICODE_MODE, 0, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(250) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "249 chars EC2" },
/* 6*/ { UNICODE_MODE, 0, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "250 chars EC2" },
/* 7*/ { UNICODE_MODE, 0, 1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(274) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "273 chars EC0" },
/* 8*/ { UNICODE_MODE, 0, 1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "274 chars EC0" },
/* 9*/ { UNICODE_MODE, 0, -1, -1, "é", 0, "(2) 257 233", "" },
/* 10*/ { UNICODE_MODE, 0, -1, -1, "β", ZINT_WARN_USES_ECI, "Warning (2) 263 226", "" },
/* 11*/ { UNICODE_MODE, 9, -1, -1, "β", 0, "(2) 263 226", "" },
/* 12*/ { UNICODE_MODE, 9, -1, -1, "βAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(250) 263 226 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "249 chars EC2" },
/* 13*/ { UNICODE_MODE, 9, -1, ULTRA_COMPRESSION, "A", 0, "(2) 272 65", "Note ECI ignored and not outputted if ULTRA_COMPRESSION and all ASCII" },
/* 14*/ { UNICODE_MODE, 15, -1, -1, "Ŗ", 0, "(2) 268 170", "" },
/* 15*/ { DATA_MODE, 898, -1, -1, "\001\002\003\004\377", 0, "(7) 278 130 1 2 3 4 255", "" },
/* 16*/ { DATA_MODE, 899, -1, -1, "\001\002\003\004\377", 0, "(6) 280 1 2 3 4 255", "" },
/* 17*/ { DATA_MODE, 900, -1, -1, "\001\002\003\004\377", 0, "(9) 257 274 137 128 1 2 3 4 255", "" },
/* 18*/ { DATA_MODE, 9999, -1, -1, "\001\002\003\004\377", 0, "(9) 257 274 227 227 1 2 3 4 255", "" },
/* 19*/ { DATA_MODE, 10000, -1, -1, "\001\002\003\004\377", 0, "(10) 257 275 129 128 128 1 2 3 4 255", "" },
/* 20*/ { DATA_MODE, 811799, -1, -1, "\001\002\003\004\377", 0, "(10) 257 275 209 145 227 1 2 3 4 255", "" },
/* 21*/ { DATA_MODE, 811800, -1, -1, "\001\002\003\004\377", ZINT_ERROR_INVALID_OPTION, "Error 590: ECI value not supported by Ultracode", "" },
/* 22*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "123,456,789/12,/3,4,/5//", 0, "(15) 272 140 231 173 234 206 257 140 44 262 242 44 264 47 47", "Mode: a (24)" },
/* 23*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(32) 257 256 46 151 78 210 205 208 258 5 148 28 72 2 167 52 127 193 83 75 211 267 76 65 32", "Mode: cccccc88cccccccccc8888aaa8cccccc (32)" },
/* 24*/ { UNICODE_MODE, 0, -1, -1, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(33) 257 72 69 73 77 65 83 205 208 65 32 75 69 78 78 65 82 65 72 193 83 75 211 76 65 32 205", "" },
/* 25*/ { UNICODE_MODE, 10, -1, ULTRA_COMPRESSION, "אולטרה-קוד1234", 0, "(14) 264 224 229 236 232 248 228 45 247 229 227 267 140 162", "Mode: 8888888888aaaa (14); Figure G.3" },
/* 26*/ { UNICODE_MODE, 10, -1, -1, "אולטרה-קוד1234", 0, "(15) 264 224 229 236 232 248 228 45 247 229 227 49 50 51 52", "" },
/* 27*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "https://aimglobal.org/jcrv3tX", 0, "(16) 282 266 1 74 41 19 6 168 270 212 59 106 144 56 265 70", "Mode: c (21); Figure G.4a" },
/* 28*/ { UNICODE_MODE, 0, -1, -1, "https://aimglobal.org/jcrv3tX", 0, "(22) 282 97 105 109 103 108 111 98 97 108 46 111 114 103 47 106 99 114 118 51 116 88", "" },
/* 29*/ { GS1_MODE, 0, -1, -1, "[01]03453120000011[17]121125[10]ABCD1234", 0, "(20) 273 129 131 173 159 148 128 128 139 145 140 139 153 138 65 66 67 68 140 162", "Mode: a (34); Figure G.6 uses C43 for 6 of last 7 chars (same codeword count)" },
/* 30*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCD1234[410]9501101020917", 0, "(21) 273 145 140 133 136 138 65 66 67 68 140 162 272 169 137 178 139 129 130 137 145", "Mode: a (35)" },
/* 31*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCDEFGHI[410]9501101020917", 0, "(24) 273 145 140 133 136 138 65 66 67 68 69 70 71 72 73 272 169 137 178 139 129 130 137 145", "Mode: a (36)" },
/* 32*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://", 0, "(4) 272 278 269 165", "Mode: c (6)" },
/* 33*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, ".cgi", 0, "(4) 272 278 274 131", "Mode: c (4)" },
/* 34*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://a.cgi", 0, "(6) 272 280 269 123 274 131", "Mode: c (11)" },
/* 35*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "e: file:f.shtml !", 0, "(12) 272 280 30 94 236 235 72 233 39 52 267 250", "Mode: c (17)" },
/* 36*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aaatel:", 0, "(6) 272 280 262 76 6 89", "Mode: c (7)" },
/* 37*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aatel:a", 0, "(6) 272 280 262 76 271 161", "Mode: c (7)" },
/* 38*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Atel:aAa", 0, "(8) 272 275 6 89 275 148 0 42", "Mode: c (8)" },
/* 39*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "tel:AAaa", 0, "(8) 272 275 271 161 6 28 262 118", "Mode: c (8)" },
/* 40*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "AAaatel:aA", 0, "(10) 272 276 0 42 0 41 118 46 6 156", "Mode: c (10)" },
/* 2*/ { UNICODE_MODE, 0, -1, -1, "12", 0, "(3) 257 49 50", "" },
/* 3*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "12", 0, "(2) 272 140", "" },
/* 4*/ { UNICODE_MODE, 0, -1, -1, "123", 0, "(4) 257 49 50 51", "" },
/* 5*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "123", 0, "(3) 272 140 51", "" },
/* 6*/ { UNICODE_MODE, 0, -1, -1, "ABC", 0, "(4) 257 65 66 67", "" },
/* 7*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ABC", 0, "(4) 272 65 66 67", "" },
/* 8*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ULTRACODE_123456789!", 0, "(17) 272 85 76 84 82 65 67 79 68 69 95 140 162 184 206 57 33", "" },
/* 9*/ { UNICODE_MODE, 0, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(250) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "249 chars EC2" },
/* 10*/ { UNICODE_MODE, 0, -1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "250 chars EC2" },
/* 11*/ { UNICODE_MODE, 0, 1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(274) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "273 chars EC0" },
/* 12*/ { UNICODE_MODE, 0, 1, -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "274 chars EC0" },
/* 13*/ { UNICODE_MODE, 0, -1, -1, "é", 0, "(2) 257 233", "" },
/* 14*/ { UNICODE_MODE, 0, -1, -1, "β", ZINT_WARN_USES_ECI, "Warning (2) 263 226", "" },
/* 15*/ { UNICODE_MODE, 9, -1, -1, "β", 0, "(2) 263 226", "" },
/* 16*/ { UNICODE_MODE, 9, -1, -1, "βAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(250) 263 226 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "249 chars EC2" },
/* 17*/ { UNICODE_MODE, 9, -1, ULTRA_COMPRESSION, "A", 0, "(2) 272 65", "Note ECI ignored and not outputted if ULTRA_COMPRESSION and all ASCII" },
/* 18*/ { UNICODE_MODE, 15, -1, -1, "Ŗ", 0, "(2) 268 170", "" },
/* 19*/ { DATA_MODE, 898, -1, -1, "\001\002\003\004\377", 0, "(7) 278 130 1 2 3 4 255", "" },
/* 20*/ { DATA_MODE, 899, -1, -1, "\001\002\003\004\377", 0, "(6) 280 1 2 3 4 255", "" },
/* 21*/ { DATA_MODE, 900, -1, -1, "\001\002\003\004\377", 0, "(9) 257 274 137 128 1 2 3 4 255", "" },
/* 22*/ { DATA_MODE, 9999, -1, -1, "\001\002\003\004\377", 0, "(9) 257 274 227 227 1 2 3 4 255", "" },
/* 23*/ { DATA_MODE, 10000, -1, -1, "\001\002\003\004\377", 0, "(10) 257 275 129 128 128 1 2 3 4 255", "" },
/* 24*/ { DATA_MODE, 811799, -1, -1, "\001\002\003\004\377", 0, "(10) 257 275 209 145 227 1 2 3 4 255", "" },
/* 25*/ { DATA_MODE, 811800, -1, -1, "\001\002\003\004\377", ZINT_ERROR_INVALID_OPTION, "Error 590: ECI value not supported by Ultracode", "" },
/* 26*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "123,456,789/12,/3,4,/5//", 0, "(15) 272 140 231 173 234 206 257 140 44 262 242 44 264 47 47", "Mode: a (24)" },
/* 27*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(32) 257 256 46 151 78 210 205 208 258 5 148 28 72 2 167 52 127 193 83 75 211 267 76 65 32", "Mode: cccccc88cccccccccc8888aaa8cccccc (32)" },
/* 28*/ { UNICODE_MODE, 0, -1, -1, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(33) 257 72 69 73 77 65 83 205 208 65 32 75 69 78 78 65 82 65 72 193 83 75 211 76 65 32 205", "" },
/* 29*/ { UNICODE_MODE, 10, -1, ULTRA_COMPRESSION, "אולטרה-קוד1234", 0, "(14) 264 224 229 236 232 248 228 45 247 229 227 267 140 162", "Mode: 8888888888aaaa (14); Figure G.3" },
/* 30*/ { UNICODE_MODE, 10, -1, -1, "אולטרה-קוד1234", 0, "(15) 264 224 229 236 232 248 228 45 247 229 227 49 50 51 52", "" },
/* 31*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "https://aimglobal.org/jcrv3tX", 0, "(16) 282 266 1 74 41 19 6 168 270 212 59 106 144 56 265 70", "Mode: c (21); Figure G.4a" },
/* 32*/ { UNICODE_MODE, 0, -1, -1, "https://aimglobal.org/jcrv3tX", 0, "(22) 282 97 105 109 103 108 111 98 97 108 46 111 114 103 47 106 99 114 118 51 116 88", "" },
/* 33*/ { GS1_MODE, 0, -1, -1, "[01]03453120000011[17]121125[10]ABCD1234", 0, "(20) 273 129 131 173 159 148 128 128 139 145 140 139 153 138 65 66 67 68 140 162", "Mode: a (34); Figure G.6 uses C43 for 6 of last 7 chars (same codeword count)" },
/* 34*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCD1234[410]9501101020917", 0, "(21) 273 145 140 133 136 138 65 66 67 68 140 162 272 169 137 178 139 129 130 137 145", "Mode: a (35)" },
/* 35*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCDEFGHI[410]9501101020917", 0, "(24) 273 145 140 133 136 138 65 66 67 68 69 70 71 72 73 272 169 137 178 139 129 130 137 145", "Mode: a (36)" },
/* 36*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://", 0, "(4) 272 278 269 165", "Mode: c (6)" },
/* 37*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, ".cgi", 0, "(4) 272 278 274 131", "Mode: c (4)" },
/* 38*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://a.cgi", 0, "(6) 272 280 269 123 274 131", "Mode: c (11)" },
/* 39*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "e: file:f.shtml !", 0, "(12) 272 280 30 94 236 235 72 233 39 52 267 250", "Mode: c (17)" },
/* 40*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aaatel:", 0, "(6) 272 280 262 76 6 89", "Mode: c (7)" },
/* 41*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aatel:a", 0, "(6) 272 280 262 76 271 161", "Mode: c (7)" },
/* 42*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Atel:aAa", 0, "(8) 272 275 6 89 275 148 0 42", "Mode: c (8)" },
/* 43*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "tel:AAaa", 0, "(8) 272 275 271 161 6 28 262 118", "Mode: c (8)" },
/* 44*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "AAaatel:aA", 0, "(10) 272 276 0 42 0 41 118 46 6 156", "Mode: c (10)" },
};
int data_size = sizeof(data) / sizeof(struct item);

View File

@ -268,6 +268,67 @@ static void test_vector_same(int index, int debug) {
testFinish();
}
static void test_encode(int index, int generate, int debug) {
testStart("");
int ret;
struct item {
int symbology;
unsigned char *data;
int ret;
int expected_rows;
int expected_width;
char *comment;
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_UPCA, "1234567890", 0, 1, 95, "GS1 General Specifications 20.0 Figure 5.1-1 left",
"10100011010011001001001101111010100011011000101010101000010001001001000111010011100101001110101"
},
/* 1*/ { BARCODE_EANX, "4512345678906", 0, 1, 95, "GS1 General Specifications 20.0 Figure 5.1-1 right",
"10101100010110011001001101111010011101011100101010101000010001001001000111010011100101010000101"
},
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
testUtilModulesDump(symbol, " ", "\n");
printf(" },\n");
} else {
if (ret < 5) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
if (ret == 0) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// #181 Christian Hartlage OSS-Fuzz
static void test_fuzz(int index, int debug) {
@ -326,6 +387,7 @@ int main(int argc, char *argv[]) {
{ "test_upca_print", test_upca_print, 1, 0, 1 },
{ "test_isbn", test_isbn, 1, 0, 1 },
{ "test_vector_same", test_vector_same, 1, 0, 1 },
{ "test_encode", test_encode, 1, 1, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
};

View File

@ -148,90 +148,109 @@ static void test_buffer_vector(int index, int generate, int debug) {
/* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310.0, 118.0 },
/* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 230.0, 118.0 },
/* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 230.0, 118.0 },
/* 10*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268.0, 118.0 },
/* 11*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204.0, 118.0 },
/* 12*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180.0, 118.0 },
/* 13*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270.0, 118.0 },
/* 14*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234.0, 118.0 },
/* 15*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 16*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 17*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254.0, 118.0 },
/* 18*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180.0, 100.0 },
/* 19*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192.0, 118.0 },
/* 20*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148.0, 118.0 },
/* 21*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268.0, 86.0 },
/* 22*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416.0, 118.0 },
/* 23*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230.0, 118.0 },
/* 24*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230.0, 118.0 },
/* 25*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142.0, 118.0 },
/* 26*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142.0, 118.0 },
/* 27*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370.0, 24.0 },
/* 28*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254.0, 118.0 },
/* 29*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34.0, 100.0 },
/* 30*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 207, 414.0, 118.0 },
/* 31*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116.0, 100.0 },
/* 32*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284.0, 118.0 },
/* 33*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58.0, 20.0 },
/* 34*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206.0, 42.0 },
/* 35*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136.0, 42.0 },
/* 36*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 74.0, 72.0 },
/* 37*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 },
/* 38*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290.0, 118.0 },
/* 39*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266.0, 16.0 },
/* 40*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 41*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 42*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 43*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230.0, 118.0 },
/* 44*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182.0, 16.0 },
/* 45*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20.0, 20.0 },
/* 46*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268.0, 118.0 },
/* 47*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492.0, 118.0 },
/* 48*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242.0, 44.0 },
/* 49*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312.0, 118.0 },
/* 50*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266.0, 16.0 },
/* 51*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334.0, 118.0 },
/* 52*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100.0, 26.0 },
/* 53*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100.0, 138.0 },
/* 54*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204.0, 142.0 },
/* 55*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370.0, 24.0 },
/* 56*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164.0, 24.0 },
/* 57*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258.0, 16.0 },
/* 58*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454.0, 118.0 },
/* 59*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256.0, 118.0 },
/* 60*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382.0, 150.0 },
/* 61*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174.0, 16.0 },
/* 62*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30.0, 30.0 },
/* 63*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62.0, 16.0 },
/* 64*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22.0, 22.0 },
/* 65*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268.0, 118.0 },
/* 66*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446.0, 118.0 },
/* 67*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24.0, 24.0 },
/* 68*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 },
/* 69*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206.0, 54.0 },
/* 70*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76.0, 68.0 },
/* 71*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242.0, 64.0 },
/* 72*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38.0, 38.0 },
/* 73*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32.0, 22.0 },
/* 74*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46.0, 46.0 },
/* 75*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310.0, 20.0 },
/* 76*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22.0, 22.0 },
/* 77*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206.0, 118.0 },
/* 78*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238.0, 118.0 },
/* 79*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290.0, 118.0 },
/* 80*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200.0, 60.0 },
/* 81*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148.0, 56.0 },
/* 82*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268.0, 100.0 },
/* 83*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238.0, 118.0 },
/* 84*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150.0, 118.0 },
/* 85*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112.0, 48.0 },
/* 86*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112.0, 160.0 },
/* 87*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204.0, 156.0 },
/* 88*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38.0, 118.0 },
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 },
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 },
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 },
/* 92*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36.0, 26.0 },
/* 93*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 },
/* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 124, 288.0, 118.0 },
/* 11*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 151, 342.0, 118.0 },
/* 12*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 134.0, 118.0 },
/* 13*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 96, 192.0, 118.0 },
/* 14*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 123, 246.0, 118.0 },
/* 15*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 94.0, 118.0 },
/* 16*/ { BARCODE_EANX, "12", "", 50, 1, 20, 40.0, 118.0 },
/* 17*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268.0, 118.0 },
/* 18*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204.0, 118.0 },
/* 19*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180.0, 118.0 },
/* 20*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270.0, 118.0 },
/* 21*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234.0, 118.0 },
/* 22*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 23*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162.0, 44.0 },
/* 24*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254.0, 118.0 },
/* 25*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180.0, 100.0 },
/* 26*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192.0, 118.0 },
/* 27*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148.0, 118.0 },
/* 28*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268.0, 86.0 },
/* 29*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416.0, 118.0 },
/* 30*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230.0, 118.0 },
/* 31*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230.0, 118.0 },
/* 32*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 288.0, 118.0 },
/* 33*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 342.0, 118.0 },
/* 34*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142.0, 118.0 },
/* 35*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142.0, 118.0 },
/* 36*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 80, 200.0, 118.0 },
/* 37*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 107, 254.0, 118.0 },
/* 38*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370.0, 24.0 },
/* 39*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254.0, 118.0 },
/* 40*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34.0, 100.0 },
/* 41*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382.0, 118.0 },
/* 42*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116.0, 100.0 },
/* 43*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284.0, 118.0 },
/* 44*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58.0, 20.0 },
/* 45*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206.0, 42.0 },
/* 46*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136.0, 42.0 },
/* 47*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 74.0, 72.0 },
/* 48*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 },
/* 49*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290.0, 118.0 },
/* 50*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266.0, 16.0 },
/* 51*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 52*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 53*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146.0, 16.0 },
/* 54*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230.0, 118.0 },
/* 55*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 124, 288.0, 118.0 },
/* 56*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 151, 342.0, 118.0 },
/* 57*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182.0, 16.0 },
/* 58*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20.0, 20.0 },
/* 59*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268.0, 118.0 },
/* 60*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492.0, 118.0 },
/* 61*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242.0, 44.0 },
/* 62*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312.0, 118.0 },
/* 63*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266.0, 16.0 },
/* 64*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334.0, 118.0 },
/* 65*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100.0, 26.0 },
/* 66*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100.0, 138.0 },
/* 67*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204.0, 142.0 },
/* 68*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370.0, 24.0 },
/* 69*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164.0, 24.0 },
/* 70*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258.0, 16.0 },
/* 71*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454.0, 118.0 },
/* 72*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256.0, 118.0 },
/* 73*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382.0, 150.0 },
/* 74*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174.0, 16.0 },
/* 75*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30.0, 30.0 },
/* 76*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62.0, 16.0 },
/* 77*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22.0, 22.0 },
/* 78*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268.0, 118.0 },
/* 79*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446.0, 118.0 },
/* 80*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24.0, 24.0 },
/* 81*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 },
/* 82*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206.0, 54.0 },
/* 83*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76.0, 68.0 },
/* 84*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242.0, 64.0 },
/* 85*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38.0, 38.0 },
/* 86*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32.0, 22.0 },
/* 87*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46.0, 46.0 },
/* 88*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310.0, 20.0 },
/* 89*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22.0, 22.0 },
/* 90*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206.0, 118.0 },
/* 91*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238.0, 118.0 },
/* 92*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 128, 296.0, 118.0 },
/* 93*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 155, 350.0, 118.0 },
/* 94*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290.0, 118.0 },
/* 95*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200.0, 60.0 },
/* 96*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148.0, 56.0 },
/* 97*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268.0, 100.0 },
/* 98*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238.0, 118.0 },
/* 99*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 296.0, 118.0 },
/*100*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 350.0, 118.0 },
/*101*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150.0, 118.0 },
/*102*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 84, 208.0, 118.0 },
/*103*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 111, 262.0, 118.0 },
/*104*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112.0, 48.0 },
/*105*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112.0, 160.0 },
/*106*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204.0, 156.0 },
/*107*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38.0, 118.0 },
/*108*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 },
/*109*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 },
/*110*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 },
/*111*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36.0, 26.0 },
/*112*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 },
};
int data_size = sizeof(data) / sizeof(struct item);
@ -283,6 +302,281 @@ static void test_buffer_vector(int index, int generate, int debug) {
testFinish();
}
static void test_upcean_hrt(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int show_hrt;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
float expected_vector_width;
float expected_vector_height;
float expected_string_x;
float expected_addon_string_x;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 230.0, 118.0, 10, -1 }, // EAN-13
/* 1*/ { BARCODE_EANX, 0, "123456789012", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, // EAN-13
/* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 230.0, 118.0, 10, -1 }, // EAN-13
/* 3*/ { BARCODE_EANX_CHK, 0, "1234567890128", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, // EAN-13
/* 4*/ { BARCODE_EANX, -1, "123456789012+12", 0, 50, 1, 124, 288.0, 118.0, 10, 70 }, // EAN-13 + EAN-2
/* 5*/ { BARCODE_EANX, 0, "123456789012+12", 0, 50, 1, 124, 288.0, 118.0, -1, -1 }, // EAN-13 + EAN-2
/* 6*/ { BARCODE_EANX, -1, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 70 }, // EAN-13 + EAN-5
/* 7*/ { BARCODE_EANX, 0, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, // EAN-13 + EAN-5
/* 8*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 70 }, // ISBNX + EAN-5
/* 9*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, // ISBNX + EAN-5
/* 10*/ { BARCODE_EANX, -1, "1234567", 0, 50, 1, 67, 134.0, 118.0, 34, -1 }, // EAN-8
/* 11*/ { BARCODE_EANX, 0, "1234567", 0, 50, 1, 67, 134.0, 118.0, -1, -1 }, // EAN-8
/* 12*/ { BARCODE_EANX, -1, "1234567+12", 0, 50, 1, 96, 192.0, 118.0, 34, 100 }, // EAN-8 + EAN-2
/* 13*/ { BARCODE_EANX, 0, "1234567+12", 0, 50, 1, 96, 192.0, 118.0, -1, -1 }, // EAN-8 + EAN-2
/* 14*/ { BARCODE_EANX, -1, "1234567+12345", 0, 50, 1, 123, 246.0, 118.0, 34, 100 }, // EAN-8 + EAN-5
/* 15*/ { BARCODE_EANX, 0, "1234567+12345", 0, 50, 1, 123, 246.0, 118.0, -1, -1 }, // EAN-8 + EAN-5
/* 16*/ { BARCODE_UPCA, -1, "12345678901", 0, 50, 1, 95, 230.0, 118.0, 10, -1 },
/* 17*/ { BARCODE_UPCA, 0, "12345678901", 0, 50, 1, 95, 230.0, 118.0, -1, -1 },
/* 18*/ { BARCODE_UPCA, -1, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, 10, 74 },
/* 19*/ { BARCODE_UPCA, 0, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, -1, -1 },
/* 20*/ { BARCODE_UPCA_CHK, -1, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 74 },
/* 21*/ { BARCODE_UPCA_CHK, 0, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 },
/* 22*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 142.0, 118.0, 10, -1 },
/* 23*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 142.0, 118.0, -1, -1 },
/* 24*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 80, 200.0, 118.0, 10, 68 },
/* 25*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 80, 200.0, 118.0, -1, -1 },
/* 26*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 107, 254.0, 118.0, 10, 68 },
/* 27*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 107, 254.0, 118.0, -1, -1 },
};
int data_size = sizeof(data) / sizeof(struct item);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->symbology = data[i].symbology;
if (data[i].show_hrt != -1) {
symbol->show_hrt = data[i].show_hrt;
}
symbol->debug |= debug;
int length = strlen(data[i].data);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%s) symbol->width %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width);
if (data[i].show_hrt) {
assert_nonnull(symbol->vector->strings, "i:%d ZBarcode_Buffer_Vector(%d) vector->strings NULL\n", i, data[i].symbology);
assert_equal(symbol->vector->strings->x, data[i].expected_string_x,
"i:%d (%s) symbol->vector->strings->x %f != %f\n", i, testUtilBarcodeName(data[i].symbology), symbol->vector->strings->x, data[i].expected_string_x);
if (data[i].expected_addon_string_x != -1) {
assert_nonnull(symbol->vector->strings->next, "i:%d ZBarcode_Buffer_Vector(%d) vector->strings->next NULL\n", i, data[i].symbology);
assert_equal(symbol->vector->strings->next->x, data[i].expected_addon_string_x,
"i:%d (%s) symbol->vector->strings->next->x %f != %f\n", i, testUtilBarcodeName(data[i].symbology), symbol->vector->strings->next->x, data[i].expected_addon_string_x);
}
} else {
assert_null(symbol->vector->strings, "i:%d ZBarcode_Buffer_Vector(%d) vector->strings NULL\n", i, data[i].symbology);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_row_separator(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_1;
int option_3;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
int expected_separator_row;
int expected_separator_col;
int expected_separator_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, "A", 0, 20, 2, 101, 21, 42, 2 },
/* 1*/ { BARCODE_CODABLOCKF, -1, 0, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, -1, 1, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 3*/ { BARCODE_CODABLOCKF, -1, 2, "A", 0, 20, 2, 101, 20, 42, 4 },
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, "A", 0, 20, 2, 101, 19, 42, 6 },
/* 5*/ { BARCODE_CODABLOCKF, -1, 4, "A", 0, 20, 2, 101, 18, 42, 8 },
/* 6*/ { BARCODE_CODABLOCKF, -1, 5, "A", 0, 20, 2, 101, 21, 42, 2 }, // > 4 ignored, same as default
/* 7*/ { BARCODE_CODABLOCKF, 1, -1, "A", 0, 5, 1, 46, 0, 20, 2 }, // CODE128 top separator
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
rect = find_rect(symbol, data[i].expected_separator_col, data[i].expected_separator_row, data[i].expected_separator_height, 0);
assert_nonnull(rect, "i:%d (%d) find_rect(%d, %d, %d) NULL\n", i, data[i].symbology, data[i].expected_separator_col, data[i].expected_separator_row, data[i].expected_separator_height);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_output_options(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int whitespace_width;
int border_width;
int output_options;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
float expected_vector_width;
float expected_vector_height;
int expected_set;
int expected_set_row;
int expected_set_col;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 0, 4 },
/* 1*/ { BARCODE_CODE128, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 0, 4 },
/* 2*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126, 1, 0, 4 },
/* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126, 0, 4, 4 },
/* 4*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 166, 126, 1, 4, 4 },
/* 5*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118, 0, 6, 8 },
/* 6*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134, 1, 6, 8 },
/* 7*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134, 0, 14, 8 },
/* 8*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 186, 134, 1, 14, 8 },
/* 9*/ { BARCODE_CODE128, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
/* 10*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 },
/* 11*/ { BARCODE_QRCODE, -1, 3, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 },
/* 12*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 1, 0, 6 },
/* 13*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 22, 6 },
/* 14*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 22, 6 },
/* 15*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 10, 12 },
/* 16*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 10, 12 },
/* 17*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 22, 12 },
/* 18*/ { BARCODE_QRCODE, 5, 6, BARCODE_BOX, "A123", 0, 21, 21, 21, 86, 66, 1, 22, 12 },
/* 19*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 },
/* 20*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 },
/* 21*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 1, 0, 50 },
/* 22*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 0, 54, 0 },
/* 23*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 62, 58, 1, 54, 0 },
/* 24*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 74, 72, 0, 0, 82 },
/* 25*/ { BARCODE_MAXICODE, -1, 5, -1, "A123", 0, 165, 33, 30, 74, 72, 0, 0, 82 },
/* 26*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 74, 92, 1, 0, 82 },
/* 27*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 74, 92, 0, 84, 0 },
/* 28*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 94, 92, 1, 84, 0 },
/* 29*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 74, 72, 0, 0, 82 },
/* 30*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 98, 92, 1, 0, 82 },
/* 31*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 98, 92, 0, 108, 0 },
/* 32*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 118, 92, 1, 108, 0 },
/* 33*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data[i].data, -1, debug);
if (data[i].whitespace_width != -1) {
symbol->whitespace_width = data[i].whitespace_width;
}
if (data[i].border_width != -1) {
symbol->border_width = data[i].border_width;
}
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != %d\n", i, data[i].symbology, ret, data[i].ret);
if (ret < 5) {
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
if (index != -1) {
sprintf(symbol->outfile, "test_output_options_%d.svg", i);
ZBarcode_Print(symbol, 0);
}
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->vector->width, data[i].expected_vector_width, "i:%d (%s) symbol->vector->width %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->width, data[i].expected_vector_width);
assert_equal(symbol->vector->height, data[i].expected_vector_height, "i:%d (%s) symbol->vector->height %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->height, data[i].expected_vector_height);
if (data[i].expected_set != -1) {
rect = find_rect(symbol, data[i].expected_set_row, data[i].expected_set_col, 0, 0);
if (data[i].expected_set) {
assert_nonnull(rect, "i:%d (%d) find_rect(%d, %d, 0, 0) NULL\n", i, data[i].symbology, data[i].expected_set_row, data[i].expected_set_col);
} else {
assert_null(rect, "i:%d (%d) find_rect(%d, %d, 0, 0) not NULL\n", i, data[i].symbology, data[i].expected_set_row, data[i].expected_set_col);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// Checks that symbol lead-in (composite offset) isn't used to calc string position for non-composite barcodes
static void test_noncomposite_string_x(int index, int debug) {
@ -402,149 +696,16 @@ static void test_upcean_whitespace_width(int index, int debug) {
testFinish();
}
static void test_row_separator(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int option_1;
int option_3;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
int expected_separator_row;
int expected_separator_col;
int expected_separator_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, "A", 0, 20, 2, 101, 21, 42, 2 },
/* 1*/ { BARCODE_CODABLOCKF, -1, 0, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 2*/ { BARCODE_CODABLOCKF, -1, 1, "A", 0, 20, 2, 101, 21, 42, 2 }, // Same as default
/* 3*/ { BARCODE_CODABLOCKF, -1, 2, "A", 0, 20, 2, 101, 20, 42, 4 },
/* 4*/ { BARCODE_CODABLOCKF, -1, 3, "A", 0, 20, 2, 101, 19, 42, 6 },
/* 5*/ { BARCODE_CODABLOCKF, -1, 4, "A", 0, 20, 2, 101, 18, 42, 8 },
/* 6*/ { BARCODE_CODABLOCKF, -1, 5, "A", 0, 20, 2, 101, 21, 42, 2 }, // > 4 ignored, same as default
/* 7*/ { BARCODE_CODABLOCKF, 1, -1, "A", 0, 5, 1, 46, 0, 20, 2 }, // CODE128 top separator
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, -1, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
rect = find_rect(symbol, data[i].expected_separator_col, data[i].expected_separator_row, data[i].expected_separator_height, 0);
assert_nonnull(rect, "i:%d (%d) find_rect(%d, %d, %d) NULL\n", i, data[i].symbology, data[i].expected_separator_col, data[i].expected_separator_row, data[i].expected_separator_height);
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_border_whitespace(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int whitespace_width;
int border_width;
int output_options;
unsigned char *data;
int ret;
int expected_height;
int expected_rows;
int expected_width;
float expected_vector_width;
float expected_vector_height;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118 },
/* 1*/ { BARCODE_CODE128, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118 },
/* 2*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 118 },
/* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 158, 118 },
/* 4*/ { BARCODE_CODE128, 3, -1, -1, "A123", 0, 50, 1, 79, 170, 118 },
/* 5*/ { BARCODE_CODE128, 3, 4, -1, "A123", 0, 50, 1, 79, 170, 118 },
/* 6*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 118 },
/* 7*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 170, 118 },
};
int data_size = ARRAY_SIZE(data);
struct zint_vector_rect *rect;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
if (data[i].whitespace_width != -1) {
symbol->whitespace_width = data[i].whitespace_width;
}
if (data[i].border_width != -1) {
symbol->border_width = data[i].border_width;
}
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height);
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
assert_equal(symbol->vector->width, data[i].expected_vector_width, "i:%d (%s) symbol->vector->width %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->width, data[i].expected_vector_width);
assert_equal(symbol->vector->height, data[i].expected_vector_height, "i:%d (%s) symbol->vector->height %f != %f\n",
i, testUtilBarcodeName(data[i].symbology), symbol->vector->height, data[i].expected_vector_height);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
{ "test_options", test_options, 1, 0, 1 },
{ "test_buffer_vector", test_buffer_vector, 1, 1, 1 },
{ "test_upcean_hrt", test_upcean_hrt, 1, 0, 1 },
{ "test_row_separator", test_row_separator, 1, 0, 1 },
{ "test_output_options", test_output_options, 1, 0, 1 },
{ "test_noncomposite_string_x", test_noncomposite_string_x, 1, 0, 1 },
{ "test_upcean_whitespace_width", test_upcean_whitespace_width, 1, 0, 1 },
{ "test_row_separator", test_row_separator, 1, 0, 1 },
{ "test_border_whitespace", test_border_whitespace, 1, 0, 1 },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));

View File

@ -624,6 +624,10 @@ void testUtilStrCpyRepeat(char *buffer, char *repeat, int size) {
int i;
int len = strlen(repeat);
int max = size - len;
if (len == 0) {
fprintf(stderr, "testUtilStrCpyRepeat: only use non-empty, non-NUL single-byte data for repeat pattern\n");
abort();
}
for (i = 0; i < max; i += len) {
memcpy(buffer + i, repeat, len);
}

View File

@ -37,7 +37,6 @@
#define TESTCOMMON_H
#include <stdio.h>
#include <string.h>
#include "../common.h"
#ifndef ARRAY_SIZE

View File

@ -33,8 +33,8 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include "common.h"
#include "tif.h"
#ifdef _MSC_VER
@ -76,6 +76,9 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
rows_per_strip = 1;
}
/* Suppresses clang-tidy clang-analyzer-core.VLASize warning */
assert(symbol->bitmap_height > 0);
strip_count = symbol->bitmap_height / rows_per_strip;
if ((symbol->bitmap_height % rows_per_strip) != 0) {
strip_count++;
@ -90,7 +93,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
}
#ifndef _MSC_VER
uint32_t strip_offset[strip_count]; // NOLINT(clang-analyzer-core.VLASize) strip_count >= 1
uint32_t strip_offset[strip_count];
uint32_t strip_bytes[strip_count];
#else
strip_offset = (uint32_t*) _alloca(strip_count * sizeof(uint32_t));

View File

@ -36,7 +36,6 @@
#include <malloc.h>
#endif
#include <stdio.h>
#include <string.h>
#include "common.h"
#define EIGHTBIT_MODE 10
@ -287,7 +286,7 @@ static float look_ahead_ascii(unsigned char source[], int in_length, int in_locn
do {
/* Check for double digits */
done = 0;
if (in_locn != (in_length - 1)) {
if (i + 1 < in_length) {
first_digit = posn(ultra_digit, source[i]);
second_digit = posn(ultra_digit, source[i + 1]);
if ((first_digit != -1) && (second_digit != -1)) {
@ -506,7 +505,7 @@ static float look_ahead_c43(unsigned char source[], int in_length, int in_locn,
}
unshift_set = subset;
do {
while ((sublocn < in_length) && (sublocn < end_char)) {
/* Check for FNC1 */
if (gs1 && source[sublocn] == '[') {
break;
@ -572,8 +571,7 @@ static float look_ahead_c43(unsigned char source[], int in_length, int in_locn,
}
subset = unshift_set;
}
} while ((sublocn < in_length) && (sublocn < end_char));
}
pad = 3 - (subcodeword_count % 3);
if (pad == 3) {
@ -1109,7 +1107,7 @@ INTERNAL int ultracode(struct zint_symbol *symbol, const unsigned char source[],
for (i = 0; i < total_height; i++) {
symbol->row_height[i] = 1;
for(j = 0; j < total_width; j++) {
symbol->encoded_data[i][j] = posn(ultra_colour, pattern[(i * total_width) + j]);
set_module_colour(symbol, i, j, posn(ultra_colour, pattern[(i * total_width) + j]));
}
}

View File

@ -34,17 +34,19 @@ namespace Zint {
m_securityLevel = -1;
m_fgColor = Qt::black;
m_bgColor = Qt::white;
m_zintSymbol = 0;
m_zintSymbol = NULL;
m_error = 0;
m_input_mode = UNICODE_MODE + ESCAPE_MODE;
m_input_mode = UNICODE_MODE;
m_scale = 1.0;
m_option_3 = 0;
m_hidetext = 0;
m_dot_size = 4.0 / 5.0;
target_size_horiz = 0;
target_size_vert = 0;
m_width = 0;
m_option_2 = 0;
m_whitespace = 0;
m_gssep = false;
m_debug = false;
}
QZint::~QZint() {
@ -52,20 +54,20 @@ namespace Zint {
ZBarcode_Delete(m_zintSymbol);
}
void QZint::encode() {
void QZint::resetSymbol() {
if (m_zintSymbol)
ZBarcode_Delete(m_zintSymbol);
m_lastError.clear();
m_zintSymbol = ZBarcode_Create();
m_zintSymbol->output_options = m_border;
m_zintSymbol->output_options |= m_border;
m_zintSymbol->symbology = m_symbol;
m_zintSymbol->height = m_height;
m_zintSymbol->whitespace_width = m_whitespace;
m_zintSymbol->border_width = m_borderWidth;
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
m_zintSymbol->option_2 = m_option_2;
m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
@ -73,13 +75,27 @@ namespace Zint {
m_zintSymbol->show_hrt = 1;
}
m_zintSymbol->option_3 = m_option_3;
m_zintSymbol->scale = m_scale;
if (m_gssep) {
m_zintSymbol->output_options |= GS1_GS_SEPARATOR;
}
if (m_debug) {
m_zintSymbol->debug |= ZINT_DEBUG_PRINT;
}
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6));
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127));
}
void QZint::encode() {
resetSymbol();
QByteArray bstr = m_text.toUtf8();
QByteArray pstr = m_primaryMessage.left(99).toLatin1();
strcpy(m_zintSymbol->primary, pstr.data());
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
m_lastError = m_zintSymbol->errtxt;
switch (m_zintSymbol->output_options) {
switch (m_zintSymbol->output_options & (BARCODE_BIND | BARCODE_BOX)) {
case 0: m_border = NO_BORDER;
break;
case 2: m_border = BIND;
@ -99,6 +115,10 @@ namespace Zint {
m_symbol = symbol;
}
int QZint::inputMode() const {
return m_input_mode;
}
void QZint::setInputMode(int input_mode) {
m_input_mode = input_mode;
}
@ -111,11 +131,6 @@ namespace Zint {
m_text = text;
}
void QZint::setTargetSize(int width, int height) {
target_size_horiz = width;
target_size_vert = height;
}
QString QZint::primaryMessage() const {
return m_primaryMessage;
}
@ -124,12 +139,20 @@ namespace Zint {
m_primaryMessage = primaryMessage;
}
int QZint::height() const {
return m_height;
}
void QZint::setHeight(int height) {
m_height = height;
}
void QZint::setWidth(int width) {
m_width = width;
int QZint::option2() const {
return m_option_2;
}
void QZint::setOption2(int option) {
m_option_2 = option;
}
void QZint::setOption3(int option) {
@ -194,14 +217,6 @@ namespace Zint {
m_securityLevel = securityLevel;
}
int QZint::getError() {
return m_error;
}
QString QZint::error_message() const {
return m_lastError;
}
int QZint::mode() const {
return m_securityLevel;
}
@ -214,40 +229,39 @@ namespace Zint {
m_hidetext = hide;
}
void QZint::setTargetSize(int width, int height) {
target_size_horiz = width;
target_size_vert = height;
}
void QZint::setGSSep(bool gssep) {
m_gssep = gssep;
}
void QZint::setDebug(bool debug) {
m_debug = debug;
}
int QZint::getError() const {
return m_error;
}
QString QZint::error_message() const {
return m_lastError;
}
const QString & QZint::lastError() const {
return m_lastError;
}
bool QZint::hasErrors() const {
return m_lastError.length();
}
bool QZint::save_to_file(QString filename) {
if (m_zintSymbol)
ZBarcode_Delete(m_zintSymbol);
QString fg_colour_hash = m_fgColor.name();
QString bg_colour_hash = m_bgColor.name();
m_lastError.clear();
m_zintSymbol = ZBarcode_Create();
m_zintSymbol->output_options = m_border;
m_zintSymbol->symbology = m_symbol;
m_zintSymbol->height = m_height;
m_zintSymbol->whitespace_width = m_whitespace;
m_zintSymbol->border_width = m_borderWidth;
m_zintSymbol->option_1 = m_securityLevel;
m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2 = m_width;
m_zintSymbol->dot_size = m_dot_size;
if (m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
m_zintSymbol->show_hrt = 1;
}
m_zintSymbol->option_3 = m_option_3;
m_zintSymbol->scale = m_scale;
resetSymbol();
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
QByteArray bstr = m_text.toUtf8();
QByteArray pstr = m_primaryMessage.left(99).toLatin1();
QByteArray fstr = filename.left(255).toLatin1();
strcpy(m_zintSymbol->primary, pstr.data());
strcpy(m_zintSymbol->outfile, fstr.data());
QByteArray fgcol = fg_colour_hash.right(6).toLatin1();
QByteArray bgcol = bg_colour_hash.right(6).toLatin1();
strcpy(m_zintSymbol->fgcolour, fgcol.data());
strcpy(m_zintSymbol->bgcolour, bgcol.data());
m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
if (m_error >= 5) {
m_lastError = m_zintSymbol->errtxt;
@ -404,14 +418,4 @@ namespace Zint {
painter.restore();
}
const QString & QZint::lastError() const {
return m_lastError;
}
bool QZint::hasErrors() {
return m_lastError.length();
}
}

View File

@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/* vim: set ts=4 sw=4 et : */
#ifndef BARCODERENDER_H
#define BARCODERENDER_H
@ -29,98 +30,105 @@ class QZint
private:
public:
enum BorderType{NO_BORDER=0, BIND=2, BOX=4};
enum AspectRatioMode{IgnoreAspectRatio=0, KeepAspectRatio=1, CenterBarCode=2};
enum BorderType{NO_BORDER=0, BIND=2, BOX=4};
enum AspectRatioMode{IgnoreAspectRatio=0, KeepAspectRatio=1, CenterBarCode=2};
public:
QZint();
~QZint();
QZint();
~QZint();
int symbol() const;
void setSymbol(int symbol);
void setSymbol(int symbol);
int inputMode() const;
void setInputMode(int input_mode);
QString text() const;
void setText(const QString & text);
void setText(const QString & text);
QString primaryMessage() const;
void setPrimaryMessage(const QString & primaryMessage);
void setPrimaryMessage(const QString & primaryMessage);
void setHeight(int height);
int height();
int height() const;
void setHeight(int height);
void setWidth(int width);
int width();
int option2() const;
void setOption2(int option);
void setOption3(int option);
QColor fgColor() const;
void setFgColor(const QColor & fgColor);
QColor bgColor() const;
void setBgColor(const QColor & bgColor);
BorderType borderType() const;
void setBorderType(BorderType border);
int borderWidth() const;
void setBorderWidth(int boderWidth);
int securityLevel() const;
void setSecurityLevel(int securityLevel);
int getError();
void setOption3(int option);
float scale() const;
void setScale(float scale);
void setScale(float scale);
void setDotSize(float dot_size);
void setDotSize(float dot_size);
QColor fgColor() const;
void setFgColor(const QColor & fgColor);
QColor bgColor() const;
void setBgColor(const QColor & bgColor);
BorderType borderType() const;
void setBorderType(BorderType border);
int borderWidth() const;
void setBorderWidth(int boderWidth);
int securityLevel() const;
void setSecurityLevel(int securityLevel);
int mode() const;
void setMode(int securityLevel);
void setMode(int securityLevel);
void setInputMode(int input_mode);
void setWhitespace(int whitespace);
void setWhitespace(int whitespace);
void setHideText(bool hide);
void setTargetSize(int width, int height);
void setGSSep(bool gssep);
void setDebug(bool debug);
int getError() const;
QString error_message() const;
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio);
const QString & lastError() const;
bool hasErrors();
bool hasErrors() const;
bool save_to_file(QString filename);
bool save_to_file(QString filename);
void setHideText(bool hide);
void setTargetSize(int width, int height);
void render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode=IgnoreAspectRatio);
private:
void encode();
int module_set(int y_coord, int x_coord) const;
void resetSymbol();
void encode();
private:
int m_symbol;
QString m_text;
QString m_primaryMessage;
int m_height;
BorderType m_border;
int m_borderWidth;
int m_width;
int m_securityLevel;
int m_input_mode;
QColor m_fgColor;
QColor m_bgColor;
QString m_lastError;
int m_error;
int m_whitespace;
zint_symbol * m_zintSymbol;
float m_scale;
int m_option_3;
bool m_hidetext;
int m_symbol;
QString m_text;
QString m_primaryMessage;
int m_height;
BorderType m_border;
int m_borderWidth;
int m_option_2;
int m_securityLevel;
int m_input_mode;
QColor m_fgColor;
QColor m_bgColor;
QString m_lastError;
int m_error;
int m_whitespace;
zint_symbol * m_zintSymbol;
float m_scale;
int m_option_3;
bool m_hidetext;
float m_dot_size;
int target_size_horiz;
int target_size_vert;
bool m_gssep;
bool m_debug;
};
}
#endif

View File

@ -61,7 +61,7 @@ composite: A composite symbology is one which is made up of elements which are
based on the PDF417 symbology. These symbols also have a separator
which separates the linear and the stacked components.
GS-1 data: This is a structured way of representing information which consists
GS1 data: This is a structured way of representing information which consists
of "chunks" of data, each of which starts with an Application
Identifier. The AI identifies what type of information is being
encoded.
@ -269,7 +269,7 @@ Numeric Value | Barcode Name
28 | Flattermarken
29 | GS1 DataBar-14
30 | GS1 DataBar Limited
31 | GS1 DataBar Extended
31 | GS1 DataBar Expanded
32 | Telepen Alpha
34 | UPC A
35 | UPC A + Check Digit
@ -329,7 +329,7 @@ Numeric Value | Barcode Name
131 | Composite Symbol with GS1-128 linear component
132 | Composite Symbol with GS1 DataBar-14 linear component
133 | Composite Symbol with GS1 DataBar Limited component
134 | Composite Symbol with GS1 DataBar Extended component
134 | Composite Symbol with GS1 DataBar Expanded component
135 | Composite Symbol with UPC A linear component
136 | Composite Symbol with UPC E linear component
137 | Composite Symbol with GS1 DataBar-14 Stacked component
@ -1001,7 +1001,7 @@ Value |
28 | BARCODE_FLAT | Flattermarken
29 | BARCODE_RSS14 | GS1 DataBar-14
30 | BARCODE_RSS_LTD | GS1 DataBar Limited
31 | BARCODE_RSS_EXP | GS1 DataBar Extended
31 | BARCODE_RSS_EXP | GS1 DataBar Expanded
32 | BARCODE_TELEPEN | Telepen Alpha
34 | BARCODE_UPCA | UPC A
35 | BARCODE_UPCA_CHK | UPC A + Check Digit
@ -1027,7 +1027,7 @@ Value |
70 | BARCODE_RM4SCC | Royal Mail 4 State (RM4SCC)
71 | BARCODE_DATAMATRIX | Data Matrix (ECC200)
72 | BARCODE_EAN14 | EAN-14
73 | BARCODE_VIN | Vehicle Identification Number (America)
73 | BARCODE_VIN | Vehicle Identification Number
74 | BARCODE_CODABLOCKF | Codablock-F
75 | BARCODE_NVE18 | NVE-18
76 | BARCODE_JAPANPOST | Japanese Postal Code
@ -1065,7 +1065,7 @@ Value |
| | component
133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited
| | component
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Extended
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded
| | component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC A linear component
136 | BARCODE_UPCE_CC | Composite Symbol with UPC E linear component
@ -1168,8 +1168,9 @@ They consist of a number of bars and a number of spaces of differing widths.
-------------
Developed by Intermec in 1977, Code 11 is similar to Code 2 of 5 Matrix and is
primarily used in telecommunications. The symbol can encode any length string
consisting of the digits 0-9 and the dash character (-). One modulo-11 check
digit is calculated.
consisting of the digits 0-9 and the dash character (-). Two modulo-11 check
digits are added by default. To add just one check digit, set option_2 = 1 or
--vers=1. To add no check digits, set option_2 = 2 or --vers=2.
6.1.2 Code 2 of 5
-----------------
@ -1314,7 +1315,7 @@ Ltd. in the UK. The symbol can encode any length data consisting of digits
-----------------
Based on Plessey and developed by MSE Data Corporation, MSI Plessey is
available with a range of check digit options available by setting option_2 or
by using the --ver= switch. Any length numeric (digits 0-9) input can be
by using the --vers= switch. Any length numeric (digits 0-9) input can be
encoded. The table below shows the options available:
-------------------------------------------
@ -1350,32 +1351,32 @@ Standard Code 39 was developed in 1974 by Intermec. Input data can be of any
length and can include the characters 0-9, A-Z, dash (-), full stop (.), space,
asterisk (*), dollar ($), slash (/), plus (+) and percent (%). The standard
does not require a check digit but a modulo-43 check digit can be added if
required by setting option_2 = 1 or using --ver=1.
required by setting option_2 = 1 or using --vers=1.
6.1.8.2 Extended Code 39
------------------------
Also known as Code 39e and Code39+, this symbology expands on Standard Code 39
to provide support to the full ASCII character set. The standard does not
require a check digit but a modulo-43 check digit can be added if required by
setting option_2 = 1 or using --ver=1.
setting option_2 = 1 or using --vers=1.
6.1.8.3 Code 93
---------------
A variation of Extended Code 39, Code 93 also supports full ASCII text. Two
check digits are added by Zint.
6.1.8.4 PZN
-----------
PZN is a Code 39 based symbology used by the pharmaceutical industry in
Germany. PZN encodes a 6 digit number to which Zint will add a modulo-10
check digit.
6.1.8.4 PZN (Pharmazentralnummer)
---------------------------------
PZN is a Code 39 based symbology used by the pharmaceutical industry in Germany.
PZN encodes a 7 digit number to which Zint will add a modulo-11 check digit.
6.1.8.5 LOGMARS
---------------
LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) is a
variation of the Code 39 symbology used by the US Department of Defence.
LOGMARS encodes the same character set as Standard Code 39 and adds a modulo-43
check digit.
LOGMARS encodes the same character set as Standard Code 39. It does not require
a check digit but a modulo-43 check digit can be added by setting option_2 = 1
or using --vers=1.
6.1.8.6 Code 32
---------------
@ -1392,9 +1393,10 @@ standards.
6.1.8.8 Vehicle Identification Number (VIN)
-------------------------------------------
This option includes a verification stage for vehicle identification numbers
used in North America which include a check digit. For European vehicle
identification numbers use Standard Code 39.
A variation of Code 39 that for vehicle identification numbers used in North
America (first character '1' to '5') has a check character verification stage.
An Import character prefix 'I' can be added by setting option_2 = 1 or using
--vers=1.
6.1.9 Codabar (EN 798)
----------------------
@ -1404,7 +1406,8 @@ purposes. The American Blood Commission adopted Codabar in 1977 as the standard
symbology for blood identification. Codabar can encode any length string
starting and ending with the letters A-D and containing between these letters
the numbers 0-9, dash (-), dollar ($), colon (:), slash (/), full stop (.) or
plus (+). No check digit is generated.
plus (+). No check digit is generated by default, but a modulo-16 one can be
added by setting option_2 = 1 or using --vers=1.
6.1.10 Pharmacode
-----------------
@ -1508,10 +1511,10 @@ check digit.
-------------------
A highly compressed symbol for numeric data. The number of channels in the
symbol can be between 3 and 8 and this can be specified by setting the value of
option_2. It can also be determined by the length of the input data e.g. a
three character input string generates a 4 channel code by default. The maximum
values permitted depend on the number of channels used as shown in the table
below:
option_2 or using the --vers= option. It can also be determined by the length of
the input data e.g. a three character input string generates a 4 channel code by
default. The maximum values permitted depend on the number of channels used as
shown in the table below:
--------------------------------------------
Channels | Minimum Value | Maximum Value
@ -1662,7 +1665,7 @@ Value |
| | component
133 | BARCODE_RSS_LTD_CC | Composite Symbol with GS1 DataBar Limited
| | component
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Extended
134 | BARCODE_RSS_EXP_CC | Composite Symbol with GS1 DataBar Expanded
| | component
135 | BARCODE_UPCA_CC | Composite Symbol with UPC A linear component
136 | BARCODE_UPCE_CC | Composite Symbol with UPC E linear component
@ -2028,8 +2031,8 @@ using the --fullmultibyte switch or by setting option_3 to ZINT_FULL_MULTIBYTE.
6.6.4 Rectangular Micro QR Code (rMQR)
--------------------------------------
A rectangular version of QR Code. Like QR code rMQR supports encoding of
GS-1 data, Latin-1 and Kanji characters in the Shift-JIS encoding scheme.
A rectangular version of QR Code. Like QR code rMQR supports encoding of GS1
data, Latin-1 and Kanji characters in the Shift-JIS encoding scheme.
It does not support other ISO 8859 character sets or Unicode. As with other
symbologies data should be entered as UTF-8 with the conversion to Shift-JIS
being handled by Zint. The amount of ECC codewords can be adjusted using
@ -2174,7 +2177,7 @@ size dependent on the length of the data to be encoded. Error correction
codewords will normally be generated to fill at least 23% of the symbol. Two
options are available to change this behaviour:
The size of the symbol can be specified using the --ver= option or setting
The size of the symbol can be specified using the --vers= option or setting
option_2 to a value between 1 and 36 according to the following table. The
symbols marked with an asterisk (*) in the table below are "compact" symbols,
meaning they have a smaller bulls-eye pattern at the centre of the symbol.
@ -2288,7 +2291,7 @@ should be entered as Unicode (UTF-8) with conversion to GB 2312 being carried
out automatically by Zint. The symbology also supports the ECI mechanism. The
size of the symbol and the error correction capacity can be specified. If you
specify both of these values then Zint will make a 'best-fit' attempt to
satisfy both conditions. The symbol size can be specified using the --ver=
satisfy both conditions. The symbol size can be specified using the --vers=
option or by setting option_2, and the error correction capacity can be
specified by using the --secure= option or by setting option_1 according to
the following tables:
@ -2329,7 +2332,7 @@ supports this before using.
-------------
DotCode uses a grid of dots in a rectangular formation to encode characters up
to a maximum of approximately 450 characters (or 900 numeric digits). The
symbology supports ECI encoding and GS-1 data encoding. By default Zint will
symbology supports ECI encoding and GS1 data encoding. By default Zint will
produce a symbol which is approximately square, however the width of the symbol
can be adjusted by using the --cols= option or by setting option_2. Outputting
DotCode to raster images (PNG, GIF, BMP, PCX) will require setting the scale of
@ -2343,9 +2346,9 @@ Also known as Chinese Sensible Code, Han Xin is a symbology which is still under
development, so it is recommended it should not yet be used for a production
environment. The symbology is capable of encoding characters in the GB18030
character set (up to 4-byte characters) and is also able to support the ECI
mechanism. Support for the encoding of GS-1 data has not yet been implemented.
mechanism. Support for the encoding of GS1 data has not yet been implemented.
The size of the symbol can be specified using the --ver= option or setting
The size of the symbol can be specified using the --vers= option or setting
option_2 to a value between 1 and 84 according to the following table.
---------------------
@ -2456,7 +2459,7 @@ supports this before using.
6.6.13 Ultracode
----------------
This symbology uses a grid of coloured elements to encode data. ECI and GS-1
This symbology uses a grid of coloured elements to encode data. ECI and GS1
modes are supported. The amount of error correction can be set using the
--secure= option or by setting option_1 to a value as shown in the following
table:

View File

@ -77,7 +77,7 @@ static void types(void) {
static void usage(void) {
printf( "Zint version %d.%d.%d\n"
"Encode input data in a barcode and save as BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n\n"
" -b, --barcode=NUMBER Number of barcode type (default is 20 (=Code128)).\n"
" -b, --barcode=NUMBER Number of barcode type. Default is 20 (Code 128)\n"
" --batch Treat each line of input file as a separate data set\n"
" --bg=COLOUR Specify a background colour (in hex)\n"
" --binary Treat input as raw binary data\n"
@ -108,7 +108,7 @@ static void usage(void) {
" --mirror Use batch data to determine filename\n"
" --mode=NUMBER Set encoding mode (Maxicode/Composite)\n"
" --notext Remove human readable text\n"
" -o, --output=FILE Send output to FILE. (default is out.png)\n"
" -o, --output=FILE Send output to FILE. Default is out.png\n"
" --primary=STRING Set structured primary message (Maxicode/Composite)\n"
" --scale=NUMBER Adjust size of X-dimension\n"
" --secure=NUMBER Set error correction level\n"
@ -119,7 +119,7 @@ static void usage(void) {
" --rotate=NUMBER Rotate symbol by NUMBER degrees (BMP/GIF/PCX/PNG/TIF)\n"
" --rows=NUMBER Set number of rows (Codablock-F)\n"
" -t, --types Display table of barcode types\n"
" --vers=NUMBER Set symbol version (QR Code/Han Xin)\n"
" --vers=NUMBER Set symbol version (size, check digits, other options)\n"
" -w, --whitesp=NUMBER Set width of whitespace in multiples of X-dimension\n"
, ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
}

View File

@ -8,10 +8,11 @@ set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequen
QT5_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
QT5_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
# grpAztec.ui grpC39.ui grpDM.ui grpMSICheck.ui
# grpC128.ui grpChannel.ui grpMicroPDF.ui grpPDF417.ui
# grpC16k.ui grpCodablock.ui grpMQR.ui grpQR.ui
# grpMaxicode.ui)
# grpAztec.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpVIN.ui
# grpC11.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpPZN.ui
# grpC128.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpQR.ui
# grpC16k.ui grpCodablockF.ui grpGrid.ui grpMQR.ui grpRMQR.ui
# grpC39.ui grpCodeOne.ui grpHX.ui grpMSICheck.ui grpUltra.ui
QT5_ADD_RESOURCES(zint-qt_SRCS resources.qrc)

View File

@ -18,17 +18,20 @@ FORMS += extData.ui \
extExport.ui \
extSequence.ui \
grpAztec.ui \
grpC11.ui \
grpC128.ui \
grpC16k.ui \
grpC39.ui \
grpC49.ui \
grpChannel.ui \
grpCodabar.ui \
grpCodeOne.ui \
grpCodablockF.ui \
grpDBExtend.ui \
grpDM.ui \
grpGrid.ui \
grpHX.ui \
grpLOGMARS.ui \
grpMaxicode.ui \
grpMicroPDF.ui \
grpMQR.ui \
@ -36,6 +39,7 @@ FORMS += extData.ui \
grpPDF417.ui \
grpQR.ui \
grpRMQR.ui \
grpVIN.ui \
mainWindow.ui \
grpDotCode.ui

View File

@ -10,6 +10,12 @@
<height>237</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -19,7 +25,7 @@
<item row="0" column="0">
<widget class="QRadioButton" name="radAztecAuto">
<property name="text">
<string>A&amp;utomatic Resizing</string>
<string>Automatic Resizing</string>
</property>
<property name="checked">
<bool>true</bool>
@ -29,7 +35,7 @@
<item row="1" column="0">
<widget class="QRadioButton" name="radAztecSize">
<property name="text">
<string>Adjust Si&amp;ze To:</string>
<string>Adjust Size To:</string>
</property>
</widget>
</item>
@ -223,7 +229,7 @@
<item row="2" column="0">
<widget class="QRadioButton" name="radAztecECC">
<property name="text">
<string>Add Minimum &amp;Error Correction:</string>
<string>Add Minimum Error Correction:</string>
</property>
</widget>
</item>
@ -257,48 +263,57 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupBoxAztecEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>453</width>
<height>71</height>
</rect>
<layout class="QGridLayout" name="gridLayoutAztecEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QRadioButton" name="radAztecHIBC">
<property name="text">
<string>HIBC Aztec Code</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radAztecGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radAztecStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<item row="0" column="0">
<widget class="QRadioButton" name="radAztecStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radAztecGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radAztecHIBC">
<property name="text">
<string>HIBC Aztec Code</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>43</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

76
frontend_qt/grpC11.ui Normal file
View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>grpC11</class>
<widget class="QWidget" name="grpC11">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>227</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="grpC11CheckDigits">
<property name="title">
<string>Check Digits</string>
</property>
<layout class="QGridLayout" name="gridLayoutC11CheckDigits">
<item row="0" column="0">
<widget class="QRadioButton" name="radC11TwoCheckDigits">
<property name="text">
<string>Two (Mod-11)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC11OneCheckDigit">
<property name="text">
<string>One (Mod-11)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radC11NoCheckDigits">
<property name="text">
<string>No Check Digit</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -10,54 +10,83 @@
<height>156</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radC128Stand">
<property name="text">
<string>S&amp;tandard</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC128CSup">
<property name="text">
<string>Subset &amp;C Supression</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radC128EAN">
<property name="text">
<string>&amp;GS1-128</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radC128HIBC">
<property name="text">
<string>&amp;HIBC 128</string>
</property>
</widget>
</item>
</layout>
<widget class="QGroupBox" name="groupBoxC128EncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutC128EncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radC128Stand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC128CSup">
<property name="text">
<string>Subset C Supression</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radC128EAN">
<property name="text">
<string>GS1-128</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radC128HIBC">
<property name="text">
<string>HIBC 128</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lblC128">
<widget class="QLabel" name="noteC128CompositeEAN">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Note: Composite symbols require a&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;GS1-128 linear component.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Note: Composite symbols require a GS1-128 linear component.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>

View File

@ -10,6 +10,12 @@
<height>123</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -30,7 +36,7 @@
<widget class="QComboBox" name="cmbC16kRowSepHeight">
<item>
<property name="text">
<string>Default (1 X)</string>
<string>1 X (default)</string>
</property>
</item>
<item>
@ -53,28 +59,28 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxEncodingMode">
<widget class="QGroupBox" name="groupBoxC16kEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QGridLayout" name="gridLayoutC16kEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<item row="0" column="0">
<widget class="QRadioButton" name="radC16kStand">
<property name="text">
<string>S&amp;tandard Mode</string>
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC16kGS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
<string>GS1 Data Mode</string>
</property>
</widget>
</item>

View File

@ -10,6 +10,12 @@
<height>131</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -19,7 +25,7 @@
<item row="0" column="0">
<widget class="QRadioButton" name="radC39Stand">
<property name="text">
<string>&amp;No Check Digit</string>
<string>No Check Digit</string>
</property>
<property name="checked">
<bool>true</bool>
@ -29,14 +35,14 @@
<item row="1" column="0">
<widget class="QRadioButton" name="radC39HIBC">
<property name="text">
<string>&amp;HIBC 39</string>
<string>HIBC 39</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC39Check">
<property name="text">
<string>&amp;Mod-43 Check Digit</string>
<string>Mod-43 Check Digit</string>
</property>
</widget>
</item>

View File

@ -10,6 +10,12 @@
<height>123</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -30,7 +36,7 @@
<widget class="QComboBox" name="cmbC49RowSepHeight">
<item>
<property name="text">
<string>Default (1 X)</string>
<string>1 X (default)</string>
</property>
</item>
<item>
@ -53,28 +59,28 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxEncodingMode">
<widget class="QGroupBox" name="groupBoxC49EncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QGridLayout" name="gridLayoutC49EncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<item row="0" column="0">
<widget class="QRadioButton" name="radC49Stand">
<property name="text">
<string>S&amp;tandard Mode</string>
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC49GS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
<string>GS1 Data Mode</string>
</property>
</widget>
</item>

44
frontend_qt/grpCodabar.ui Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>grpCodabar</class>
<widget class="QWidget" name="grpCodabar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<height>131</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkCodabarCheck">
<property name="text">
<string>Add Check Character (Mod-16)</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -6,20 +6,26 @@
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<height>376</height>
<width>450</width>
<height>320</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridCbfLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelWidth">
<property name="text">
<string>S&amp;ymbol Width (Columns):</string>
<string>Symbol Width (Columns):</string>
</property>
<property name="buddy">
<cstring>cmbCbfWidth</cstring>
@ -28,6 +34,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbCbfWidth">
<property name="maxVisibleItems">
<number>21</number>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -333,7 +342,7 @@
<item row="1" column="0">
<widget class="QLabel" name="labelHeight">
<property name="text">
<string>Symbo&amp;l Height (Rows):</string>
<string>Symbol Height (Rows):</string>
</property>
<property name="buddy">
<cstring>cmbCbfHeight</cstring>
@ -342,6 +351,9 @@
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbCbfHeight">
<property name="maxVisibleItems">
<number>21</number>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -583,7 +595,7 @@
<widget class="QComboBox" name="cmbCbfRowSepHeight">
<item>
<property name="text">
<string>Default (1 X)</string>
<string>1 X (default)</string>
</property>
</item>
<item>
@ -606,7 +618,7 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxEncodingMode">
<widget class="QGroupBox" name="groupBoxCbfEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
@ -627,7 +639,7 @@
<item>
<widget class="QRadioButton" name="radCbfHIBC">
<property name="text">
<string>HIBC Codabloc&amp;k-F Mode</string>
<string>HIBC Codablock-F</string>
</property>
</widget>
</item>
@ -640,7 +652,7 @@
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View File

@ -10,6 +10,12 @@
<height>124</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -19,7 +25,7 @@
<item row="0" column="0">
<widget class="QLabel" name="lblChannel">
<property name="text">
<string>S&amp;ymbol Size:</string>
<string>Symbol Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -88,25 +94,37 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radC1Stand">
<property name="text">
<string>S&amp;tandard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radC1GS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutC1EncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radC1Stand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radC1GS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -10,6 +10,12 @@
<height>78</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>

View File

@ -10,40 +10,22 @@
<height>339</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="radDM200Stand">
<property name="text">
<string>S&amp;tandard</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radDM200HIBC">
<property name="text">
<string>&amp;HIBC Data Matrix</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radDM200GS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblDM200Size">
<property name="text">
<string>Si&amp;ze:</string>
<string>Size:</string>
</property>
<property name="buddy">
<cstring>cmbDM200Size</cstring>
@ -52,6 +34,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbDM200Size">
<property name="maxVisibleItems">
<number>21</number>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -301,6 +286,42 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxDM200EncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutDM200EncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radDM200Stand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radDM200GS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radDM200HIBC">
<property name="text">
<string>HIBC Data Matrix</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDMRectangle">
<property name="text">
@ -321,6 +342,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDMGSSep">
<property name="text">
<string>Use separator GS for GS1</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -10,6 +10,12 @@
<height>223</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -19,7 +25,7 @@
<item row="0" column="1">
<widget class="QComboBox" name="cmbDotCols">
<property name="maxVisibleItems">
<number>11</number>
<number>21</number>
</property>
<item>
<property name="text">
@ -314,30 +320,45 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radDotStan">
<property name="text">
<string>Standard &amp;Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radDotGs1">
<property name="text">
<string>GS-&amp;1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxDotEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutDotEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radDotStand">
<property name="text">
<string>S&amp;tandard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radDotGS1">
<property name="text">
<string>&amp;GS1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>

View File

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>159</height>
<width>400</width>
<height>227</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -17,27 +23,22 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radGridAuto">
<widget class="QLabel" name="labelGridSize">
<property name="text">
<string>A&amp;utomatic Resizing</string>
<string>Size:</string>
</property>
<property name="checked">
<bool>true</bool>
<property name="buddy">
<cstring>cmbGridSize</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radGridSize">
<property name="text">
<string>Adjust Si&amp;ze To:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QComboBox" name="cmbGridSize">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>18 x 18 (Version 1)</string>
@ -105,18 +106,23 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radGridECC">
<item row="1" column="0">
<widget class="QLabel" name="labelGridECC">
<property name="text">
<string>Add &amp;Error Correction:</string>
<string>Error Correction:</string>
</property>
<property name="buddy">
<cstring>cmbGridECC</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="cmbGridECC">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>~10%</string>
@ -146,11 +152,41 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="noteGridECC">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Note: Error Correction is ignored if it is below the minimum available or is too high for a given size.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
@ -162,38 +198,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>radGridSize</sender>
<signal>toggled(bool)</signal>
<receiver>cmbGridSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>98</x>
<y>54</y>
</hint>
<hint type="destinationlabel">
<x>279</x>
<y>53</y>
</hint>
</hints>
</connection>
<connection>
<sender>radGridECC</sender>
<signal>toggled(bool)</signal>
<receiver>cmbGridECC</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>114</x>
<y>89</y>
</hint>
<hint type="destinationlabel">
<x>279</x>
<y>89</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

69
frontend_qt/grpLOGMARS.ui Normal file
View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>grpLOGMARS</class>
<widget class="QWidget" name="grpLOGMARS">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>131</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="grpLOGMARSCheckDigits">
<property name="title">
<string>Check Digits</string>
</property>
<layout class="QGridLayout" name="gridLayoutLOGMARSCheckDigits">
<item row="0" column="0">
<widget class="QRadioButton" name="radLOGMARSStand">
<property name="text">
<string>No Check Digit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radLOGMARSCheck">
<property name="text">
<string>One (Mod-43)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -5,10 +5,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>159</height>
<width>400</width>
<height>227</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
@ -16,27 +22,22 @@
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QRadioButton" name="radMQRAuto" >
<widget class="QLabel" name="lavelMQRSize" >
<property name="text" >
<string>A&amp;utomatic Resizing</string>
<string>Size:</string>
</property>
<property name="checked" >
<bool>true</bool>
<property name="buddy">
<cstring>cmbMQRSize</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="radMQRSize" >
<property name="text" >
<string>Adjust Si&amp;ze To:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="0" column="1" >
<widget class="QComboBox" name="cmbMQRSize" >
<property name="enabled" >
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text" >
<string>11 x 11 (Version M1)</string>
@ -59,18 +60,23 @@
</item>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="radMQRECC" >
<item row="1" column="0" >
<widget class="QLabel" name="labelMQRECC" >
<property name="text" >
<string>Add &amp;Error Correction:</string>
<string>Error Correction:</string>
</property>
<property name="buddy">
<cstring>cmbMQRECC</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<item row="1" column="1" >
<widget class="QComboBox" name="cmbMQRECC" >
<property name="enabled" >
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text" >
<string>~20% (Level L)</string>
@ -95,6 +101,9 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
@ -106,38 +115,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>radMQRSize</sender>
<signal>toggled(bool)</signal>
<receiver>cmbMQRSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>98</x>
<y>54</y>
</hint>
<hint type="destinationlabel" >
<x>279</x>
<y>53</y>
</hint>
</hints>
</connection>
<connection>
<sender>radMQRECC</sender>
<signal>toggled(bool)</signal>
<receiver>cmbMQRECC</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>114</x>
<y>89</y>
</hint>
<hint type="destinationlabel" >
<x>279</x>
<y>89</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -9,6 +9,12 @@
<height>79</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>

View File

@ -10,6 +10,12 @@
<height>251</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>

View File

@ -10,6 +10,12 @@
<height>376</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -58,25 +64,37 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radMPDFStand">
<property name="text">
<string>S&amp;tandard</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radMPDFHIBC">
<property name="text">
<string>&amp;HIBC MicroPDF417</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxMPDFEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutMPDFEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radMPDFStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radMPDFHIBC">
<property name="text">
<string>HIBC MicroPDF417</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -9,6 +9,12 @@
<height>223</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
@ -204,32 +210,44 @@
</item>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="radPDFStand" >
<property name="text" >
<string>S&amp;tandard</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QRadioButton" name="radPDFHIBC" >
<property name="text" >
<string>&amp;HIBC PDF417</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QRadioButton" name="radPDFTruncated" >
<property name="text" >
<string>&amp;Truncated</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxPDFEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutPDFEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radPDFStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radPDFHIBC">
<property name="text">
<string>HIBC PDF417</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radPDFTruncated">
<property name="text">
<string>Truncated</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >

View File

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>441</width>
<height>238</height>
<width>400</width>
<height>227</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -17,27 +23,25 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radQRAuto">
<widget class="QLabel" name="labelQRSize">
<property name="text">
<string>A&amp;utomatic Resizing</string>
<string>Size:</string>
</property>
<property name="checked">
<bool>true</bool>
<property name="buddy">
<cstring>cmbQRSize</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radQRSize">
<property name="text">
<string>Adjust Si&amp;ze To:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QComboBox" name="cmbQRSize">
<property name="enabled">
<bool>false</bool>
<property name="maxVisibleItems">
<number>21</number>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>21 x 21 (Version 1)</string>
@ -240,18 +244,23 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radQRECC">
<item row="1" column="0">
<widget class="QLabel" name="labelQRECC">
<property name="text">
<string>Add &amp;Error Correction:</string>
<string>Error Correction:</string>
</property>
<property name="buddy">
<cstring>cmbQRECC</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="cmbQRECC">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>~20% (Level L)</string>
@ -277,95 +286,59 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="grpQRMode">
<property name="minimumSize">
<widget class="QGroupBox" name="groupBoxQREncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutQREncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radQRStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radQRGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radQRHIBC">
<property name="text">
<string>HIBC QR Code</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>70</height>
<width>20</width>
<height>43</height>
</size>
</property>
<property name="title">
<string>Data Encoding</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>411</width>
<height>80</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="radQRStand">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>S&amp;tandard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radQRHIBC">
<property name="text">
<string>&amp;HIBC QR Code</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radQRGS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>radQRSize</sender>
<signal>toggled(bool)</signal>
<receiver>cmbQRSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>89</x>
<y>39</y>
</hint>
<hint type="destinationlabel">
<x>255</x>
<y>46</y>
</hint>
</hints>
</connection>
<connection>
<sender>radQRECC</sender>
<signal>toggled(bool)</signal>
<receiver>cmbQRECC</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>79</y>
</hint>
<hint type="destinationlabel">
<x>308</x>
<y>79</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>441</width>
<height>238</height>
<width>400</width>
<height>227</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -17,27 +23,25 @@
<item>
<layout class="QGridLayout" name="grpRMQROptions">
<item row="0" column="0">
<widget class="QRadioButton" name="radRMQRAuto">
<widget class="QLabel" name="labelRMQRSize">
<property name="text">
<string>A&amp;utomatic Resizing</string>
<string>Size:</string>
</property>
<property name="checked">
<bool>true</bool>
<property name="buddy">
<cstring>cmbRMQRSize</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radRMQRSize">
<property name="text">
<string>Adjust Si&amp;ze To:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QComboBox" name="cmbRMQRSize">
<property name="enabled">
<bool>false</bool>
<property name="maxVisibleItems">
<number>21</number>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>R7x43</string>
@ -230,18 +234,23 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radRMQRECC">
<item row="1" column="0">
<widget class="QLabel" name="labelRMQRECC">
<property name="text">
<string>Add &amp;Error Correction:</string>
<string>Error Correction:</string>
</property>
<property name="buddy">
<cstring>cmbRMQRECC</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="cmbRMQRECC">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>~37% (Level M)</string>
@ -257,88 +266,52 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="grpRMQRMode">
<property name="minimumSize">
<widget class="QGroupBox" name="groupBoxRMQREncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<layout class="QGridLayout" name="gridLayoutRMQREncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radRMQRStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radRMQRGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>70</height>
<width>20</width>
<height>43</height>
</size>
</property>
<property name="title">
<string>Data Encoding</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>411</width>
<height>80</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="radRMQRStand">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>S&amp;tandard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radRMQRGS1">
<property name="text">
<string>&amp;GS-1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>radRMQRSize</sender>
<signal>toggled(bool)</signal>
<receiver>cmbRMQRSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>89</x>
<y>39</y>
</hint>
<hint type="destinationlabel">
<x>255</x>
<y>46</y>
</hint>
</hints>
</connection>
<connection>
<sender>radRMQRECC</sender>
<signal>toggled(bool)</signal>
<receiver>cmbRMQRECC</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>79</y>
</hint>
<hint type="destinationlabel">
<x>308</x>
<y>79</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -10,6 +10,12 @@
<height>237</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -76,41 +82,50 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="grpUltraEncodingMode">
<property name="title">
<string>Encoding Mode</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>453</width>
<height>71</height>
</rect>
<layout class="QGridLayout" name="gridLayoutUltraEncodingMode">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QRadioButton" name="radUltraGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radUltraStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<item row="0" column="0">
<widget class="QRadioButton" name="radUltraStand">
<property name="text">
<string>Standard Mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radUltraGS1">
<property name="text">
<string>GS1 Data Mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>43</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

54
frontend_qt/grpVIN.ui Normal file
View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>grpVIN</class>
<widget class="QWidget" name="grpVIN">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>131</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="chkVINImportChar">
<property name="text">
<string>Import Character Prefix</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -321,9 +321,25 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkEscape">
<property name="text">
<string>Parse Escape Sequences</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabAppear">
<property name="maximumSize">
<size>
<width>678</width>
<height>16777215</height>
</size>
</property>
<attribute name="title">
<string>Appearance</string>
</attribute>
@ -346,45 +362,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>B&amp;order Width:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>bwidth</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblWhitespace">
<property name="text">
<string>&amp;Whitespace:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spnWhitespace</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblScale">
<property name="text">
<string>&amp;Printing Scale:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spnScale</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="heightb">
<property name="enabled">
@ -407,6 +384,19 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>B&amp;order Width:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>bwidth</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="bwidth">
<property name="toolTip">
@ -426,7 +416,55 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Border &amp;Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>btype</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="btype">
<property name="toolTip">
<string>Add border or box</string>
</property>
<item>
<property name="text">
<string>No border</string>
</property>
</item>
<item>
<property name="text">
<string>Bind</string>
</property>
</item>
<item>
<property name="text">
<string>Box</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblWhitespace">
<property name="text">
<string>&amp;Whitespace:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spnWhitespace</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spnWhitespace">
<property name="toolTip">
<string>Width of whitespace</string>
@ -436,7 +474,20 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="0">
<widget class="QLabel" name="lblScale">
<property name="text">
<string>&amp;Printing Scale:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spnScale</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spnScale">
<property name="toolTip">
<string>Image scale when output to file</string>
@ -462,41 +513,16 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="label_dummyAppear02">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Border &amp;Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>btype</cstring>
<string></string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="btype">
<property name="toolTip">
<string>Add border or box</string>
</property>
<item>
<property name="text">
<string>No border</string>
</property>
</item>
<item>
<property name="text">
<string>Bind</string>
</property>
</item>
<item>
<property name="text">
<string>Box</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="fgcolor">
<property name="toolTip">
<string>Change ink colour</string>
@ -506,7 +532,17 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="3">
<item row="1" column="2">
<widget class="QLabel" name="label_dummyAppear12">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="bgcolor">
<property name="toolTip">
<string>Change paper colour</string>
@ -516,7 +552,17 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="3" column="3">
<item row="2" column="2">
<widget class="QLabel" name="label_dummyAppear13">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string></string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="btnReset">
<property name="toolTip">
<string>Reset to black on white</string>

View File

@ -35,8 +35,9 @@
#include <stdio.h>
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl),m_optionWidget(0)
: QWidget(parent, fl), m_optionWidget(0)
{
m_bc.bc.setDebug(QCoreApplication::arguments().contains("--verbose"));
QCoreApplication::setOrganizationName("zint");
QCoreApplication::setOrganizationDomain("zint.org.uk");
@ -68,6 +69,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
"Code 49",
"Code 93",
"Code One",
"DAFT Code",
"Data Matrix (ISO 16022)",
"Deutsche Post Identcode",
"Deutsche Post Leitcode",
@ -112,7 +114,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
"UPNQR",
"Universal Product Code (UPC-A)",
"Universal Product Code (UPC-E)",
"USPS Intelligent Mail"
"USPS Intelligent Mail",
"VIN (Vehicle Identification Number)"
};
scene = new QGraphicsScene(this);
@ -151,6 +154,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(composite_enable()));
connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(cmbCompType, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(chkEscape, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about()));
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
@ -391,11 +395,12 @@ void MainWindow::copy_to_clipboard_bmp()
void MainWindow::change_options()
{
QUiLoader uiload;
int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex());
if (tabMain->count()==3)
tabMain->removeTab(1);
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE128)
if (symbology == BARCODE_CODE128)
{
QFile file(":/grpC128.ui");
if (!file.open(QIODevice::ReadOnly))
@ -413,7 +418,7 @@ void MainWindow::change_options()
else
chkComposite->setText(tr("Add 2D Component"));
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_PDF417)
if (symbology == BARCODE_PDF417)
{
QFile file(":/grpPDF417.ui");
if (!file.open(QIODevice::ReadOnly))
@ -426,9 +431,10 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radPDFTruncated"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radPDFStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radPDFHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MICROPDF417)
if (symbology == BARCODE_MICROPDF417)
{
QFile file(":/grpMicroPDF.ui");
if (!file.open(QIODevice::ReadOnly))
@ -440,7 +446,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radMPDFStand"), SIGNAL(toggled( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_DOTCODE)
if (symbology == BARCODE_DOTCODE)
{
QFile file(":/grpDotCode.ui");
if (!file.open(QIODevice::ReadOnly))
@ -449,12 +455,12 @@ void MainWindow::change_options()
file.close();
tabMain->insertTab(1,m_optionWidget,tr("DotCode"));
connect(m_optionWidget->findChild<QObject*>("cmbDotCols"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDotStan"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDotGs1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDotStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radDotGS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("txtDotSize"), SIGNAL(textChanged( QString )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_AZTEC)
if (symbology == BARCODE_AZTEC)
{
QFile file(":/grpAztec.ui");
if (!file.open(QIODevice::ReadOnly))
@ -472,7 +478,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radAztecHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MSI_PLESSEY)
if (symbology == BARCODE_MSI_PLESSEY)
{
QFile file(":/grpMSICheck.ui");
if (!file.open(QIODevice::ReadOnly))
@ -483,8 +489,20 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("cmbMSICheck"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
}
if((metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE39) ||
(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_EXCODE39))
if (symbology == BARCODE_CODE11)
{
QFile file(":/grpC11.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Code 11"));
connect(m_optionWidget->findChild<QObject*>("radC11TwoCheckDigits"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC11OneCheckDigit"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC11NoCheckDigits"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if ((symbology == BARCODE_CODE39) || (symbology == BARCODE_EXCODE39))
{
QFile file(":/grpC39.ui");
if (!file.open(QIODevice::ReadOnly))
@ -495,7 +513,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radC39Stand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC39Check"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radC39HIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_EXCODE39)
if (symbology == BARCODE_EXCODE39)
{
if(m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->isChecked() == true)
{
@ -508,7 +526,19 @@ void MainWindow::change_options()
m_optionWidget->findChild<QRadioButton*>("radC39HIBC")->setEnabled(true);
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE16K)
if (symbology == BARCODE_LOGMARS)
{
QFile file(":/grpLOGMARS.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("LOGMARS"));
connect(m_optionWidget->findChild<QObject*>("radLOGMARSStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radLOGMARSCheck"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if (symbology == BARCODE_CODE16K)
{
QFile file(":/grpC16k.ui");
if (!file.open(QIODevice::ReadOnly))
@ -520,7 +550,18 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radC16kStand"), SIGNAL(toggled( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODABLOCKF)
if (symbology == BARCODE_CODABAR)
{
QFile file(":/grpCodabar.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Codabar"));
connect(m_optionWidget->findChild<QObject*>("chkCodabarCheck"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if (symbology == BARCODE_CODABLOCKF)
{
QFile file (":/grpCodablockF.ui");
if (!file.open(QIODevice::ReadOnly))
@ -535,7 +576,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radCbfHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_DATAMATRIX)
if (symbology == BARCODE_DATAMATRIX)
{
QFile file(":/grpDM.ui");
if (!file.open(QIODevice::ReadOnly))
@ -549,9 +590,10 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("cmbDM200Size"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("chkDMRectangle"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("chkDMRE"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("chkDMGSSep"), SIGNAL(stateChanged( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_QRCODE)
if (symbology == BARCODE_QRCODE)
{
QFile file(":/grpQR.ui");
if (!file.open(QIODevice::ReadOnly))
@ -559,9 +601,6 @@ void MainWindow::change_options()
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("QR Code"));
connect(m_optionWidget->findChild<QObject*>("radQRAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radQRSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radQRECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radQRStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
@ -569,7 +608,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radQRHIBC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_RMQR)
if (symbology == BARCODE_RMQR)
{
QFile file(":/grpRMQR.ui");
if (!file.open(QIODevice::ReadOnly))
@ -577,16 +616,13 @@ void MainWindow::change_options()
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("rMQR Code"));
connect(m_optionWidget->findChild<QObject*>("radRMQRAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radRMQRSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radRMQRECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbRMQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbRMQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radRMQRStand"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radRMQRGS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_HANXIN)
if (symbology == BARCODE_HANXIN)
{
QFile file (":/grpHX.ui");
if (!file.open(QIODevice::ReadOnly))
@ -594,14 +630,11 @@ void MainWindow::change_options()
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Han Xin Code"));
connect(m_optionWidget->findChild<QObject*>("radHXAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radHXSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radHXECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbHXSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbHXECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MICROQR)
if (symbology == BARCODE_MICROQR)
{
QFile file(":/grpMQR.ui");
if (!file.open(QIODevice::ReadOnly))
@ -609,14 +642,11 @@ void MainWindow::change_options()
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Micro QR Code"));
connect(m_optionWidget->findChild<QObject*>("radMQRAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radMQRSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radMQRECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbMQRSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbMQRECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_GRIDMATRIX)
if (symbology == BARCODE_GRIDMATRIX)
{
QFile file(":/grpGrid.ui");
if (!file.open(QIODevice::ReadOnly))
@ -624,14 +654,11 @@ void MainWindow::change_options()
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("Grid Matrix"));
connect(m_optionWidget->findChild<QObject*>("radGridAuto"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radGridSize"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("radGridECC"), SIGNAL(clicked( bool )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbGridSize"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
connect(m_optionWidget->findChild<QObject*>("cmbGridECC"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_MAXICODE)
if (symbology == BARCODE_MAXICODE)
{
QFile file(":/grpMaxicode.ui");
if (!file.open(QIODevice::ReadOnly))
@ -644,7 +671,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("txtMaxiPrimary"), SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CHANNEL)
if (symbology == BARCODE_CHANNEL)
{
QFile file(":/grpChannel.ui");
if (!file.open(QIODevice::ReadOnly))
@ -655,7 +682,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("cmbChannel"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODEONE)
if (symbology == BARCODE_CODEONE)
{
QFile file(":/grpCodeOne.ui");
if (!file.open(QIODevice::ReadOnly))
@ -667,7 +694,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radC1GS1"), SIGNAL(toggled( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODE49)
if (symbology == BARCODE_CODE49)
{
QFile file(":/grpC49.ui");
if (!file.open(QIODevice::ReadOnly))
@ -679,7 +706,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radC49GS1"), SIGNAL(toggled( bool )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_RSS_EXPSTACK)
if (symbology == BARCODE_RSS_EXPSTACK)
{
QFile file(":/grpDBExtend.ui");
if (!file.open(QIODevice::ReadOnly))
@ -690,7 +717,7 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("cmbCols"), SIGNAL(currentIndexChanged ( int )), SLOT(update_preview()));
}
if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_ULTRA)
if (symbology == BARCODE_ULTRA)
{
QFile file(":/grpUltra.ui");
if (!file.open(QIODevice::ReadOnly))
@ -705,7 +732,18 @@ void MainWindow::change_options()
connect(m_optionWidget->findChild<QObject*>("radUltraGS1"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
switch(metaObject()->enumerator(0).value(bstyle->currentIndex()))
if (symbology == BARCODE_VIN)
{
QFile file(":/grpVIN.ui");
if (!file.open(QIODevice::ReadOnly))
return;
m_optionWidget=uiload.load(&file);
file.close();
tabMain->insertTab(1,m_optionWidget,tr("VIN"));
connect(m_optionWidget->findChild<QObject*>("chkVINImportChar"), SIGNAL(clicked( bool )), SLOT(update_preview()));
}
switch (symbology)
{
case BARCODE_CODE128:
case BARCODE_EANX:
@ -773,6 +811,7 @@ void MainWindow::update_preview()
int width = view->geometry().width();
int height = view->geometry().height();
int item_val;
QCheckBox *checkBox;
//m_bc.ar=(Zint::QZint::AspectRatioMode)1;
if(chkComposite->isChecked() == true) {
@ -782,13 +821,17 @@ void MainWindow::update_preview()
m_bc.bc.setText(txtData->text());
}
m_bc.bc.setSecurityLevel(0);
m_bc.bc.setWidth(0);
m_bc.bc.setOption2(0);
m_bc.bc.setOption3(0);
m_bc.bc.setInputMode(UNICODE_MODE);
if (chkEscape->isChecked()) {
m_bc.bc.setInputMode(m_bc.bc.inputMode() | ESCAPE_MODE);
}
m_bc.bc.setHideText(0);
if(chkHRTHide->isChecked() == false) {
m_bc.bc.setHideText(1);
}
m_bc.bc.setGSSep(false);
switch(metaObject()->enumerator(0).value(bstyle->currentIndex()))
{
case BARCODE_CODE128:
@ -873,11 +916,11 @@ void MainWindow::update_preview()
m_bc.bc.setSymbol(BARCODE_RSS_EXPSTACK);
if(m_optionWidget->findChild<QComboBox*>("cmbCols")->currentIndex() != 0)
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbCols")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbCols")->currentIndex());
break;
case BARCODE_PDF417:
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbPDFCols")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbPDFCols")->currentIndex());
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbPDFECC")->currentIndex()-1);
if(m_optionWidget->findChild<QRadioButton*>("radPDFStand")->isChecked())
m_bc.bc.setSymbol(BARCODE_PDF417);
@ -890,7 +933,7 @@ void MainWindow::update_preview()
break;
case BARCODE_MICROPDF417:
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMPDFCols")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbMPDFCols")->currentIndex());
if(m_optionWidget->findChild<QRadioButton*>("radMPDFStand")->isChecked())
m_bc.bc.setSymbol(BARCODE_MICROPDF417);
@ -900,8 +943,8 @@ void MainWindow::update_preview()
case BARCODE_DOTCODE:
m_bc.bc.setSymbol(BARCODE_DOTCODE);
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDotCols")->currentIndex());
if(m_optionWidget->findChild<QRadioButton*>("radDotGs1")->isChecked())
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbDotCols")->currentIndex());
if(m_optionWidget->findChild<QRadioButton*>("radDotGS1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE);
m_bc.bc.setDotSize(m_optionWidget->findChild<QLineEdit*>("txtDotSize")->text().toFloat());
break;
@ -909,7 +952,7 @@ void MainWindow::update_preview()
case BARCODE_AZTEC:
m_bc.bc.setSymbol(BARCODE_AZTEC);
if(m_optionWidget->findChild<QRadioButton*>("radAztecSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbAztecSize")->currentIndex() + 1);
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbAztecSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radAztecECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbAztecECC")->currentIndex() + 1);
@ -922,7 +965,16 @@ void MainWindow::update_preview()
case BARCODE_MSI_PLESSEY:
m_bc.bc.setSymbol(BARCODE_MSI_PLESSEY);
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMSICheck")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbMSICheck")->currentIndex());
break;
case BARCODE_CODE11:
m_bc.bc.setSymbol(BARCODE_CODE11);
if (m_optionWidget->findChild<QRadioButton*>("radC11OneCheckDigit")->isChecked()) {
m_bc.bc.setOption2(1);
} else if (m_optionWidget->findChild<QRadioButton*>("radC11NoCheckDigits")->isChecked()) {
m_bc.bc.setOption2(2);
}
break;
case BARCODE_CODE39:
@ -932,16 +984,24 @@ void MainWindow::update_preview()
{
m_bc.bc.setSymbol(BARCODE_CODE39);
if(m_optionWidget->findChild<QRadioButton*>("radC39Check")->isChecked())
m_bc.bc.setWidth(1);
m_bc.bc.setOption2(1);
}
break;
case BARCODE_EXCODE39:
m_bc.bc.setSymbol(BARCODE_EXCODE39);
if(m_optionWidget->findChild<QRadioButton*>("radC39Check")->isChecked())
m_bc.bc.setWidth(1);
m_bc.bc.setOption2(1);
break;
case BARCODE_LOGMARS:
m_bc.bc.setSymbol(BARCODE_LOGMARS);
if (m_optionWidget->findChild<QRadioButton*>("radLOGMARSCheck")->isChecked()) {
m_bc.bc.setOption2(1);
}
break;
case BARCODE_CODE16K:
m_bc.bc.setSymbol(BARCODE_CODE16K);
if(m_optionWidget->findChild<QRadioButton*>("radC16kStand")->isChecked())
@ -955,6 +1015,13 @@ void MainWindow::update_preview()
}
break;
case BARCODE_CODABAR:
m_bc.bc.setSymbol(BARCODE_CODABAR);
if (m_optionWidget->findChild<QCheckBox*>("chkCodabarCheck")->isChecked()) {
m_bc.bc.setOption2(1);
}
break;
case BARCODE_CODABLOCKF:
if (m_optionWidget->findChild<QRadioButton*>("radCbfHIBC")->isChecked()) {
m_bc.bc.setSymbol(BARCODE_HIBC_BLOCKF);
@ -963,7 +1030,7 @@ void MainWindow::update_preview()
}
item_val = m_optionWidget->findChild<QComboBox*>("cmbCbfWidth")->currentIndex();
if (item_val) {
m_bc.bc.setWidth(item_val - 1 + 9);
m_bc.bc.setOption2(item_val - 1 + 9);
}
// Height selection uses option 1 in zint_symbol
item_val = m_optionWidget->findChild<QComboBox*>("cmbCbfHeight")->currentIndex();
@ -984,10 +1051,18 @@ void MainWindow::update_preview()
else
m_bc.bc.setSymbol(BARCODE_DATAMATRIX);
if(m_optionWidget->findChild<QRadioButton*>("radDM200GS1")->isChecked())
if (m_optionWidget->findChild<QRadioButton*>("radDM200GS1")->isChecked()) {
m_bc.bc.setInputMode(GS1_MODE);
checkBox = m_optionWidget->findChild<QCheckBox*>("chkDMGSSep");
checkBox->setEnabled(true);
if (checkBox->isChecked()) {
m_bc.bc.setGSSep(true);
}
} else {
m_optionWidget->findChild<QCheckBox*>("chkDMGSSep")->setEnabled(false);
}
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex());
if (m_optionWidget->findChild<QComboBox*>("cmbDM200Size")->currentIndex() == 0) {
// Supressing rectangles or allowing DMRE only makes sense if in automatic size mode
@ -1017,20 +1092,28 @@ void MainWindow::update_preview()
if(m_optionWidget->findChild<QRadioButton*>("radQRGS1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE);
if(m_optionWidget->findChild<QRadioButton*>("radQRSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbQRSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radQRECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbQRECC")->currentIndex() + 1);
printf("cmbQRSize stylesheet %s\n", (const char *) m_optionWidget->findChild<QComboBox*>("cmbQRSize")->styleSheet().toLatin1());
item_val = m_optionWidget->findChild<QComboBox*>("cmbQRSize")->currentIndex();
if (item_val) {
m_bc.bc.setOption2(item_val);
}
printf("cmbQRECC stylesheet %s\n", (const char *) m_optionWidget->findChild<QComboBox*>("cmbQRECC")->styleSheet().toLatin1());
item_val = m_optionWidget->findChild<QComboBox*>("cmbQRECC")->currentIndex();
if (item_val) {
m_bc.bc.setSecurityLevel(item_val);
}
break;
case BARCODE_MICROQR:
m_bc.bc.setSymbol(BARCODE_MICROQR);
if(m_optionWidget->findChild<QRadioButton*>("radMQRSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbMQRSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radMQRECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbMQRECC")->currentIndex() + 1);
item_val = m_optionWidget->findChild<QComboBox*>("cmbMQRSize")->currentIndex();
if (item_val) {
m_bc.bc.setOption2(item_val);
}
item_val = m_optionWidget->findChild<QComboBox*>("cmbMQRECC")->currentIndex();
if (item_val) {
m_bc.bc.setSecurityLevel(item_val);
}
break;
case BARCODE_RMQR:
@ -1039,20 +1122,26 @@ void MainWindow::update_preview()
if(m_optionWidget->findChild<QRadioButton*>("radRMQRGS1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE);
if(m_optionWidget->findChild<QRadioButton*>("radRMQRSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbRMQRSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radRMQRECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbRMQRECC")->currentIndex() * 2 + 2);
item_val = m_optionWidget->findChild<QComboBox*>("cmbRMQRSize")->currentIndex();
if (item_val) {
m_bc.bc.setOption2(item_val);
}
item_val = m_optionWidget->findChild<QComboBox*>("cmbRMQRECC")->currentIndex();
if (item_val) {
m_bc.bc.setSecurityLevel(item_val * 2); // Levels 2 (M) and 4 (H) only
}
break;
case BARCODE_GRIDMATRIX:
m_bc.bc.setSymbol(BARCODE_GRIDMATRIX);
if(m_optionWidget->findChild<QRadioButton*>("radGridSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbGridSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radGridECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbGridECC")->currentIndex() + 1);
item_val = m_optionWidget->findChild<QComboBox*>("cmbGridSize")->currentIndex();
if (item_val) {
m_bc.bc.setOption2(item_val);
}
item_val = m_optionWidget->findChild<QComboBox*>("cmbGridECC")->currentIndex();
if (item_val) {
m_bc.bc.setSecurityLevel(item_val);
}
break;
case BARCODE_MAXICODE:
@ -1069,16 +1158,16 @@ void MainWindow::update_preview()
case BARCODE_CHANNEL:
m_bc.bc.setSymbol(BARCODE_CHANNEL);
if(m_optionWidget->findChild<QComboBox*>("cmbChannel")->currentIndex() == 0)
m_bc.bc.setWidth(0);
m_bc.bc.setOption2(0);
else
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbChannel")->currentIndex() + 2);
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbChannel")->currentIndex() + 2);
break;
case BARCODE_CODEONE:
m_bc.bc.setSymbol(BARCODE_CODEONE);
if(m_optionWidget->findChild<QRadioButton*>("radC1GS1")->isChecked())
m_bc.bc.setInputMode(GS1_MODE);
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbC1Size")->currentIndex());
m_bc.bc.setOption2(m_optionWidget->findChild<QComboBox*>("cmbC1Size")->currentIndex());
break;
case BARCODE_CODE49:
@ -1094,11 +1183,14 @@ void MainWindow::update_preview()
case BARCODE_HANXIN:
m_bc.bc.setSymbol(BARCODE_HANXIN);
if(m_optionWidget->findChild<QRadioButton*>("radHXSize")->isChecked())
m_bc.bc.setWidth(m_optionWidget->findChild<QComboBox*>("cmbHXSize")->currentIndex() + 1);
if(m_optionWidget->findChild<QRadioButton*>("radHXECC")->isChecked())
m_bc.bc.setSecurityLevel(m_optionWidget->findChild<QComboBox*>("cmbHXECC")->currentIndex() + 1);
item_val = m_optionWidget->findChild<QComboBox*>("cmbHXSize")->currentIndex();
if (item_val) {
m_bc.bc.setOption2(item_val);
}
item_val = m_optionWidget->findChild<QComboBox*>("cmbHXECC")->currentIndex();
if (item_val) {
m_bc.bc.setSecurityLevel(item_val);
}
break;
case BARCODE_ULTRA:
@ -1109,6 +1201,13 @@ void MainWindow::update_preview()
m_bc.bc.setInputMode(GS1_MODE);
break;
case BARCODE_VIN:
m_bc.bc.setSymbol(BARCODE_VIN);
if (m_optionWidget->findChild<QCheckBox*>("chkVINImportChar")->isChecked()) {
m_bc.bc.setOption2(m_bc.bc.option2() | 1); // Import character 'I' prefix
}
break;
default:
m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex()));
break;

View File

@ -62,6 +62,7 @@ public:
CODE49 = 24,
CODE93 = 25,
CODE_ONE = 141,
DAFT = 93,
DATAMATRIX = 71,
DPIDENT = 22,
DPLEIT = 21,
@ -106,7 +107,8 @@ public:
UPNQR = 143,
UPCA = 34,
UPCE = 37,
ONECODE = 85
ONECODE = 85,
VIN = 73
};
public:

View File

@ -5,11 +5,13 @@
<file>images/rotateright.png</file>
<file>images/zoomin.png</file>
<file>grpAztec.ui</file>
<file>grpC11.ui</file>
<file>grpC39.ui</file>
<file>grpDM.ui</file>
<file>grpMSICheck.ui</file>
<file>grpC128.ui</file>
<file>grpChannel.ui</file>
<file>grpLOGMARS.ui</file>
<file>grpMicroPDF.ui</file>
<file>grpMaxicode.ui</file>
<file>grpPDF417.ui</file>
@ -23,8 +25,10 @@
<file>images/zint.png</file>
<file>grpHX.ui</file>
<file>grpDotCode.ui</file>
<file>grpCodabar.ui</file>
<file>grpCodablockF.ui</file>
<file>grpRMQR.ui</file>
<file>grpUltra.ui</file>
<file>grpVIN.ui</file>
</qresource>
</RCC>