2020-08-05 09:22:26 +12:00
/*
libzint - the open source barcode library
2023-01-15 13:22:43 +13:00
Copyright ( C ) 2020 - 2023 Robin Stuart < rstuart114 @ gmail . com >
2020-08-05 09:22:26 +12:00
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 .
*/
2022-09-15 07:23:47 +12:00
/* SPDX-License-Identifier: BSD-3-Clause */
2020-08-05 09:22:26 +12:00
2022-07-15 03:01:30 +12:00
# ifndef _WIN32
# include <sys/wait.h>
# endif
2020-08-05 09:22:26 +12:00
2022-09-15 07:23:47 +12:00
# include "testcommon.h"
2021-06-10 22:15:39 +12:00
# ifdef _WIN32
/* Hacks to stop popen() mangling input on Windows */
static int utf8_to_wchar ( const char * str , wchar_t * out ) {
unsigned int codepoint , state = 0 ;
while ( * str ) {
do {
decode_utf8 ( & state , & codepoint , * str + + ) ;
} while ( * str & & state ! = 0 & & state ! = 12 ) ;
if ( state ! = 0 ) {
fprintf ( stderr , " utf8_to_wchar: warning: invalid UTF-8 \n " ) ;
return 0 ;
}
* out + + = codepoint ;
}
* out = L ' \0 ' ;
return 1 ;
}
static int escape_cmd ( const char * str , char * buf ) {
int ret = 0 ;
char * out = buf ;
const unsigned char * ustr ;
for ( ustr = ( const unsigned char * ) str ; * ustr ; ustr + + ) {
if ( * ustr > = 0x80 | | * ustr < 0x20 | | * ustr = = ' \\ ' ) {
sprintf ( out , " \\ x%02X " , * ustr ) ;
out + = 4 ;
ret = 1 ;
} else {
* out + + = * ustr ;
}
}
* out = ' \0 ' ;
if ( ret ) {
if ( out - buf > 5 & & strcmp ( out - 5 , " 2>&1 " ) = = 0 ) {
strcpy ( out - 5 , " --esc 2>&1 " ) ;
} else {
strcpy ( out , " --esc " ) ;
}
}
return ret ;
}
# endif
2022-05-23 08:33:45 +12:00
static char * exec ( const char * cmd , char * buf , int buf_size , int debug , int index , int * p_exit_status ) {
2020-08-05 09:44:20 +12:00
FILE * fp ;
int cnt ;
2022-05-23 08:33:45 +12:00
int exit_status ;
2021-06-10 22:15:39 +12:00
# ifdef _WIN32
wchar_t wchar_cmd [ 8192 ] ;
char esc_cmd [ 16384 ] ;
int is_binary = strstr ( cmd , " --binary " ) ! = NULL ;
int is_escaped = strstr ( cmd , " --esc " ) ! = NULL ;
# endif
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
if ( debug & ZINT_DEBUG_TEST_PRINT ) printf ( " %d: %s \n " , index , cmd ) ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
* buf = ' \0 ' ;
2020-08-05 09:22:26 +12:00
2021-06-10 22:15:39 +12:00
# ifdef _WIN32
if ( ! is_binary & & utf8_to_wchar ( cmd , wchar_cmd ) ) {
fp = _wpopen ( wchar_cmd , L " r " ) ;
} else if ( ! is_escaped & & is_binary & & escape_cmd ( cmd , esc_cmd ) ) {
fp = testutil_popen ( esc_cmd , " r " ) ;
} else {
fp = testutil_popen ( cmd , " r " ) ;
}
# else
fp = testutil_popen ( cmd , " r " ) ;
# endif
2020-08-05 09:22:26 +12:00
if ( ! fp ) {
fprintf ( stderr , " exec: failed to run '%s' \n " , cmd ) ;
return NULL ;
}
2021-06-27 22:47:55 +12:00
cnt = ( int ) fread ( buf , 1 , buf_size , fp ) ;
2020-08-05 09:22:26 +12:00
if ( fgetc ( fp ) ! = EOF ) {
fprintf ( stderr , " exec: failed to read full stream (%s) \n " , cmd ) ;
2022-05-23 08:33:45 +12:00
exit_status = testutil_pclose ( fp ) ;
if ( p_exit_status ) {
2022-06-03 07:32:25 +12:00
# ifndef _WIN32
2022-05-23 08:33:45 +12:00
if ( WIFEXITED ( exit_status ) ) {
exit_status = WEXITSTATUS ( exit_status ) ;
}
2022-06-03 07:32:25 +12:00
# endif
2022-05-23 08:33:45 +12:00
* p_exit_status = exit_status ;
}
2020-08-05 09:22:26 +12:00
return NULL ;
}
2022-05-23 08:33:45 +12:00
exit_status = testutil_pclose ( fp ) ;
if ( p_exit_status ) {
2022-06-03 07:32:25 +12:00
# ifndef _WIN32
2022-05-23 08:33:45 +12:00
if ( WIFEXITED ( exit_status ) ) {
exit_status = WEXITSTATUS ( exit_status ) ;
}
2022-06-03 07:32:25 +12:00
# endif
2022-05-23 08:33:45 +12:00
* p_exit_status = exit_status ;
}
2020-08-05 09:44:20 +12:00
if ( cnt ) {
if ( buf [ cnt - 1 ] = = ' \r ' | | buf [ cnt - 1 ] = = ' \n ' ) {
buf [ cnt - 1 ] = ' \0 ' ;
2020-12-18 15:36:48 +13:00
if ( cnt > 1 & & ( buf [ cnt - 2 ] = = ' \r ' | | buf [ cnt - 2 ] = = ' \n ' ) ) {
2020-08-05 09:44:20 +12:00
buf [ cnt - 2 ] = ' \0 ' ;
}
}
}
return buf ;
2020-08-05 09:22:26 +12:00
}
static void arg_int ( char * cmd , const char * opt , int val ) {
2020-08-05 09:44:20 +12:00
if ( val ! = - 1 ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s%d " , strlen ( cmd ) ? " " : " " , opt , val ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
static void arg_bool ( char * cmd , const char * opt , int val ) {
2020-08-05 09:44:20 +12:00
if ( val = = 1 ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s " , strlen ( cmd ) ? " " : " " , opt ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
static void arg_double ( char * cmd , const char * opt , double val ) {
2020-08-05 09:44:20 +12:00
if ( val ! = - 1 ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s%.8f " , strlen ( cmd ) ? " " : " " , opt , val ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
static void arg_data ( char * cmd , const char * opt , const char * data ) {
2020-08-05 09:44:20 +12:00
if ( data ! = NULL ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s \" %s \" " , strlen ( cmd ) ? " " : " " , opt , data ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
static void arg_seg ( char * cmd , const char * opt , const char * data , const int eci ) {
if ( data ! = NULL ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s%d, \" %s \" " , strlen ( cmd ) ? " " : " " , opt , eci , data ) ;
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
} else {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s%s%d " , strlen ( cmd ) ? " " : " " , opt , eci ) ;
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
}
}
2020-08-05 09:22:26 +12:00
static int arg_input ( char * cmd , const char * filename , const char * input ) {
2020-08-05 09:44:20 +12:00
FILE * fp ;
int cnt ;
if ( input ! = NULL ) {
2020-12-18 15:36:48 +13:00
if ( strcmp ( input , " - " ) ! = 0 ) {
2023-05-11 08:29:09 +12:00
fp = testUtilOpen ( filename , " wb " ) ;
2020-12-18 15:36:48 +13:00
if ( ! fp ) {
fprintf ( stderr , " arg_input: failed to open '%s' for writing \n " , filename ) ;
return 0 ;
}
2021-06-27 22:47:55 +12:00
cnt = ( int ) fwrite ( input , 1 , strlen ( input ) , fp ) ;
2020-12-18 15:36:48 +13:00
if ( cnt ! = ( int ) strlen ( input ) ) {
fprintf ( stderr , " arg_input: failed to write %d bytes, cnt %d written (%s) \n " , ( int ) strlen ( input ) , cnt , filename ) ;
fclose ( fp ) ;
return 0 ;
}
2020-08-05 09:44:20 +12:00
fclose ( fp ) ;
}
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s-i \" %s \" " , strlen ( cmd ) ? " " : " " , filename ) ;
2020-08-05 09:44:20 +12:00
return 1 ;
}
return 0 ;
2020-08-05 09:22:26 +12:00
}
static void arg_input_mode ( char * cmd , int input_mode ) {
2020-08-05 09:44:20 +12:00
if ( input_mode ! = - 1 ) {
if ( ( input_mode & 0x07 ) = = DATA_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--binary " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
} else if ( ( input_mode & 0x07 ) = = GS1_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--gs1 " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( input_mode & ESCAPE_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--esc " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
2023-01-15 13:22:43 +13:00
if ( input_mode & EXTRA_ESCAPE_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--extraesc " , strlen ( cmd ) ? " " : " " ) ;
2023-01-15 13:22:43 +13:00
}
2021-12-19 05:22:02 +13:00
if ( input_mode & FAST_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--fast " , strlen ( cmd ) ? " " : " " ) ;
2021-12-19 05:22:02 +13:00
}
2021-05-15 23:23:46 +12:00
if ( input_mode & GS1PARENS_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--gs1parens " , strlen ( cmd ) ? " " : " " ) ;
2021-05-15 23:23:46 +12:00
}
2021-11-21 00:32:30 +13:00
if ( input_mode & GS1NOCHECK_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--gs1nocheck " , strlen ( cmd ) ? " " : " " ) ;
2021-11-21 00:32:30 +13:00
}
if ( input_mode & HEIGHTPERROW_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--heightperrow " , strlen ( cmd ) ? " " : " " ) ;
2021-11-21 00:32:30 +13:00
}
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
static void arg_output_options ( char * cmd , int output_options ) {
2020-08-05 09:44:20 +12:00
if ( output_options ! = - 1 ) {
if ( output_options & BARCODE_BIND ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--bind " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
2022-11-11 11:13:41 +13:00
if ( output_options & BARCODE_BIND_TOP ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--bindtop " , strlen ( cmd ) ? " " : " " ) ;
2022-11-11 11:13:41 +13:00
}
2020-08-05 09:44:20 +12:00
if ( output_options & BARCODE_BOX ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--box " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & BARCODE_STDOUT ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--direct " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & READER_INIT ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--init " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & SMALL_TEXT ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--small " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & BOLD_TEXT ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--bold " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & CMYK_COLOUR ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--cmyk " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & BARCODE_DOTTY_MODE ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--dotty " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
if ( output_options & GS1_GS_SEPARATOR ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--gssep " , strlen ( cmd ) ? " " : " " ) ;
2020-08-05 09:44:20 +12:00
}
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
if ( output_options & BARCODE_QUIET_ZONES ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--quietzones " , strlen ( cmd ) ? " " : " " ) ;
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
}
if ( output_options & BARCODE_NO_QUIET_ZONES ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--noquietzones " , strlen ( cmd ) ? " " : " " ) ;
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
}
if ( output_options & COMPLIANT_HEIGHT ) {
2023-06-12 12:25:55 +12:00
sprintf ( cmd + strlen ( cmd ) , " %s--compliantheight " , strlen ( cmd ) ? " " : " " ) ;
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 12:13:39 +13:00
}
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
2022-09-15 07:23:47 +12:00
/* Tests args that can be detected with `--dump` */
2022-09-13 06:26:04 +12:00
static void test_dump_args ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-08-05 09:22:26 +12:00
struct item {
int b ;
char * data ;
char * data2 ;
2020-08-05 09:44:20 +12:00
char * input ;
char * input2 ;
int input_mode ;
int output_options ;
int batch ;
int cols ;
int dmre ;
int eci ;
int fullmultibyte ;
2020-11-28 01:54:44 +13:00
int mask ;
2020-08-05 09:44:20 +12:00
int mode ;
char * primary ;
int rows ;
int secure ;
int square ;
int vers ;
char * expected ;
2020-08-05 09:22:26 +12:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-08-05 09:22:26 +12:00
struct item data [ ] = {
2020-11-28 01:54:44 +13:00
/* 0*/ { - 1 , " 123 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 13 9B 39 65 C8 C9 8E B " } ,
/* 1*/ { BARCODE_CODE128 , " 123 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 13 9B 39 65 C8 C9 8E B " } ,
/* 2*/ { BARCODE_CODE128 , " 123 " , " 456 " , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 13 9B 39 65 C8 C9 8E B \n D2 19 3B 72 67 4E 4D 8E B " } ,
/* 3*/ { BARCODE_CODE128 , " 123 " , NULL , NULL , NULL , - 1 , - 1 , 1 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " Warning 141: Can't use batch mode if data given, ignoring \n D2 13 9B 39 65 C8 C9 8E B " } ,
/* 4*/ { BARCODE_CODE128 , NULL , NULL , " 123 \n 45 \n " , NULL , - 1 , - 1 , 1 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 13 9B 39 65 C8 C9 8E B \n D3 97 62 3B 63 AC " } ,
/* 5*/ { BARCODE_CODE128 , NULL , NULL , " 123 \n 45 \n " , " 7 \n " , - 1 , - 1 , 1 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " Warning 144: Processing first input file 'test_dump_args1.txt' only \n D2 13 9B 39 65 C8 C9 8E B \n D3 97 62 3B 63 AC " } ,
/* 6*/ { BARCODE_CODE128 , " \t " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D0 90 D2 1A 63 AC " } ,
/* 7*/ { BARCODE_CODE128 , " \\ t " , NULL , NULL , NULL , ESCAPE_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D0 90 D2 1A 63 AC " } ,
2023-01-15 13:22:43 +13:00
/* 8*/ { BARCODE_CODE128 , " \\ ^Ab \011 " , NULL , NULL , NULL , EXTRA_ESCAPE_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 12 1B AF 43 4C A1 8E B " } ,
/* 9*/ { BARCODE_CODE128 , " \\ ^Ab \\ t " , NULL , NULL , NULL , ESCAPE_MODE | EXTRA_ESCAPE_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 12 1B AF 43 4C A1 8E B " } ,
/* 10*/ { BARCODE_CODE128 , " 123 " , NULL , NULL , NULL , - 1 , BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP | SMALL_TEXT | BOLD_TEXT | CMYK_COLOUR , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D2 13 9B 39 65 C8 C9 8E B " } ,
/* 11*/ { BARCODE_CODE128 , " 123 " , NULL , NULL , NULL , - 1 , BARCODE_DOTTY_MODE , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " Error 224: Selected symbology cannot be rendered as dots " } ,
/* 12*/ { BARCODE_CODABLOCKF , " ABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D0 97 BA 86 51 88 B1 11 AC 46 D8 C7 58 \n D0 97 BB 12 46 88 C5 1A 3C 55 CC C7 58 " } ,
/* 13*/ { BARCODE_CODABLOCKF , " ABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , 10 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " D0 97 BA 86 51 88 B1 11 AC 44 68 BC 98 EB \n D0 97 BB 12 46 2B BD 7B A3 47 8A 8D 18 EB " } ,
/* 14*/ { BARCODE_CODABLOCKF , " ABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , 3 , - 1 , 0 , - 1 , " D0 97 BA 58 51 88 B1 11 AC 46 36 C7 58 \n D0 97 BB 12 46 88 C5 77 AF 74 62 C7 58 \n D0 97 BA CE 5D EB DD 1A 3C 56 88 C7 58 " } ,
/* 15*/ { BARCODE_CODE11 , NULL , NULL , " 123 " , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " B2 D6 96 CA B5 6D 64 " } ,
/* 16*/ { BARCODE_CODE11 , NULL , NULL , " 123 " , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , 1 , " B2 D6 96 CA B5 64 " } ,
/* 17*/ { BARCODE_CODE11 , " 123 " , NULL , " 456 " , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , 2 , " B2 D6 96 CA B2 \n B2 B6 DA 9A B2 " } ,
/* 18*/ { BARCODE_CODE11 , " 123 " , " 456 " , " 789 " , " 012 " , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , 2 , " B2 D6 96 CA B2 \n B2 B6 DA 9A B2 \n B2 A6 D2 D5 64 \n B2 AD AD 2D 64 " } ,
/* 19*/ { BARCODE_PDF417 , " 123 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , 0 , 0 , - 1 , " FF 54 7A BC 3A 9C 1D 5C 0F E8 A4 \n FF 54 7E AE 3C 11 5F AB 8F E8 A4 \n FF 54 6A F8 29 9F 1D 5F 8F E8 A4 \n FF 54 57 9E 37 BA 1A F7 CF E8 A4 \n FF 54 75 CC 36 F0 5D 73 0F E8 A4 " } ,
/* 20*/ { BARCODE_DATAMATRIX , " ABC " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA 8 \n B3 4 \n 8F 0 \n B2 C \n A6 0 \n BA C \n D6 0 \n EB 4 \n E2 8 \n FF C " } ,
/* 21*/ { BARCODE_DATAMATRIX , " ABC " , NULL , NULL , NULL , - 1 , READER_INIT , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A \n AC 7 \n 8A 4 \n A0 3 \n C2 2 \n B5 1 \n 82 2 \n BA 7 \n 8C C \n A0 5 \n 86 A \n FF F " } ,
/* 22*/ { BARCODE_DATAMATRIX , " ABCDEFGH " , NULL , NULL , NULL , FAST_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n A6 8C \n B2 F0 \n 98 B4 \n B9 A8 \n B8 CC \n F0 78 \n A0 3C \n 99 70 \n 85 1C \n DA B0 \n E5 94 \n A7 50 \n FF FC " } ,
/* 23*/ { BARCODE_DATAMATRIX , " ABCDEFGH " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n 80 04 \n 82 60 \n C5 24 \n 98 A8 \n A3 9C \n CB B8 \n AF DC \n 86 58 \n F6 44 \n AC 18 \n 90 54 \n CF 30 \n FF FC " } ,
/* 24*/ { BARCODE_DATAMATRIX , " ABCDEFGHIJK " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA AA AA AA \n 80 09 F9 BD \n 82 4A E2 58 \n C5 CD C9 A5 \n D8 5C A5 FC \n E0 35 88 69 \n CC FC B3 E6 \n FF FF FF FF " } ,
/* 25*/ { BARCODE_DATAMATRIX , " ABCDEFGHIJK " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 1 , - 1 , " AA AA \n 80 25 \n 82 24 \n C5 5D \n 98 90 \n A4 C7 \n C8 A6 \n B9 E9 \n 8E 02 \n DE 91 \n CD 6C \n A0 BB \n 85 80 \n 98 2D \n E4 CA \n FF FF " } ,
/* 26*/ { BARCODE_DATAMATRIX , " ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA AA A8 \n BA 5A 44 \n 8B 4D 28 \n BF 77 64 \n 97 85 50 \n BA D8 AC \n CD ED B8 \n D4 B5 2C \n D1 A8 00 \n 81 FB 2C \n E4 75 78 \n 96 E8 2C \n F3 75 78 \n EE 1D 04 \n CA BA 98 \n B1 8F B4 \n A0 4F 00 \n E4 A7 74 \n F1 D3 90 \n EF E1 BC \n 91 10 38 \n FF FF FC " } ,
/* 27*/ { BARCODE_DATAMATRIX , " ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 1 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA AA AA AA AA AA AA AA \n BA 03 BA 7D E5 31 B0 0D \n 8B 6A 93 B6 E0 0A B8 3C \n BF 1D EA A7 EB ED A1 FB \n 96 66 86 B6 C9 AE 92 40 \n BF 65 E7 95 BC B7 FA E3 \n CC 7C 90 CC D1 24 AB 5A \n FF FF FF FF FF FF FF FF " } ,
/* 28*/ { BARCODE_DATAMATRIX , " ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 1 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 1 , - 1 , " AA AA A8 \n BA 5A 44 \n 8B 4D 28 \n BF 77 64 \n 97 85 50 \n BA D8 AC \n CD ED B8 \n D4 B5 2C \n D1 A8 00 \n 81 FB 2C \n E4 75 78 \n 96 E8 2C \n F3 75 78 \n EE 1D 04 \n CA BA 98 \n B1 8F B4 \n A0 4F 00 \n E4 A7 74 \n F1 D3 90 \n EF E1 BC \n 91 10 38 \n FF FF FC " } ,
/* 29*/ { BARCODE_DATAMATRIX , " [91]12[92]34 " , NULL , NULL , NULL , GS1_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n FA 9C \n BC 00 \n D7 84 \n ED E0 \n A4 E4 \n A7 40 \n 9D 3C \n BF 50 \n FA 24 \n B1 68 \n E5 04 \n 92 70 \n FF FC " } ,
/* 30*/ { BARCODE_DATAMATRIX , " [91]12[92]34 " , NULL , NULL , NULL , GS1_MODE , GS1_GS_SEPARATOR , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n F9 DC \n BF 20 \n D6 C4 \n ED 10 \n A0 0C \n A7 C0 \n 96 5C \n BA 70 \n BB A4 \n E2 18 \n DD 14 \n 9C 40 \n FF FC " } ,
/* 31*/ { BARCODE_DATAMATRIX , " [9 \\ x31]12[92]34 " , NULL , NULL , NULL , GS1_MODE | ESCAPE_MODE , GS1_GS_SEPARATOR , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n F9 DC \n BF 20 \n D6 C4 \n ED 10 \n A0 0C \n A7 C0 \n 96 5C \n BA 70 \n BB A4 \n E2 18 \n DD 14 \n 9C 40 \n FF FC " } ,
/* 32*/ { BARCODE_DATAMATRIX , " (9 \\ x31)12(92)34 " , NULL , NULL , NULL , GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE , GS1_GS_SEPARATOR , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " AA A8 \n F9 DC \n BF 20 \n D6 C4 \n ED 10 \n A0 0C \n A7 C0 \n 96 5C \n BA 70 \n BB A4 \n E2 18 \n DD 14 \n 9C 40 \n FF FC " } ,
/* 33*/ { BARCODE_EANX_CC , " [91]12 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , " 12345678+12 " , - 1 , - 1 , 0 , - 1 , " DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00 \n DB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00 \n DA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00 \n 10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 \n 20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 \n 10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 \n 14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98 " } ,
/* 34*/ { BARCODE_EANX_CC , " [91]12 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , 2 , " 12345678+12 " , - 1 , - 1 , 0 , - 1 , " D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00 \n D3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00 \n D1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00 \n D1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00 \n 10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 \n 20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 \n 10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 \n 14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98 " } ,
/* 35*/ { BARCODE_QRCODE , " 点 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " Warning 760: Converted to Shift JIS but no ECI specified \n FE 2B F8 \n 82 AA 08 \n BA B2 E8 \n BA 0A E8 \n BA FA E8 \n 82 E2 08 \n FE AB F8 \n 00 80 00 \n D3 3B B0 \n 60 95 68 \n 7A B3 A0 \n 1D 0F 98 \n AA D7 30 \n 00 E6 A8 \n FE DA D0 \n 82 42 20 \n BA 0E 38 \n BA C7 18 \n BA 17 68 \n 82 B9 40 \n FE C5 28 " } ,
/* 36*/ { BARCODE_QRCODE , " 点 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , 26 , 0 , - 1 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " FE 5B F8 \n 82 72 08 \n BA DA E8 \n BA 52 E8 \n BA 2A E8 \n 82 0A 08 \n FE AB F8 \n 00 D8 00 \n EF F6 20 \n B5 C2 28 \n 36 28 88 \n FD 42 10 \n 62 2A C8 \n 00 95 70 \n FE B7 38 \n 82 FD D8 \n BA 97 00 \n BA 43 60 \n BA C8 C8 \n 82 C3 68 \n FE EA F8 " } ,
/* 37*/ { BARCODE_QRCODE , " \223 \137 " , NULL , NULL , NULL , DATA_MODE , - 1 , 0 , - 1 , 0 , - 1 , 0 , - 1 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " FE 2B F8 \n 82 0A 08 \n BA A2 E8 \n BA 0A E8 \n BA 5A E8 \n 82 72 08 \n FE AB F8 \n 00 A0 00 \n EF AE 20 \n 75 B5 20 \n 82 F7 58 \n F4 9D C8 \n 5E 17 28 \n 00 C2 20 \n FE 88 80 \n 82 82 38 \n BA EA A8 \n BA 55 50 \n BA D7 68 \n 82 BD D0 \n FE B7 78 " } ,
/* 38*/ { BARCODE_QRCODE , " \223 \137 " , NULL , NULL , NULL , DATA_MODE , - 1 , 0 , - 1 , 0 , - 1 , 1 , - 1 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " FE 2B F8 \n 82 AA 08 \n BA B2 E8 \n BA 0A E8 \n BA FA E8 \n 82 E2 08 \n FE AB F8 \n 00 80 00 \n D3 3B B0 \n 60 95 68 \n 7A B3 A0 \n 1D 0F 98 \n AA D7 30 \n 00 E6 A8 \n FE DA D0 \n 82 42 20 \n BA 0E 38 \n BA C7 18 \n BA 17 68 \n 82 B9 40 \n FE C5 28 " } ,
/* 39*/ { BARCODE_QRCODE , " \\ x93 \\ x5F " , NULL , NULL , NULL , DATA_MODE | ESCAPE_MODE , - 1 , 0 , - 1 , 0 , - 1 , 1 , - 1 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " FE 2B F8 \n 82 AA 08 \n BA B2 E8 \n BA 0A E8 \n BA FA E8 \n 82 E2 08 \n FE AB F8 \n 00 80 00 \n D3 3B B0 \n 60 95 68 \n 7A B3 A0 \n 1D 0F 98 \n AA D7 30 \n 00 E6 A8 \n FE DA D0 \n 82 42 20 \n BA 0E 38 \n BA C7 18 \n BA 17 68 \n 82 B9 40 \n FE C5 28 " } ,
/* 40*/ { BARCODE_QRCODE , " 点 " , NULL , NULL , NULL , - 1 , - 1 , 0 , - 1 , 0 , - 1 , 0 , 2 , - 1 , NULL , - 1 , 1 , 0 , - 1 , " Warning 760: Converted to Shift JIS but no ECI specified \n FE 4B F8 \n 82 92 08 \n BA 42 E8 \n BA 92 E8 \n BA 3A E8 \n 82 EA 08 \n FE AB F8 \n 00 38 00 \n FB CD 50 \n A5 89 18 \n 0B 74 B8 \n FC 81 A0 \n 92 34 B8 \n 00 DE 48 \n FE AB 10 \n 82 5E 50 \n BA C9 20 \n BA C9 20 \n BA F4 E0 \n 82 81 A0 \n FE B4 E8 " } ,
/* 41*/ { BARCODE_HANXIN , " é " , NULL , NULL , NULL , DATA_MODE , - 1 , 0 , - 1 , 0 , - 1 , 1 , - 1 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " FE 8A FE \n 80 28 02 \n BE E8 FA \n A0 94 0A \n AE 3E EA \n AE D2 EA \n AE 74 EA \n 00 AA 00 \n 15 B4 80 \n 0B 48 74 \n A2 4A A4 \n B5 56 2C \n A8 5A A8 \n 9F 18 50 \n 02 07 50 \n 00 A6 00 \n FE 20 EA \n 02 C2 EA \n FA C4 EA \n 0A 42 0A \n EA 52 FA \n EA 24 02 \n EA AA FE " } ,
/* 42*/ { BARCODE_HANXIN , " é " , NULL , NULL , NULL , DATA_MODE , - 1 , 0 , - 1 , 0 , - 1 , 1 , 3 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " FE 16 FE \n 80 E2 02 \n BE C2 FA \n A0 A0 0A \n AE F6 EA \n AE 98 EA \n AE BA EA \n 00 E0 00 \n 15 83 80 \n 44 7E AE \n 92 9C 78 \n 25 BF 08 \n 47 4B 8C \n 0D F9 74 \n 03 E7 50 \n 00 3A 00 \n FE C2 EA \n 02 22 EA \n FA DA EA \n 0A 22 0A \n EA B2 FA \n EA 9A 02 \n EA E8 FE " } ,
/* 43*/ { BARCODE_HANXIN , " é " , NULL , NULL , NULL , DATA_MODE , - 1 , 0 , - 1 , 0 , - 1 , 1 , 4 , - 1 , NULL , - 1 , - 1 , 0 , - 1 , " FE 8A FE \n 80 28 02 \n BE E8 FA \n A0 94 0A \n AE 3E EA \n AE D2 EA \n AE 74 EA \n 00 AA 00 \n 15 B4 80 \n 0B 48 74 \n A2 4A A4 \n B5 56 2C \n A8 5A A8 \n 9F 18 50 \n 02 07 50 \n 00 A6 00 \n FE 20 EA \n 02 C2 EA \n FA C4 EA \n 0A 42 0A \n EA 52 FA \n EA 24 02 \n EA AA FE " } ,
2020-08-05 09:22:26 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char * input1_filename = " test_dump_args1.txt " ;
char * input2_filename = " test_dump_args2.txt " ;
int have_input1 ;
int have_input2 ;
2020-08-05 09:22:26 +12:00
2021-06-24 02:00:49 +12:00
testStart ( " test_dump_args " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
strcpy ( cmd , " zint --dump " ) ;
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
arg_data ( cmd , " -d " , data [ i ] . data2 ) ;
have_input1 = arg_input ( cmd , input1_filename , data [ i ] . input ) ;
have_input2 = arg_input ( cmd , input2_filename , data [ i ] . input2 ) ;
arg_input_mode ( cmd , data [ i ] . input_mode ) ;
arg_output_options ( cmd , data [ i ] . output_options ) ;
arg_bool ( cmd , " --batch " , data [ i ] . batch ) ;
arg_int ( cmd , " --cols= " , data [ i ] . cols ) ;
arg_bool ( cmd , " --dmre " , data [ i ] . dmre ) ;
arg_int ( cmd , " --eci= " , data [ i ] . eci ) ;
arg_bool ( cmd , " --fullmultibyte " , data [ i ] . fullmultibyte ) ;
2020-11-28 01:54:44 +13:00
arg_int ( cmd , " --mask= " , data [ i ] . mask ) ;
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " --mode= " , data [ i ] . mode ) ;
arg_data ( cmd , " --primary= " , data [ i ] . primary ) ;
arg_int ( cmd , " --rows= " , data [ i ] . rows ) ;
arg_int ( cmd , " --secure= " , data [ i ] . secure ) ;
arg_bool ( cmd , " --square " , data [ i ] . square ) ;
arg_int ( cmd , " --vers= " , data [ i ] . vers ) ;
strcat ( cmd , " 2>&1 " ) ;
2020-08-05 09:22:26 +12:00
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2020-11-28 01:54:44 +13:00
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
2020-08-05 09:44:20 +12:00
if ( have_input1 ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input1_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input1_filename , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
}
if ( have_input2 ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input2_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input2_filename , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
testFinish ( ) ;
2020-12-18 15:36:48 +13:00
}
2020-08-05 09:22:26 +12:00
2022-09-15 07:23:47 +12:00
/* Tests segs */
2022-09-13 06:26:04 +12:00
static void test_dump_segs ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
struct item {
int b ;
char * data ;
char * data_seg1 ;
char * data_seg2 ;
int eci ;
int eci_seg1 ;
int eci_seg2 ;
char * expected ;
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
struct item data [ ] = {
/* 0*/ { - 1 , " 123 " , NULL , NULL , - 1 , - 1 , - 1 , " D2 13 9B 39 65 C8 C9 8E B " } ,
/* 1*/ { - 1 , " 123 " , NULL , NULL , - 1 , 3 , - 1 , " Error 166: Invalid segment argument, expect \" ECI,DATA \" " } ,
/* 2*/ { - 1 , " 123 " , " 456 " , NULL , - 1 , - 1 , - 1 , " Error 167: Invalid segment ECI (digits only) " } ,
/* 3*/ { - 1 , " 123 " , " 456 " , NULL , - 1 , 1000000 , - 1 , " Error 168: Segment ECI code out of range (0 to 999999) " } ,
/* 4*/ { - 1 , " 123 " , " 456 " , NULL , - 1 , 3 , - 1 , " Error 775: Symbology does not support multiple segments " } ,
/* 5*/ { BARCODE_AZTEC , " 123 " , " 456 " , NULL , - 1 , 3 , - 1 , " 2B 7A \n C7 02 \n F0 6E \n 3F FE \n 70 1C \n B7 D6 \n B4 58 \n 15 54 \n 94 56 \n B7 DC \n 30 1A \n 1F FC \n 4C 66 \n 22 DA \n 1E C6 " } ,
/* 6*/ { BARCODE_AZTEC , " 123 " , NULL , " 789 " , - 1 , - 1 , 3 , " Error 172: Segments must be consecutive - segment 1 missing " } ,
} ;
int data_size = ARRAY_SIZE ( data ) ;
int i ;
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
testStart ( " test_dump_segs " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
strcpy ( cmd , " zint --dump " ) ;
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
arg_int ( cmd , " -b " , data [ i ] . b ) ;
if ( data [ i ] . data & & data [ i ] . data [ 0 ] ) {
arg_data ( cmd , " -d " , data [ i ] . data ) ;
}
if ( data [ i ] . eci > 0 ) {
arg_int ( cmd , " --eci= " , data [ i ] . eci ) ;
}
if ( data [ i ] . data_seg1 & & data [ i ] . data_seg1 [ 0 ] ) {
arg_seg ( cmd , " --seg1= " , data [ i ] . data_seg1 , data [ i ] . eci_seg1 ) ;
} else if ( data [ i ] . eci_seg1 > = 0 ) {
arg_seg ( cmd , " --seg1= " , NULL , data [ i ] . eci_seg1 ) ;
}
if ( data [ i ] . data_seg2 & & data [ i ] . data_seg2 [ 0 ] ) {
arg_seg ( cmd , " --seg2= " , data [ i ] . data_seg2 , data [ i ] . eci_seg2 ) ;
} else if ( data [ i ] . eci_seg2 > = 0 ) {
arg_seg ( cmd , " --seg2= " , NULL , data [ i ] . eci_seg2 ) ;
}
strcat ( cmd , " 2>&1 " ) ;
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
}
testFinish ( ) ;
}
2022-09-13 06:26:04 +12:00
static void test_input ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-08-05 09:22:26 +12:00
2021-06-10 22:15:39 +12:00
# define TEST_INPUT_LONG "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
2022-12-06 01:55:28 +13:00
# define TEST_MIRRORED_DIR_LONG "testdir_9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 / "
# define TEST_MIRRORED_DIR_TOO_LONG "testdir_901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 / "
2022-07-05 08:55:06 +12:00
# ifndef _WIN32
# define TEST_INPUT_AMPERSAND_EXPECTED "***1.gif\000***2.gif"
# else
# define TEST_INPUT_AMPERSAND_EXPECTED "+++1.gif\000+++2.gif"
# endif
2022-07-09 06:16:02 +12:00
2020-08-05 09:22:26 +12:00
struct item {
int b ;
2020-08-05 09:44:20 +12:00
int batch ;
2021-01-16 03:22:32 +13:00
int input_mode ;
2020-08-05 09:44:20 +12:00
int mirror ;
char * filetype ;
2023-05-11 08:29:09 +12:00
char * input_filename ;
2020-08-05 09:44:20 +12:00
char * input ;
char * outfile ;
int num_expected ;
char * expected ;
2020-08-05 09:22:26 +12:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-08-05 09:22:26 +12:00
struct item data [ ] = {
2023-05-11 08:29:09 +12:00
/* 0*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n 456 \n " , " " , 2 , " 00001.gif \000 00002.gif " } ,
/* 1*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \n 9 \n 10 \n " , " ~~~.gif " , 10 , " 001.gif \000 002.gif \000 003.gif \000 004.gif \000 005.gif \000 006.gif \000 007.gif \000 008.gif \000 009.gif \000 010.gif " } ,
/* 2*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n 456 \n " , " @@@@.gif " , 2 , TEST_INPUT_AMPERSAND_EXPECTED } ,
/* 3*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n 456 \n 789 \n " , " #####.gif " , 3 , " 1.gif \000 2.gif \000 3.gif " } ,
/* 4*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n 456 \n " , " test_batch~.gif " , 2 , " test_batch1.gif \000 test_batch2.gif " } ,
/* 5*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n " , NULL , 3 , " 123.gif \000 456.gif \000 7890123456789.gif " } ,
/* 6*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n " , " test_input_dir/ " , 3 , " test_input_dir/123.gif \000 test_input_dir/456.gif \000 test_input_dir/7890123456789.gif " } ,
/* 7*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " svg " , NULL , " 123 \n 456 \n 7890123456789 \n " , NULL , 3 , " 123.svg \000 456.svg \000 7890123456789.svg " } ,
/* 8*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n A \\ xA0B \n " , NULL , 4 , " 123.gif \000 456.gif \000 7890123456789.gif \000 A_xA0B.gif " } ,
/* 9*/ { BARCODE_CODE128 , 1 , ESCAPE_MODE , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n A \\ xA0B \n " , NULL , 4 , " 123.gif \000 456.gif \000 7890123456789.gif \000 A_B.gif " } ,
/* 10*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n A \\ u00A0B \n " , NULL , 4 , " 123.gif \000 456.gif \000 7890123456789.gif \000 A_u00A0B.gif " } ,
/* 11*/ { BARCODE_CODE128 , 1 , ESCAPE_MODE , 1 , " gif " , NULL , " 123 \n 456 \n 7890123456789 \n A \\ u00A0B \n " , NULL , 4 , " 123.gif \000 456.gif \000 7890123456789.gif \000 A_B.gif " } ,
/* 12*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 1!2 \" 3* \n /:45<6> \n ?7890 \\ \\ 12345|6789 \177 \n A \\ U0000A0B \n " , NULL , 4 , " 1_2_3_.gif \000 __45_6_.gif \000 _7890__12345_6789_.gif \000 A_U0000A0B.gif " } ,
/* 13*/ { BARCODE_CODE128 , 1 , ESCAPE_MODE , 1 , " gif " , NULL , " ! \" * \n /:45<6> \n ?7890 \\ \\ 12345|6789 \177 \n A \\ U0000A0B \n " , NULL , 4 , " ___.gif \000 __45_6_.gif \000 _7890_12345_6789_.gif \000 A_B.gif " } ,
/* 14*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 1 \\ d123*9 \n \\ o1234:5 \n #$%&'()+,-.;=@[]^`{} \n " , NULL , 3 , " 1_d123_9.gif \000 _o1234_5.gif \000 #$%&'()+,-.;=@[]^`{}.gif " } ,
/* 15*/ { BARCODE_CODE128 , 1 , ESCAPE_MODE , 1 , " gif " , NULL , " 1 \\ d123*2 \n \\ o1234:5 \n #$%&'()+,-.;=@[]^`{} \n " , NULL , 3 , " 1__2.gif \000 _4_5.gif \000 #$%&'()+,-.;=@[]^`{}.gif " } ,
/* 16*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " \n " , " test_batch.gif " , 0 , NULL } ,
/* 17*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n 456 \n " , TEST_INPUT_LONG " ~.gif " , 2 , TEST_INPUT_LONG " 1.gif \000 " TEST_INPUT_LONG " 2.gif " } ,
/* 18*/ { BARCODE_CODE128 , 0 , - 1 , 0 , " svg " , NULL , " 123 " , TEST_INPUT_LONG " 1.gif " , 1 , TEST_INPUT_LONG " 1.svg " } ,
/* 19*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " svg " , NULL , " 123 \n " , TEST_INPUT_LONG " 1.gif " , 1 , TEST_INPUT_LONG " 1.svg " } ,
/* 20*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n " , " test_batch.jpeg " , 1 , " test_batch.jpeg.gif " } ,
/* 21*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , NULL , " 123 \n " , " test_batch.jpg " , 1 , " test_batch.gif " } ,
/* 22*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " emf " , NULL , " 123 \n " , " test_batch.jpeg " , 1 , " test_batch.jpeg.emf " } ,
/* 23*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " emf " , NULL , " 123 \n " , " test_batch.jpg " , 1 , " test_batch.emf " } ,
/* 24*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " eps " , NULL , " 123 \n " , " test_batch.ps " , 1 , " test_batch.eps " } ,
/* 25*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 1234567890123456789012345678901 \n 1234567890123456789012345678902 \n " , TEST_MIRRORED_DIR_LONG , 2 , TEST_MIRRORED_DIR_LONG " 1234567890123456789012345678901.gif \000 " TEST_MIRRORED_DIR_LONG " 1234567890123456789012345678902.gif " } ,
/* 26*/ { BARCODE_CODE128 , 1 , - 1 , 1 , " gif " , NULL , " 123 \n 456 \n " , TEST_MIRRORED_DIR_TOO_LONG , 2 , " 123.gif \000 456.gif " } ,
/* 27*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , " testé_input.txt " , " 123 \n 456 \n " , " " , 2 , " 00001.gif \000 00002.gif " } ,
/* 28*/ { BARCODE_CODE128 , 1 , - 1 , 0 , " gif " , " testก_input.txt " , " 123 \n 456 \n " , " test_input_δir/testé~~~.gif " , 2 , " test_input_δir/testé001.gif \000 test_input_δir/testé002.gif " } ,
2020-08-05 09:22:26 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
2020-08-05 09:22:26 +12:00
2023-05-11 08:29:09 +12:00
char * input_filename ;
2020-08-05 09:44:20 +12:00
char * outfile ;
2020-08-05 09:22:26 +12:00
2021-06-24 02:00:49 +12:00
testStart ( " test_input " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
int j ;
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2021-06-30 02:43:42 +12:00
# ifdef _WIN32
if ( data [ i ] . outfile & & ( int ) strlen ( data [ i ] . outfile ) > 50 ) {
if ( debug & ZINT_DEBUG_TEST_PRINT ) printf ( " %d not Windows compatible (outfile length %d > 50) \n " , i , ( int ) strlen ( data [ i ] . outfile ) ) ;
continue ;
}
# endif
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
strcpy ( cmd , " zint " ) ;
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_bool ( cmd , " --batch " , data [ i ] . batch ) ;
2021-01-16 03:22:32 +13:00
arg_input_mode ( cmd , data [ i ] . input_mode ) ;
2020-08-05 09:44:20 +12:00
arg_bool ( cmd , " --mirror " , data [ i ] . mirror ) ;
arg_data ( cmd , " --filetype= " , data [ i ] . filetype ) ;
2023-05-11 08:29:09 +12:00
input_filename = data [ i ] . input_filename ? data [ i ] . input_filename : " test_input.txt " ;
2020-08-05 09:44:20 +12:00
arg_input ( cmd , input_filename , data [ i ] . input ) ;
arg_data ( cmd , " -o " , data [ i ] . outfile ) ;
2020-08-05 09:22:26 +12:00
2023-06-12 12:25:55 +12:00
if ( ! data [ i ] . expected
| | ( data [ i ] . batch & & data [ i ] . mirror & & data [ i ] . outfile & & data [ i ] . outfile [ 0 ]
& & strcmp ( data [ i ] . outfile , TEST_MIRRORED_DIR_LONG ) = = 0 ) ) {
printf ( " ++++ Following %s expected, ignore: " , data [ i ] . expected ? " warning " : " error " ) ;
fflush ( stdout ) ;
2022-12-06 01:55:28 +13:00
}
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
outfile = data [ i ] . expected ;
2021-06-24 02:00:49 +12:00
for ( j = 0 ; j < data [ i ] . num_expected ; j + + ) {
2020-08-05 09:44:20 +12:00
assert_nonzero ( testUtilExists ( outfile ) , " i:%d j:%d testUtilExists(%s) != 1 \n " , i , j , outfile ) ;
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( outfile ) , " i:%d j:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , j , outfile , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
outfile + = strlen ( outfile ) + 1 ;
}
2020-08-05 09:22:26 +12:00
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input_filename , errno , strerror ( errno ) ) ;
2022-12-06 01:55:28 +13:00
if ( data [ i ] . batch & & data [ i ] . mirror & & data [ i ] . outfile & & data [ i ] . outfile [ 0 ] & & strcmp ( data [ i ] . outfile , TEST_MIRRORED_DIR_TOO_LONG ) ! = 0 ) {
assert_zero ( testUtilRmDir ( data [ i ] . outfile ) , " i:%d testUtilRmDir(%s) != 0 (%d: %s) \n " , i , data [ i ] . outfile , errno , strerror ( errno ) ) ;
}
2020-08-05 09:22:26 +12:00
}
testFinish ( ) ;
2020-12-18 15:36:48 +13:00
}
2022-09-13 06:26:04 +12:00
static void test_stdin_input ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-12-18 15:36:48 +13:00
struct item {
int b ;
char * data ;
char * input ;
char * outfile ;
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-12-18 15:36:48 +13:00
struct item data [ ] = {
2021-06-10 22:15:39 +12:00
/* 0*/ { BARCODE_CODE128 , " 123 " , " - " , " test_stdin_input.gif " } ,
2020-12-18 15:36:48 +13:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-12-18 15:36:48 +13:00
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
char * input_filename = " - " ;
2021-06-24 02:00:49 +12:00
testStart ( " test_stdin_input " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2020-12-18 15:36:48 +13:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2020-12-18 15:36:48 +13:00
sprintf ( cmd , " echo '%s' | zint " , data [ i ] . data ) ;
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_input ( cmd , input_filename , data [ i ] . input ) ;
arg_data ( cmd , " -o " , data [ i ] . outfile ) ;
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2020-12-18 15:36:48 +13:00
assert_nonzero ( testUtilExists ( data [ i ] . outfile ) , " i:%d testUtilExists(%s) != 1 \n " , i , data [ i ] . outfile ) ;
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( data [ i ] . outfile ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , data [ i ] . outfile , errno , strerror ( errno ) ) ;
2020-12-18 15:36:48 +13:00
}
testFinish ( ) ;
}
2020-08-05 09:22:26 +12:00
2022-09-15 07:23:47 +12:00
/* Note ordering of `--batch` before/after data/input args affects error messages */
2022-09-13 06:26:04 +12:00
static void test_batch_input ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-08-05 09:22:26 +12:00
struct item {
int b ;
char * data ;
2020-08-05 09:44:20 +12:00
char * input ;
char * input2 ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char * expected ;
2020-08-05 09:22:26 +12:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-08-05 09:22:26 +12:00
struct item data [ ] = {
2020-08-05 09:44:20 +12:00
/* 0*/ { BARCODE_CODE128 , " 123 " , NULL , NULL , " Warning 122: Can't define data in batch mode, ignoring '123' \n Warning 124: No data received, no symbol generated " } ,
/* 1*/ { BARCODE_CODE128 , " 123 " , " 123 \n 456 \n " , NULL , " Warning 122: Can't define data in batch mode, ignoring '123' \n D2 13 9B 39 65 C8 C9 8E B \n D2 19 3B 72 67 4E 4D 8E B " } ,
/* 3*/ { BARCODE_CODE128 , NULL , " 123 \n 456 \n " , " 789 \n " , " Warning 143: Can only define one input file in batch mode, ignoring 'test_batch_input2.txt' \n D2 13 9B 39 65 C8 C9 8E B \n D2 19 3B 72 67 4E 4D 8E B " } ,
2020-08-05 09:22:26 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char * input1_filename = " test_batch_input1.txt " ;
char * input2_filename = " test_batch_input2.txt " ;
int have_input1 ;
int have_input2 ;
2020-08-05 09:22:26 +12:00
2021-06-24 02:00:49 +12:00
testStart ( " test_batch_input " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
strcpy ( cmd , " zint --dump --batch " ) ;
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
have_input1 = arg_input ( cmd , input1_filename , data [ i ] . input ) ;
have_input2 = arg_input ( cmd , input2_filename , data [ i ] . input2 ) ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
strcat ( cmd , " 2>&1 " ) ;
2020-08-05 09:22:26 +12:00
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2020-08-05 09:44:20 +12:00
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d buf (%s) != expected (%s) \n " , i , buf , data [ i ] . expected ) ;
if ( have_input1 ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input1_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input1_filename , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
}
if ( have_input2 ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input2_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input2_filename , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
testFinish ( ) ;
2020-12-18 15:36:48 +13:00
}
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
static void test_batch_large ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-08-05 09:22:26 +12:00
struct item {
int b ;
int mirror ;
char * pattern ;
2020-08-05 09:44:20 +12:00
int length ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char * expected ;
2020-08-05 09:22:26 +12:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-08-05 09:22:26 +12:00
struct item data [ ] = {
2022-07-05 07:14:20 +12:00
/* 0*/ { BARCODE_HANXIN , 0 , " 1 " , 7827 , " 00001.gif " } ,
2021-06-10 22:15:39 +12:00
/* 1*/ { BARCODE_HANXIN , 1 , " 1 " , 7827 , " 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.gif " } ,
2020-08-05 09:44:20 +12:00
/* 2*/ { BARCODE_HANXIN , 0 , " 1 " , 7828 , NULL } ,
2020-08-05 09:22:26 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char cmd [ 16384 ] ;
char data_buf [ 8192 ] ;
char buf [ 16384 ] ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char * input_filename = " test_batch_large.txt " ;
int have_input ;
2020-08-05 09:22:26 +12:00
2021-06-24 02:00:49 +12:00
testStart ( " test_batch_large " ) ;
# ifdef _WIN32
testSkip ( " Test not compatible with Windows " ) ;
return ;
# endif
for ( i = 0 ; i < data_size ; i + + ) {
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2020-08-05 09:22:26 +12:00
2021-06-10 22:15:39 +12:00
strcpy ( cmd , " zint --batch --filetype=gif " ) ;
2020-08-05 09:44:20 +12:00
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_bool ( cmd , " --mirror " , data [ i ] . mirror ) ;
2020-08-05 09:22:26 +12:00
testUtilStrCpyRepeat ( data_buf , data [ i ] . pattern , data [ i ] . length ) ;
2020-08-05 09:44:20 +12:00
strcat ( data_buf , " \n " ) ;
have_input = arg_input ( cmd , input_filename , data_buf ) ;
2020-08-05 09:22:26 +12:00
2023-06-12 12:25:55 +12:00
if ( ! data [ i ] . expected ) {
printf ( " ++++ Following error expected, ignore: " ) ;
fflush ( stdout ) ;
}
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2020-08-05 09:44:20 +12:00
if ( data [ i ] . expected ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( data [ i ] . expected ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , data [ i ] . expected , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
} else {
2021-06-10 22:15:39 +12:00
assert_zero ( testUtilExists ( " out.gif " ) , " i:%d testUtilExists(out.gif) != 0 (%d: %s) (%s) \n " , i , errno , strerror ( errno ) , cmd ) ;
2020-08-05 09:44:20 +12:00
}
if ( have_input ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( input_filename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , input_filename , errno , strerror ( errno ) ) ;
2020-08-05 09:44:20 +12:00
}
2020-08-05 09:22:26 +12:00
}
testFinish ( ) ;
2020-12-18 15:36:48 +13:00
}
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
static void test_checks ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2020-08-05 09:22:26 +12:00
struct item {
2020-08-05 09:44:20 +12:00
int addongap ;
int border ;
int cols ;
double dotsize ;
2023-02-11 03:44:10 +13:00
double textgap ;
2020-08-05 09:44:20 +12:00
int eci ;
char * filetype ;
2021-09-22 11:04:15 +12:00
double height ;
double guard_descent ;
2020-11-28 01:54:44 +13:00
int mask ;
2020-08-05 09:44:20 +12:00
int mode ;
int rotate ;
int rows ;
double scale ;
2021-01-21 10:15:03 +13:00
int scmvv ;
2020-08-05 09:44:20 +12:00
int secure ;
int separator ;
int vers ;
2021-05-26 07:42:26 +12:00
int vwhitesp ;
2020-08-05 09:44:20 +12:00
int w ;
char * expected ;
2020-08-05 09:22:26 +12:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2020-08-05 09:22:26 +12:00
struct item data [ ] = {
2023-02-11 03:44:10 +13:00
/* 0*/ { - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 139: Invalid add-on gap value (digits only) " } ,
/* 1*/ { 6 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 140: Add-on gap out of range (7 to 12), ignoring " } ,
/* 2*/ { 13 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 140: Add-on gap out of range (7 to 12), ignoring " } ,
/* 3*/ { - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 107: Invalid border width value (digits only) " } ,
/* 4*/ { - 1 , 1001 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 108: Border width out of range (0 to 1000), ignoring " } ,
/* 5*/ { - 1 , - 1 , - 1 , - 1 , - 0.5 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 194: Invalid text gap floating point (integer part must be digits only) " } ,
/* 6*/ { - 1 , - 1 , - 1 , - 1 , 5.01 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 195: Text gap '5.01' out of range (0 to 5), ignoring " } ,
/* 7*/ { - 1 , - 1 , - 1 , 12345678 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 181: Invalid dot radius floating point (integer part must be 7 digits maximum) " } ,
/* 8*/ { - 1 , - 1 , - 1 , 0.009 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 106: Invalid dot radius value (less than 0.01), ignoring " } ,
/* 9*/ { - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 131: Invalid columns value (digits only) " } ,
/* 10*/ { - 1 , - 1 , 201 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 111: Number of columns out of range (1 to 200), ignoring " } ,
/* 11*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 138: Invalid ECI value (digits only) " } ,
/* 12*/ { - 1 , - 1 , - 1 , - 1 , - 1 , 1000000 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 118: ECI code out of range (0 to 999999), ignoring " } ,
/* 13*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " jpg " , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 142: File type 'jpg' not supported, ignoring " } ,
/* 14*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 183: Invalid symbol height floating point (integer part must be digits only) " } ,
/* 15*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , 0 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 110: Symbol height '0' out of range (0.5 to 2000), ignoring " } ,
/* 16*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , 2001 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 110: Symbol height '2001' out of range (0.5 to 2000), ignoring " } ,
/* 17*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 182: Invalid guard bar descent floating point (integer part must be digits only) " } ,
/* 18*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , 50.1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 135: Guard bar descent '50.1' out of range (0 to 50), ignoring " } ,
/* 19*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 148: Invalid mask value (digits only) " } ,
/* 20*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , 8 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 147: Mask value out of range (0 to 7), ignoring " } ,
/* 21*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , 7 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 116: Mode value out of range (0 to 6), ignoring " } ,
/* 22*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 117: Invalid rotation value (digits only) " } ,
/* 23*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , 45 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 137: Invalid rotation parameter (0, 90, 180 or 270 only), ignoring " } ,
/* 24*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 132: Invalid rows value (digits only) " } ,
/* 25*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , 91 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 112: Number of rows out of range (1 to 90), ignoring " } ,
/* 26*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 184: Invalid scale floating point (integer part must be digits only) " } ,
/* 27*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 0.49 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 146: Scaling less than 0.5 will be set to 0.5 for 'gif' output " } ,
/* 28*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , - 1 , " Error 149: Invalid Structured Carrier Message version value (digits only) " } ,
/* 29*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 100 , - 1 , - 1 , - 1 , - 1 , - 1 , " Warning 150: Structured Carrier Message version out of range (0 to 99), ignoring " } ,
/* 30*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , - 1 , " Error 134: Invalid ECC value (digits only) " } ,
/* 31*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 9 , - 1 , - 1 , - 1 , - 1 , " Warning 114: ECC level out of range (0 to 8), ignoring " } ,
/* 32*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , - 1 , " Error 128: Invalid separator value (digits only) " } ,
/* 33*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 5 , - 1 , - 1 , - 1 , " Warning 127: Separator value out of range (0 to 4), ignoring " } ,
/* 34*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , - 1 , " Error 133: Invalid version value (digits only) " } ,
/* 35*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 1000 , - 1 , - 1 , " Warning 113: Version value out of range (1 to 999), ignoring " } ,
/* 36*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , - 1 , " Error 153: Invalid vertical whitespace value '-2' (digits only) " } ,
/* 37*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 1001 , - 1 , " Warning 154: Vertical whitespace value out of range (0 to 1000), ignoring " } ,
/* 38*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 2 , " Error 120: Invalid horizontal whitespace value '-2' (digits only) " } ,
/* 39*/ { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , NULL , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 1001 , " Warning 121: Horizontal whitespace value out of range (0 to 1000), ignoring " } ,
2020-08-05 09:22:26 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2020-08-05 09:22:26 +12:00
2020-08-05 09:44:20 +12:00
char cmd [ 4096 ] ;
char buf [ 4096 ] ;
2022-09-06 02:11:46 +12:00
const char * outfilename = " out.gif " ;
2020-08-05 09:22:26 +12:00
2021-06-24 02:00:49 +12:00
testStart ( " test_checks " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2020-08-05 09:22:26 +12:00
2021-06-10 22:15:39 +12:00
strcpy ( cmd , " zint -d 1 --filetype=gif " ) ;
2020-08-05 09:44:20 +12:00
if ( debug & ZINT_DEBUG_PRINT ) {
strcat ( cmd , " --verbose " ) ;
}
arg_int ( cmd , " --addongap= " , data [ i ] . addongap ) ;
arg_int ( cmd , " --border= " , data [ i ] . border ) ;
arg_int ( cmd , " --cols= " , data [ i ] . cols ) ;
arg_double ( cmd , " --dotsize= " , data [ i ] . dotsize ) ;
2023-02-11 03:44:10 +13:00
arg_double ( cmd , " --textgap= " , data [ i ] . textgap ) ;
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " --eci= " , data [ i ] . eci ) ;
arg_data ( cmd , " --filetype= " , data [ i ] . filetype ) ;
2021-09-22 11:04:15 +12:00
arg_double ( cmd , " --height= " , data [ i ] . height ) ;
arg_double ( cmd , " --guarddescent= " , data [ i ] . guard_descent ) ;
2020-11-28 01:54:44 +13:00
arg_int ( cmd , " --mask= " , data [ i ] . mask ) ;
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " --mode= " , data [ i ] . mode ) ;
arg_int ( cmd , " --rotate= " , data [ i ] . rotate ) ;
arg_int ( cmd , " --rows= " , data [ i ] . rows ) ;
arg_double ( cmd , " --scale= " , data [ i ] . scale ) ;
2021-01-21 10:15:03 +13:00
arg_int ( cmd , " --scmvv= " , data [ i ] . scmvv ) ;
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " --secure= " , data [ i ] . secure ) ;
arg_int ( cmd , " --separator= " , data [ i ] . separator ) ;
arg_int ( cmd , " --vers= " , data [ i ] . vers ) ;
2021-05-26 07:42:26 +12:00
arg_int ( cmd , " --vwhitesp= " , data [ i ] . vwhitesp ) ;
2020-08-05 09:44:20 +12:00
arg_int ( cmd , " -w " , data [ i ] . w ) ;
strcat ( cmd , " 2>&1 " ) ;
2020-08-05 09:22:26 +12:00
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
2020-08-11 06:40:10 +12:00
if ( strncmp ( data [ i ] . expected , " Warning " , 7 ) = = 0 ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( outfilename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , outfilename , errno , strerror ( errno ) ) ;
2020-08-11 06:40:10 +12:00
}
2020-08-05 09:22:26 +12:00
}
testFinish ( ) ;
2020-12-18 15:36:48 +13:00
}
2020-08-05 09:22:26 +12:00
2022-09-13 06:26:04 +12:00
static void test_barcode_symbology ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2021-01-21 10:15:03 +13:00
struct item {
const char * bname ;
const char * data ;
const char * primary ;
int fail ;
const char * expected ;
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2021-01-21 10:15:03 +13:00
static const struct item data [ ] = {
/* 0*/ { " _ " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type '_' " } ,
/* 1*/ { " a " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'a' " } ,
2022-09-29 09:58:57 +13:00
/* 2*/ { " code128 " , " 1 " , NULL , 0 , " BARCODE_CODE128 (20), " } ,
2021-01-21 10:15:03 +13:00
/* 3*/ { " code218 " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'code218' " } ,
/* 4*/ { " code12 " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'code12' " } ,
2022-09-29 09:58:57 +13:00
/* 5*/ { " BARCODE_CODE11 " , " 1 " , NULL , 0 , " BARCODE_CODE11 (1), " } ,
/* 6*/ { " C25 Standard " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } ,
/* 7*/ { " c25matrix " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Legacy now supported */
/* 8*/ { " 2 of 5 Standard " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Synonym */
/* 9*/ { " 2 of 5 Matrix " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Synonym */
/* 10*/ { " Code 2 of 5 Standard " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Synonym */
/* 11*/ { " Code 2 of 5 Matrix " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Synonym */
/* 12*/ { " Standard Code 2 of 5 " , " 1 " , NULL , 0 , " BARCODE_C25STANDARD (2), " } , /* Synonym */
/* 13*/ { " C25INTER " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } ,
/* 14*/ { " c25 interleaved " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 15*/ { " code 2 of 5 inter " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 16*/ { " code 2 of 5 interleaved " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 17*/ { " 2 of 5 inter " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 18*/ { " 2 of 5 interleaved " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 19*/ { " interleaved 2 of 5 " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 20*/ { " interleaved code 2 of 5 " , " 1 " , NULL , 0 , " BARCODE_C25INTER (3), " } , /* Synonym */
/* 21*/ { " c25IATA " , " 1 " , NULL , 0 , " BARCODE_C25IATA (4), " } ,
/* 22*/ { " 2of5IATA " , " 1 " , NULL , 0 , " BARCODE_C25IATA (4), " } , /* Synonym */
/* 23*/ { " code2of5IATA " , " 1 " , NULL , 0 , " BARCODE_C25IATA (4), " } , /* Synonym */
/* 24*/ { " IATA2of5 " , " 1 " , NULL , 0 , " BARCODE_C25IATA (4), " } , /* Synonym */
/* 25*/ { " IATAcode2of5 " , " 1 " , NULL , 0 , " BARCODE_C25IATA (4), " } , /* Synonym */
/* 26*/ { " c25 Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } ,
/* 27*/ { " c25 Data Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } , /* Synonym */
/* 28*/ { " Code 2 of 5 Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } , /* Synonym */
/* 29*/ { " Code 2 of 5 Data Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } , /* Synonym */
/* 30*/ { " 2 of 5 Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } , /* Synonym */
/* 31*/ { " 2 of 5 Data Logic " , " 1 " , NULL , 0 , " BARCODE_C25LOGIC (6), " } , /* Synonym */
/* 32*/ { " c25 Ind " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } ,
/* 33*/ { " c25 Industrial " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 34*/ { " code 2 of 5 Ind " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 35*/ { " code 2 of 5 Industrial " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 36*/ { " 2 of 5 Ind " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 37*/ { " 2 of 5 Industrial " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 38*/ { " Industrial 2 of 5 " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 39*/ { " Industrial code 2 of 5 " , " 1 " , NULL , 0 , " BARCODE_C25IND (7), " } , /* Synonym */
/* 40*/ { " code39 " , " 1 " , NULL , 0 , " BARCODE_CODE39 (8), " } ,
/* 41*/ { " excode 39 " , " 1 " , NULL , 0 , " BARCODE_EXCODE39 (9), " } ,
/* 42*/ { " Extended Code 39 " , " 1 " , NULL , 0 , " BARCODE_EXCODE39 (9), " } ,
/* 43*/ { " eanx " , " 1 " , NULL , 0 , " BARCODE_EANX (13), " } ,
/* 44*/ { " ean " , " 1 " , NULL , 0 , " BARCODE_EANX (13), " } ,
/* 45*/ { " eanx chk " , " 1 " , NULL , 0 , " BARCODE_EANX_CHK (14), " } ,
/* 46*/ { " eanxchk " , " 1 " , NULL , 0 , " BARCODE_EANX_CHK (14), " } ,
/* 47*/ { " eanchk " , " 1 " , NULL , 0 , " BARCODE_EANX_CHK (14), " } ,
/* 48*/ { " GS1128 " , " [01]12345678901231 " , NULL , 0 , " BARCODE_GS1_128 (16), " } ,
/* 49*/ { " ean 128 " , " [01]12345678901231 " , NULL , 0 , " BARCODE_GS1_128 (16), " } ,
/* 50*/ { " coda bar " , " A1B " , NULL , 0 , " BARCODE_CODABAR (18), " } ,
/* 51*/ { " DPLEIT " , " 1 " , NULL , 0 , " BARCODE_DPLEIT (21), " } ,
/* 52*/ { " DPIDENT " , " 1 " , NULL , 0 , " BARCODE_DPIDENT (22), " } ,
/* 53*/ { " code16k " , " 1 " , NULL , 0 , " BARCODE_CODE16K (23), " } ,
/* 54*/ { " CODE49 " , " 1 " , NULL , 0 , " BARCODE_CODE49 (24), " } ,
/* 55*/ { " CODE93 " , " 1 " , NULL , 0 , " BARCODE_CODE93 (25), " } ,
/* 56*/ { " flat " , " 1 " , NULL , 0 , " BARCODE_FLAT (28), " } ,
/* 57*/ { " dbar omn " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMN (29), " } ,
2023-06-12 12:25:55 +12:00
/* 58*/ { " dbar omni " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMN (29), " } ,
/* 59*/ { " rss14 " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMN (29), " } ,
/* 60*/ { " databar omn " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMN (29), " } ,
/* 61*/ { " databar omni " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMN (29), " } ,
/* 62*/ { " dbar ltd " , " 1 " , NULL , 0 , " BARCODE_DBAR_LTD (30), " } ,
/* 63*/ { " dbar limited " , " 1 " , NULL , 0 , " BARCODE_DBAR_LTD (30), " } ,
/* 64*/ { " rss ltd " , " 1 " , NULL , 0 , " BARCODE_DBAR_LTD (30), " } ,
/* 65*/ { " databar ltd " , " 1 " , NULL , 0 , " BARCODE_DBAR_LTD (30), " } ,
/* 66*/ { " databar limited " , " 1 " , NULL , 0 , " BARCODE_DBAR_LTD (30), " } ,
/* 67*/ { " dbarexp " , " [10]12 " , NULL , 0 , " BARCODE_DBAR_EXP (31), " } ,
/* 68*/ { " dbarexpanded " , " [10]12 " , NULL , 0 , " BARCODE_DBAR_EXP (31), " } ,
/* 69*/ { " rss exp " , " [10]12 " , NULL , 0 , " BARCODE_DBAR_EXP (31), " } ,
/* 70*/ { " databarexp " , " [10]12 " , NULL , 0 , " BARCODE_DBAR_EXP (31), " } ,
/* 71*/ { " databarexpanded " , " [10]12 " , NULL , 0 , " BARCODE_DBAR_EXP (31), " } ,
/* 72*/ { " telepen " , " 1 " , NULL , 0 , " BARCODE_TELEPEN (32), " } ,
/* 73*/ { " upc " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'upc' " } ,
/* 74*/ { " upca " , " 1 " , NULL , 0 , " BARCODE_UPCA (34), " } ,
/* 75*/ { " upca_chk " , " 123456789012 " , NULL , 0 , " BARCODE_UPCA_CHK (35), " } ,
/* 76*/ { " upce " , " 1 " , NULL , 0 , " BARCODE_UPCE (37), " } ,
/* 77*/ { " upce chk " , " 12345670 " , NULL , 0 , " BARCODE_UPCE_CHK (38), " } ,
/* 78*/ { " POSTNET " , " 12345678901 " , NULL , 0 , " BARCODE_POSTNET (40), " } ,
/* 79*/ { " msi " , " 1 " , NULL , 0 , " BARCODE_MSI_PLESSEY (47), " } ,
/* 80*/ { " MSI Plessey " , " 1 " , NULL , 0 , " BARCODE_MSI_PLESSEY (47), " } ,
/* 81*/ { " fim " , " A " , NULL , 0 , " BARCODE_FIM (49), " } ,
/* 82*/ { " LOGMARS " , " 123456 " , NULL , 0 , " BARCODE_LOGMARS (50), " } ,
/* 83*/ { " pharma " , " 123456 " , NULL , 0 , " BARCODE_PHARMA (51), " } ,
/* 84*/ { " pzn " , " 1 " , NULL , 0 , " BARCODE_PZN (52), " } ,
/* 85*/ { " pharma two " , " 4 " , NULL , 0 , " BARCODE_PHARMA_TWO (53), " } ,
/* 86*/ { " cepnet " , " 12345678 " , NULL , 0 , " BARCODE_CEPNET (54), " } ,
/* 87*/ { " BARCODE_PDF417 " , " 1 " , NULL , 0 , " BARCODE_PDF417 (55), " } ,
/* 88*/ { " pdf " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'pdf' " } ,
/* 89*/ { " barcodepdf417comp " , " 1 " , NULL , 0 , " BARCODE_PDF417COMP (56), " } ,
/* 90*/ { " pdf417trunc " , " 1 " , NULL , 0 , " BARCODE_PDF417COMP (56), " } ,
/* 91*/ { " MaxiCode " , " 1 " , NULL , 0 , " BARCODE_MAXICODE (57), " } ,
/* 92*/ { " QR CODE " , " 1 " , NULL , 0 , " BARCODE_QRCODE (58), " } ,
/* 93*/ { " qr " , " 1 " , NULL , 0 , " BARCODE_QRCODE (58), " } , /* Synonym */
/* 94*/ { " Code 128 B " , " 1 " , NULL , 0 , " BARCODE_CODE128AB (60), " } ,
/* 95*/ { " Code 128 aB " , " 1 " , NULL , 0 , " BARCODE_CODE128AB (60), " } ,
/* 96*/ { " AUS POST " , " 12345678901234567890123 " , NULL , 0 , " BARCODE_AUSPOST (63), " } ,
/* 97*/ { " AusReply " , " 12345678 " , NULL , 0 , " BARCODE_AUSREPLY (66), " } ,
/* 98*/ { " AUSROUTE " , " 12345678 " , NULL , 0 , " BARCODE_AUSROUTE (67), " } ,
/* 99*/ { " AUS REDIRECT " , " 12345678 " , NULL , 0 , " BARCODE_AUSREDIRECT (68), " } ,
/*100*/ { " isbnx " , " 123456789 " , NULL , 0 , " BARCODE_ISBNX (69), " } ,
/*101*/ { " rm4scc " , " 1 " , NULL , 0 , " BARCODE_RM4SCC (70), " } ,
/*102*/ { " DataMatrix " , " 1 " , NULL , 0 , " BARCODE_DATAMATRIX (71), " } ,
/*103*/ { " EAN14 " , " 1 " , NULL , 0 , " BARCODE_EAN14 (72), " } ,
/*104*/ { " vin " , " 12345678701234567 " , NULL , 0 , " BARCODE_VIN (73) " } ,
/*105*/ { " CodaBlock-F " , " 1 " , NULL , 0 , " BARCODE_CODABLOCKF (74), " } ,
/*106*/ { " NVE18 " , " 1 " , NULL , 0 , " BARCODE_NVE18 (75), " } ,
/*107*/ { " Japan Post " , " 1 " , NULL , 0 , " BARCODE_JAPANPOST (76), " } ,
/*108*/ { " Korea Post " , " 1 " , NULL , 0 , " BARCODE_KOREAPOST (77), " } ,
/*109*/ { " DBar Stk " , " 1 " , NULL , 0 , " BARCODE_DBAR_STK (79), " } ,
/*110*/ { " DBar Stacked " , " 1 " , NULL , 0 , " BARCODE_DBAR_STK (79), " } ,
/*111*/ { " rss14stack " , " 1 " , NULL , 0 , " BARCODE_DBAR_STK (79), " } ,
/*112*/ { " DataBar Stk " , " 1 " , NULL , 0 , " BARCODE_DBAR_STK (79), " } ,
/*113*/ { " DataBar Stacked " , " 1 " , NULL , 0 , " BARCODE_DBAR_STK (79), " } ,
/*114*/ { " DBar Omn Stk " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*115*/ { " DBar Stacked Omni " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*116*/ { " RSS14STACK OMNI " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*117*/ { " DataBar Omn Stk " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*118*/ { " DataBar Stacked Omn " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*119*/ { " DataBar Stacked Omni " , " 1 " , NULL , 0 , " BARCODE_DBAR_OMNSTK (80), " } ,
/*120*/ { " DBar Exp Stk " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*121*/ { " DBar Expanded Stacked " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*122*/ { " rss_expstack " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*123*/ { " DataBar Exp Stk " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*124*/ { " DataBar Expanded Stk " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*125*/ { " DataBar Expanded Stacked " , " [20]01 " , NULL , 0 , " BARCODE_DBAR_EXPSTK (81), " } ,
/*126*/ { " planet " , " 12345678901 " , NULL , 0 , " BARCODE_PLANET (82), " } ,
/*127*/ { " MicroPDF417 " , " 1 " , NULL , 0 , " BARCODE_MICROPDF417 (84), " } ,
/*128*/ { " USPS IMail " , " 12345678901234567890 " , NULL , 0 , " BARCODE_USPS_IMAIL (85), " } ,
/*129*/ { " OneCode " , " 12345678901234567890 " , NULL , 0 , " BARCODE_USPS_IMAIL (85), " } ,
/*130*/ { " plessey " , " 1 " , NULL , 0 , " BARCODE_PLESSEY (86), " } ,
/*131*/ { " telepen num " , " 1 " , NULL , 0 , " BARCODE_TELEPEN_NUM (87), " } ,
/*132*/ { " ITF14 " , " 1 " , NULL , 0 , " BARCODE_ITF14 (89), " } ,
/*133*/ { " KIX " , " 1 " , NULL , 0 , " BARCODE_KIX (90), " } ,
/*134*/ { " Aztec " , " 1 " , NULL , 0 , " BARCODE_AZTEC (92), " } ,
/*135*/ { " Aztec Code " , " 1 " , NULL , 0 , " BARCODE_AZTEC (92), " } , /* Synonym */
/*136*/ { " daft " , " D " , NULL , 0 , " BARCODE_DAFT (93), " } ,
/*137*/ { " DPD " , " 0123456789012345678901234567 " , NULL , 0 , " BARCODE_DPD (96), " } ,
/*138*/ { " Micro QR " , " 1 " , NULL , 0 , " BARCODE_MICROQR (97), " } ,
/*139*/ { " Micro QR Code " , " 1 " , NULL , 0 , " BARCODE_MICROQR (97), " } ,
/*140*/ { " hibc128 " , " 1 " , NULL , 0 , " BARCODE_HIBC_128 (98), " } ,
/*141*/ { " hibccode128 " , " 1 " , NULL , 0 , " BARCODE_HIBC_128 (98), " } , /* Synonym */
/*142*/ { " hibc39 " , " 1 " , NULL , 0 , " BARCODE_HIBC_39 (99), " } ,
/*143*/ { " hibccode39 " , " 1 " , NULL , 0 , " BARCODE_HIBC_39 (99), " } , /* Synonym */
/*144*/ { " hibcdatamatrix " , " 1 " , NULL , 0 , " BARCODE_HIBC_DM (102), " } , /* Synonym */
/*145*/ { " hibcdm " , " 1 " , NULL , 0 , " BARCODE_HIBC_DM (102), " } ,
/*146*/ { " HIBC qr " , " 1 " , NULL , 0 , " BARCODE_HIBC_QR (104), " } ,
/*147*/ { " HIBC QR Code " , " 1 " , NULL , 0 , " BARCODE_HIBC_QR (104), " } , /* Synonym */
/*148*/ { " HIBCPDF " , " 1 " , NULL , 0 , " BARCODE_HIBC_PDF (106), " } ,
/*149*/ { " HIBCPDF417 " , " 1 " , NULL , 0 , " BARCODE_HIBC_PDF (106), " } , /* Synonym */
/*150*/ { " HIBCMICPDF " , " 1 " , NULL , 0 , " BARCODE_HIBC_MICPDF (108), " } ,
/*151*/ { " HIBC Micro PDF " , " 1 " , NULL , 0 , " BARCODE_HIBC_MICPDF (108), " } , /* Synonym */
/*152*/ { " HIBC Micro PDF417 " , " 1 " , NULL , 0 , " BARCODE_HIBC_MICPDF (108), " } , /* Synonym */
/*153*/ { " HIBC BlockF " , " 1 " , NULL , 0 , " BARCODE_HIBC_BLOCKF (110), " } ,
/*154*/ { " HIBC CodaBlock-F " , " 1 " , NULL , 0 , " BARCODE_HIBC_BLOCKF (110), " } , /* Synonym */
/*155*/ { " HIBC Aztec " , " 1 " , NULL , 0 , " BARCODE_HIBC_AZTEC (112), " } ,
/*156*/ { " DotCode " , " 1 " , NULL , 0 , " BARCODE_DOTCODE (115), " } ,
/*157*/ { " Han Xin " , " 1 " , NULL , 0 , " BARCODE_HANXIN (116), " } ,
/*158*/ { " Mailmark " , " 01000000000000000AA00AA0A " , NULL , 0 , " BARCODE_MAILMARK_4S (121), " } ,
/*159*/ { " Mailmark 4-state " , " 01000000000000000AA00AA0A " , NULL , 0 , " BARCODE_MAILMARK_4S (121), " } ,
/*160*/ { " Mailmark 2D " , " 012100123412345678AB19XY1A 0 " , NULL , 0 , " BARCODE_MAILMARK_2D (119), " } ,
/*161*/ { " azrune " , " 1 " , NULL , 0 , " BARCODE_AZRUNE (128), " } ,
/*162*/ { " aztecrune " , " 1 " , NULL , 0 , " BARCODE_AZRUNE (128), " } , /* Synonym */
/*163*/ { " aztecrunes " , " 1 " , NULL , 0 , " BARCODE_AZRUNE (128), " } , /* Synonym */
/*164*/ { " code32 " , " 1 " , NULL , 0 , " BARCODE_CODE32 (129), " } ,
/*165*/ { " eanx cc " , " [20]01 " , " 1234567890128 " , 0 , " BARCODE_EANX_CC (130), " } ,
/*166*/ { " eancc " , " [20]01 " , " 1234567890128 " , 0 , " BARCODE_EANX_CC (130), " } ,
/*167*/ { " GS1 128 CC " , " [01]12345678901231 " , " [20]01 " , 0 , " BARCODE_GS1_128_CC (131), " } ,
/*168*/ { " EAN128 CC " , " [01]12345678901231 " , " [20]01 " , 0 , " BARCODE_GS1_128_CC (131), " } ,
/*169*/ { " dbaromncc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMN_CC (132), " } ,
/*170*/ { " dbaromnicc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMN_CC (132), " } ,
/*171*/ { " rss14 cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMN_CC (132), " } ,
/*172*/ { " databaromncc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMN_CC (132), " } ,
/*173*/ { " databaromnicc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMN_CC (132), " } ,
/*174*/ { " dbarltdcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_LTD_CC (133), " } ,
/*175*/ { " dbarlimitedcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_LTD_CC (133), " } ,
/*176*/ { " rss ltd cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_LTD_CC (133), " } ,
/*177*/ { " databarltdcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_LTD_CC (133), " } ,
/*178*/ { " databarlimitedcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_LTD_CC (133), " } ,
/*179*/ { " dbarexpcc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXP_CC (134), " } ,
/*180*/ { " rss exp cc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXP_CC (134), " } ,
/*181*/ { " databarexpcc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXP_CC (134), " } ,
/*182*/ { " databar expanded cc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXP_CC (134), " } ,
/*183*/ { " upcacc " , " [20]01 " , " 12345678901 " , 0 , " BARCODE_UPCA_CC (135), " } ,
/*184*/ { " upcecc " , " [20]01 " , " 1234567 " , 0 , " BARCODE_UPCE_CC (136), " } ,
/*185*/ { " dbar stk cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_STK_CC (137), " } ,
/*186*/ { " rss14stackcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_STK_CC (137), " } ,
/*187*/ { " databar stk cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_STK_CC (137), " } ,
/*188*/ { " databar stacked cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_STK_CC (137), " } ,
/*189*/ { " dbaromnstkcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMNSTK_CC (138), " } ,
/*190*/ { " BARCODE_RSS14_OMNI_CC " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMNSTK_CC (138), " } ,
/*191*/ { " databaromnstkcc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMNSTK_CC (138), " } ,
/*192*/ { " databar stacked omncc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMNSTK_CC (138), " } ,
/*193*/ { " databar stacked omni cc " , " [20]01 " , " 1234567890123 " , 0 , " BARCODE_DBAR_OMNSTK_CC (138), " } ,
/*194*/ { " dbarexpstkcc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXPSTK_CC (139), " } ,
/*195*/ { " RSS EXPSTACK CC " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXPSTK_CC (139), " } ,
/*196*/ { " databarexpstkcc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXPSTK_CC (139), " } ,
/*197*/ { " databar expanded stkcc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXPSTK_CC (139), " } ,
/*198*/ { " databar expanded stacked cc " , " [20]01 " , " [01]12345678901231 " , 0 , " BARCODE_DBAR_EXPSTK_CC (139), " } ,
/*199*/ { " Channel " , " 1 " , NULL , 0 , " BARCODE_CHANNEL (140), " } ,
/*200*/ { " Channel Code " , " 1 " , NULL , 0 , " BARCODE_CHANNEL (140), " } ,
/*201*/ { " CodeOne " , " 1 " , NULL , 0 , " BARCODE_CODEONE (141), " } ,
/*202*/ { " Grid Matrix " , " 1 " , NULL , 0 , " BARCODE_GRIDMATRIX (142), " } ,
/*203*/ { " UPN QR " , " 1 " , NULL , 0 , " BARCODE_UPNQR (143), " } ,
/*204*/ { " UPN QR Code " , " 1 " , NULL , 0 , " BARCODE_UPNQR (143), " } , /* Synonym */
/*205*/ { " ultra " , " 1 " , NULL , 0 , " BARCODE_ULTRA (144), " } ,
/*206*/ { " ultracode " , " 1 " , NULL , 0 , " BARCODE_ULTRA (144), " } , /* Synonym */
/*207*/ { " rMQR " , " 1 " , NULL , 0 , " BARCODE_RMQR (145), " } ,
/*208*/ { " bc412 " , " 1234567 " , NULL , 0 , " BARCODE_BC412 (146), " } ,
/*209*/ { " x " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type 'x' " } ,
/*210*/ { " \177 " , " 1 " , NULL , 1 , " Error 119: Invalid barcode type ' \177 ' " } ,
2021-01-21 10:15:03 +13:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2021-01-21 10:15:03 +13:00
char cmd [ 4096 ] ;
char buf [ 8192 ] ;
2022-09-06 02:11:46 +12:00
const char * outfilename = " out.gif " ;
2021-01-21 10:15:03 +13:00
2021-06-24 02:00:49 +12:00
testStart ( " test_barcode_symbology " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2021-01-21 10:15:03 +13:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2021-01-21 10:15:03 +13:00
2021-06-10 22:15:39 +12:00
strcpy ( cmd , " zint --filetype=gif " ) ;
2021-01-21 10:15:03 +13:00
strcat ( cmd , " --verbose " ) ;
arg_data ( cmd , " -b " , data [ i ] . bname ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
arg_data ( cmd , " --primary= " , data [ i ] . primary ) ;
strcat ( cmd , " 2>&1 " ) ;
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2021-01-21 10:15:03 +13:00
if ( ! data [ i ] . fail ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( outfilename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) (%s) \n " , i , outfilename , errno , strerror ( errno ) , cmd ) ;
2021-01-21 10:15:03 +13:00
}
2022-09-29 09:58:57 +13:00
assert_nonnull ( strstr ( buf , data [ i ] . expected ) , " i:%d strstr(%s, %s) == NULL (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
2021-01-21 10:15:03 +13:00
}
testFinish ( ) ;
}
2022-09-13 06:26:04 +12:00
static void test_other_opts ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2021-01-21 10:15:03 +13:00
struct item {
int b ;
char * data ;
int input_mode ;
char * opt ;
char * opt_data ;
char * expected ;
2022-05-19 21:17:51 +12:00
int strstr_cmp ;
2021-01-21 10:15:03 +13:00
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2021-01-21 10:15:03 +13:00
struct item data [ ] = {
2022-05-19 21:17:51 +12:00
/* 0*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bg= " , " EF9900 " , " " , 0 } ,
/* 1*/ { BARCODE_CODE128 , " 1 " , - 1 , " -bg= " , " EF9900 " , " " , 0 } ,
/* 2*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bg= " , " EF9900AA " , " " , 0 } ,
2023-02-11 03:44:10 +13:00
/* 3*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bg= " , " GF9900 " , " Error 881: Malformed background RGB colour 'GF9900' (hexadecimal only) " , 0 } ,
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
/* 4*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bgcolor= " , " EF9900 " , " " , 0 } ,
/* 5*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bgcolour= " , " EF9900 " , " " , 0 } ,
/* 6*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fg= " , " 000000 " , " " , 0 } ,
/* 7*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fg= " , " 00000000 " , " " , 0 } ,
2023-02-11 03:44:10 +13:00
/* 8*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fg= " , " 000000F " , " Error 880: Malformed foreground RGB colour (6 or 8 characters only) " , 0 } ,
/* 9*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fg= " , " 000000FG " , " Error 881: Malformed foreground RGB colour '000000FG' (hexadecimal only) " , 0 } ,
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
/* 10*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fg= " , " 0,0,0,100 " , " " , 0 } ,
/* 11*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fgcolor= " , " 111111 " , " " , 0 } ,
/* 12*/ { BARCODE_CODE128 , " 1 " , - 1 , " --fgcolour= " , " 111111 " , " " , 0 } ,
/* 13*/ { BARCODE_CODE128 , " 1 " , - 1 , " --compliantheight " , " " , " " , 0 } ,
2023-06-12 12:25:55 +12:00
/* 14*/ { BARCODE_EANX , " 123456 " , - 1 , " --guardwhitespace " , " " , " " , 0 } ,
/* 15*/ { BARCODE_EANX , " 123456 " , - 1 , " --embedfont " , " " , " " , 0 } ,
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
/* 16*/ { BARCODE_CODE128 , " 1 " , - 1 , " --nobackground " , " " , " " , 0 } ,
/* 17*/ { BARCODE_CODE128 , " 1 " , - 1 , " --noquietzones " , " " , " " , 0 } ,
/* 18*/ { BARCODE_CODE128 , " 1 " , - 1 , " --notext " , " " , " " , 0 } ,
/* 19*/ { BARCODE_CODE128 , " 1 " , - 1 , " --quietzones " , " " , " " , 0 } ,
/* 20*/ { BARCODE_CODE128 , " 1 " , - 1 , " --reverse " , " " , " " , 0 } ,
/* 21*/ { BARCODE_CODE128 , " 1 " , - 1 , " --werror " , NULL , " " , 0 } ,
/* 22*/ { 19 , " 1 " , - 1 , " --werror " , NULL , " Error 207: Codabar 18 not supported " , 0 } ,
/* 23*/ { BARCODE_GS1_128 , " [01]12345678901231 " , - 1 , " " , NULL , " " , 0 } ,
/* 24*/ { BARCODE_GS1_128 , " 0112345678901231 " , - 1 , " " , NULL , " Error 252: Data does not start with an AI " , 0 } ,
/* 25*/ { BARCODE_GS1_128 , " 0112345678901231 " , - 1 , " --gs1nocheck " , NULL , " Error 252: Data does not start with an AI " , 0 } ,
/* 26*/ { BARCODE_GS1_128 , " [00]376104250021234569 " , - 1 , " " , NULL , " " , 0 } ,
/* 27*/ { BARCODE_GS1_128 , " [00]376104250021234568 " , - 1 , " " , NULL , " Warning 261: AI (00) position 18: Bad checksum '8', expected '9' " , 0 } ,
/* 28*/ { BARCODE_GS1_128 , " [00]376104250021234568 " , - 1 , " --gs1nocheck " , NULL , " " , 0 } ,
/* 29*/ { BARCODE_GS1_128 , " [00]376104250021234568 " , - 1 , " --werror " , NULL , " Error 261: AI (00) position 18: Bad checksum '8', expected '9' " , 0 } ,
/* 30*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 1 " , " Error 155: Invalid Structured Append argument, expect \" index,count[,ID] \" " , 0 } ,
/* 31*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " , " , " Error 156: Structured Append index too short " , 0 } ,
/* 32*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 1234567890, " , " Error 156: Structured Append index too long " , 0 } ,
/* 33*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789, " , " Error 159: Structured Append count too short " , 0 } ,
/* 34*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789,1234567890 " , " Error 159: Structured Append count too long " , 0 } ,
/* 35*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789,123456789, " , " Error 158: Structured Append ID too short " , 0 } ,
/* 36*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789,1234567890, " , " Error 157: Structured Append count too long " , 0 } ,
/* 37*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789,123456789,123456789012345678901234567890123 " , " Error 158: Structured Append ID too long " , 0 } ,
/* 38*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 123456789,123456789,12345678901234567890123456789012 " , " Error 701: Structured Append count out of range (2-26) " , 0 } ,
/* 39*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 26,26,12345678901234567890123456789012 " , " " , 0 } ,
/* 40*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " A,26,12345678901234567890123456789012 " , " Error 160: Invalid Structured Append index (digits only) " , 0 } ,
/* 41*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 26,A,12345678901234567890123456789012 " , " Error 161: Invalid Structured Append count (digits only) " , 0 } ,
/* 42*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 26,1,12345678901234567890123456789012 " , " Error 162: Invalid Structured Append count, must be >= 2 " , 0 } ,
/* 43*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 0,2,12345678901234567890123456789012 " , " Error 163: Structured Append index out of range (1-2) " , 0 } ,
/* 44*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 3,2,12345678901234567890123456789012 " , " Error 163: Structured Append index out of range (1-2) " , 0 } ,
/* 45*/ { BARCODE_AZTEC , " 1 " , - 1 , " --structapp= " , " 2,3,12345678901234567890123456789012 " , " " , 0 } ,
/* 46*/ { BARCODE_PDF417 , " 1 " , - 1 , " --heightperrow " , " " , " " , 0 } ,
/* 47*/ { - 1 , NULL , - 1 , " -v " , NULL , " Zint version " , 1 } ,
/* 48*/ { - 1 , NULL , - 1 , " --version " , NULL , " Zint version " , 1 } ,
/* 49*/ { - 1 , NULL , - 1 , " -h " , NULL , " Encode input data in a barcode " , 1 } ,
/* 50*/ { - 1 , NULL , - 1 , " -e " , NULL , " 3: ISO/IEC 8859-1 " , 1 } ,
/* 51*/ { - 1 , NULL , - 1 , " -t " , NULL , " 1 CODE11 " , 1 } ,
/* 52*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 12345678 " , " Error 178: scalexdimdp X-dim invalid floating point (integer part must be 7 digits maximum) " , 0 } ,
/* 53*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 1234567890123 " , " Error 176: scalexdimdp X-dim too long " , 0 } ,
/* 54*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 123456.12 " , " Error 178: scalexdimdp X-dim invalid floating point (7 significant digits maximum) " , 0 } ,
/* 55*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " ,12.34 " , " Error 174: scalexdimdp X-dim too short " , 0 } ,
/* 56*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 12.34, " , " Error 175: scalexdimdp resolution too short " , 0 } ,
/* 57*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 12mm1 " , " Error 177: scalexdimdp X-dim units must occur at end " , 0 } ,
/* 58*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 1inc " , " Error 177: scalexdimdp X-dim units must occur at end " , 0 } ,
/* 59*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 1234x " , " Error 178: scalexdimdp X-dim invalid floating point (integer part must be digits only) " , 0 } ,
/* 60*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 12.34in,123x " , " Error 180: scalexdimdp resolution invalid floating point (integer part must be digits only) " , 0 } ,
/* 61*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 12,123.45678 " , " Error 180: scalexdimdp resolution invalid floating point (7 significant digits maximum) " , 0 } ,
/* 62*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 10.1,1000 " , " Warning 185: scalexdimdp X-dim (10.1) out of range (> 10), ignoring " , 0 } ,
/* 63*/ { BARCODE_EANX , " 501234567890 " , - 1 , " --scalexdimdp= " , " 10,1000.1 " , " Warning 186: scalexdimdp resolution (1000.1) out of range (> 1000), ignoring " , 0 } ,
2021-01-21 10:15:03 +13:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
2021-06-24 02:00:49 +12:00
int i ;
2021-01-21 10:15:03 +13:00
char cmd [ 4096 ] ;
char buf [ 8192 ] ;
2022-11-25 03:18:31 +13:00
const char * outfilename = ZBarcode_NoPng ( ) ? " out.gif " : " out.png " ;
2021-01-21 10:15:03 +13:00
2021-06-24 02:00:49 +12:00
testStart ( " test_other_opts " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2021-01-21 10:15:03 +13:00
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2021-01-21 10:15:03 +13:00
strcpy ( cmd , " zint " ) ;
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_input_mode ( cmd , data [ i ] . input_mode ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
if ( data [ i ] . opt_data ! = NULL ) {
arg_data ( cmd , data [ i ] . opt , data [ i ] . opt_data ) ;
} else {
strcat ( cmd , data [ i ] . opt ) ;
}
strcat ( cmd , " 2>&1 " ) ;
2022-05-23 08:33:45 +12:00
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
2022-05-19 21:17:51 +12:00
if ( data [ i ] . strstr_cmp ) {
assert_nonnull ( strstr ( buf , data [ i ] . expected ) , " i:%d strstr buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
} else {
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d strcmp buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
2022-09-06 02:11:46 +12:00
if ( strstr ( data [ i ] . expected , " Error " ) = = NULL ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( outfilename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , outfilename , errno , strerror ( errno ) ) ;
2022-09-06 02:11:46 +12:00
}
2022-05-19 21:17:51 +12:00
}
2021-01-21 10:15:03 +13:00
}
testFinish ( ) ;
}
2023-06-12 12:25:55 +12:00
static void test_combos ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
struct item {
int b ;
char * data ;
char * opts ;
char * expected ;
char * outfilename ;
int strstr_cmp ;
} ;
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data [ ] = {
/* 0*/ { - 1 , " 1 " , " --direct -o direct.gif " , " Warning 193: Output file given, ignoring '--direct' option " , " direct.gif " , 0 } ,
} ;
int data_size = ARRAY_SIZE ( data ) ;
int i ;
char cmd [ 4096 ] ;
char buf [ 8192 ] ;
testStart ( " test_combos " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
if ( testContinue ( p_ctx , i ) ) continue ;
strcpy ( cmd , " zint " ) ;
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
strcat ( cmd , data [ i ] . opts ) ;
strcat ( cmd , " 2>&1 " ) ;
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , NULL ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
if ( data [ i ] . strstr_cmp ) {
assert_nonnull ( strstr ( buf , data [ i ] . expected ) , " i:%d strstr buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
} else {
assert_zero ( strcmp ( buf , data [ i ] . expected ) , " i:%d strcmp buf (%s) != expected (%s) (%s) \n " , i , buf , data [ i ] . expected , cmd ) ;
}
if ( data [ i ] . outfilename ! = NULL ) {
assert_zero ( remove ( data [ i ] . outfilename ) , " i:%d remove(%s) != 0 (%d: %s) \n " , i , data [ i ] . outfilename , errno , strerror ( errno ) ) ;
}
}
testFinish ( ) ;
}
2022-09-13 06:26:04 +12:00
static void test_exit_status ( const testCtx * const p_ctx ) {
int debug = p_ctx - > debug ;
2022-05-23 08:33:45 +12:00
struct item {
int b ;
char * data ;
int input_mode ;
char * opt ;
char * opt_data ;
int expected ;
} ;
2022-09-15 07:23:47 +12:00
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
2022-05-23 08:33:45 +12:00
struct item data [ ] = {
/* 0*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bg= " , " EF9900 " , 0 } ,
2022-09-15 07:23:47 +12:00
/* 1*/ { BARCODE_CODE128 , " 1 " , - 1 , " --bg= " , " GF9900 " , ZINT_ERROR_INVALID_OPTION } , /* Caught by libzint */
/* 2*/ { BARCODE_CODE128 , " 1 " , - 1 , " --border= " , " 1001 " , ZINT_WARN_INVALID_OPTION } , /* Caught by CLI */
/* 3*/ { BARCODE_CODE128 , " 1 " , - 1 , " --data= " , " \200 " , ZINT_ERROR_INVALID_DATA } , /* Caught by libzint */
/* 4*/ { BARCODE_CODE128 , " 1 " , - 1 , " --separator= " , " -1 " , ZINT_ERROR_INVALID_OPTION } , /* Caught by CLI */
2022-09-29 09:58:57 +13:00
/* 5*/ { BARCODE_CODE128 , " 1 " , - 1 , " --separator " , NULL , ZINT_ERROR_INVALID_OPTION } ,
/* 6*/ { BARCODE_CODE128 , " 1 " , - 1 , " --separator= " , NULL , 0 } , /* Separator arg treated as 0 */
/* 7*/ { BARCODE_CODE128 , " 1 " , - 1 , " --unknown " , NULL , ZINT_ERROR_INVALID_OPTION } ,
2022-05-23 08:33:45 +12:00
} ;
int data_size = ARRAY_SIZE ( data ) ;
int i ;
int exit_status ;
char cmd [ 4096 ] ;
char buf [ 8192 ] ;
2022-11-25 03:18:31 +13:00
const char * outfilename = ZBarcode_NoPng ( ) ? " out.gif " : " out.png " ;
2022-05-23 08:33:45 +12:00
testStart ( " test_exit_status " ) ;
for ( i = 0 ; i < data_size ; i + + ) {
2022-09-13 06:26:04 +12:00
if ( testContinue ( p_ctx , i ) ) continue ;
2022-05-23 08:33:45 +12:00
strcpy ( cmd , " zint " ) ;
* buf = ' \0 ' ;
arg_int ( cmd , " -b " , data [ i ] . b ) ;
arg_input_mode ( cmd , data [ i ] . input_mode ) ;
arg_data ( cmd , " -d " , data [ i ] . data ) ;
if ( data [ i ] . opt_data ! = NULL ) {
arg_data ( cmd , data [ i ] . opt , data [ i ] . opt_data ) ;
} else {
strcat ( cmd , data [ i ] . opt ) ;
}
strcat ( cmd , " 2>&1 " ) ;
assert_nonnull ( exec ( cmd , buf , sizeof ( buf ) - 1 , debug , i , & exit_status ) , " i:%d exec(%s) NULL \n " , i , cmd ) ;
assert_equal ( exit_status , data [ i ] . expected , " i:%d exit_status %d != expected (%d) (%s), (cmd: %s) \n " , i , exit_status , data [ i ] . expected , buf , cmd ) ;
2022-09-06 02:11:46 +12:00
if ( data [ i ] . expected < ZINT_ERROR ) {
2023-05-11 08:29:09 +12:00
assert_zero ( testUtilRemove ( outfilename ) , " i:%d testUtilRemove(%s) != 0 (%d: %s) \n " , i , outfilename , errno , strerror ( errno ) ) ;
2022-09-06 02:11:46 +12:00
}
2022-05-23 08:33:45 +12:00
}
testFinish ( ) ;
}
2020-08-05 09:22:26 +12:00
int main ( int argc , char * argv [ ] ) {
2022-09-13 06:26:04 +12:00
testFunction funcs [ ] = { /* name, func */
{ " test_dump_args " , test_dump_args } ,
{ " test_dump_segs " , test_dump_segs } ,
{ " test_input " , test_input } ,
{ " test_stdin_input " , test_stdin_input } ,
{ " test_batch_input " , test_batch_input } ,
{ " test_batch_large " , test_batch_large } ,
{ " test_checks " , test_checks } ,
{ " test_barcode_symbology " , test_barcode_symbology } ,
{ " test_other_opts " , test_other_opts } ,
2023-06-12 12:25:55 +12:00
{ " test_combos " , test_combos } ,
2022-09-13 06:26:04 +12:00
{ " test_exit_status " , test_exit_status } ,
2020-08-05 09:22:26 +12:00
} ;
testRun ( argc , argv , funcs , ARRAY_SIZE ( funcs ) ) ;
testReport ( ) ;
return 0 ;
}
2022-04-10 22:12:18 +12:00
/* vim: set ts=4 sw=4 et : */