mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-27 21:44:13 -04:00
Test suite: add testRun allowing args; testSkip; haveIdentify/etc; general tidy-up
This commit is contained in:
parent
3fea67890b
commit
5eafa2e094
38 changed files with 2211 additions and 1518 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2020 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -34,8 +34,7 @@
|
|||
#include "../sjis.h"
|
||||
|
||||
// As control convert to Shift JIS using simple table generated from https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT plus simple processing
|
||||
static int sjis_wctomb_zint2(unsigned int* r, unsigned int wc)
|
||||
{
|
||||
static int sjis_wctomb_zint2(unsigned int *r, unsigned int wc) {
|
||||
if (wc < 0x20 || wc == 0x7F) {
|
||||
*r = wc;
|
||||
return 1;
|
||||
|
@ -78,8 +77,8 @@ static int sjis_wctomb_zint2(unsigned int* r, unsigned int wc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void test_sjis_wctomb_zint(void)
|
||||
{
|
||||
static void test_sjis_wctomb_zint(void) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret, ret2;
|
||||
|
@ -107,18 +106,18 @@ static void test_sjis_wctomb_zint(void)
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_sjis_utf8tomb(void)
|
||||
{
|
||||
static void test_sjis_utf8tomb(int index) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
unsigned char* data;
|
||||
unsigned char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char* comment;
|
||||
char *comment;
|
||||
};
|
||||
// é U+00E9 in ISO 8859-1 plus other ISO 8859 (but not in ISO 8859-7 or ISO 8859-11), Win 1250 plus other Win, not in Shift JIS, UTF-8 C3A9
|
||||
// β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page), in Shift JIS 0x83C0, UTF-8 CEB2
|
||||
|
@ -147,6 +146,8 @@ static void test_sjis_utf8tomb(void)
|
|||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
|
||||
|
@ -163,20 +164,20 @@ static void test_sjis_utf8tomb(void)
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_sjis_utf8tosb(void)
|
||||
{
|
||||
static void test_sjis_utf8tosb(int index) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int eci;
|
||||
int full_multibyte;
|
||||
unsigned char* data;
|
||||
unsigned char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char* comment;
|
||||
char *comment;
|
||||
};
|
||||
// é U+00E9 in ISO 8859-1 0xE9, Win 1250 plus other Win, in QR Kanji mode first byte range 0x81..9F, 0xE0..EB
|
||||
// β U+03B2 in ISO 8859-7 Greek 0xE2 (but not other ISO 8859 or Win page)
|
||||
|
@ -211,6 +212,8 @@ static void test_sjis_utf8tosb(void)
|
|||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
|
||||
|
@ -227,19 +230,19 @@ static void test_sjis_utf8tosb(void)
|
|||
testFinish();
|
||||
}
|
||||
|
||||
static void test_sjis_cpy(void)
|
||||
{
|
||||
static void test_sjis_cpy(int index) {
|
||||
|
||||
testStart("");
|
||||
|
||||
int ret;
|
||||
struct item {
|
||||
int full_multibyte;
|
||||
unsigned char* data;
|
||||
unsigned char *data;
|
||||
int length;
|
||||
int ret;
|
||||
size_t ret_length;
|
||||
unsigned int expected_jisdata[20];
|
||||
char* comment;
|
||||
char *comment;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
|
@ -260,6 +263,8 @@ static void test_sjis_cpy(void)
|
|||
|
||||
for (int i = 0; i < data_size; i++) {
|
||||
|
||||
if (index != -1 && i != index) continue;
|
||||
|
||||
int length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
size_t ret_length = length;
|
||||
|
||||
|
@ -273,12 +278,16 @@ static void test_sjis_cpy(void)
|
|||
testFinish();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_sjis_wctomb_zint();
|
||||
test_sjis_utf8tomb();
|
||||
test_sjis_utf8tosb();
|
||||
test_sjis_cpy();
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
{ "test_sjis_wctomb_zint", test_sjis_wctomb_zint, 0, 0, 0 },
|
||||
{ "test_sjis_utf8tomb", test_sjis_utf8tomb, 1, 0, 0 },
|
||||
{ "test_sjis_utf8tosb", test_sjis_utf8tosb, 1, 0, 0 },
|
||||
{ "test_sjis_cpy", test_sjis_cpy, 1, 0, 0 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
|
||||
testReport();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue