mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
CODABLOCKF inter-row bindings too short fix; -Wextra; tests
This commit is contained in:
parent
dc56c5ed0f
commit
2d0b966de6
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2016 Harald Oehlmann
|
Copyright (C) 2016 - 2020 Harald Oehlmann
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -34,7 +34,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
@ -116,7 +115,7 @@ static int GetPossibleCharacterSet(unsigned char C)
|
|||||||
* int CFollowing The number of characters encodable in CodeC if we
|
* int CFollowing The number of characters encodable in CodeC if we
|
||||||
* start here.
|
* start here.
|
||||||
*/
|
*/
|
||||||
static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data,const size_t dataLength)
|
static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength)
|
||||||
{
|
{
|
||||||
int charCur;
|
int charCur;
|
||||||
int runChar;
|
int runChar;
|
||||||
@ -147,7 +146,7 @@ static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data,c
|
|||||||
/* CodeC possible */
|
/* CodeC possible */
|
||||||
runChar=charCur;
|
runChar=charCur;
|
||||||
do{
|
do{
|
||||||
/* Wether this is FNC1 wether next is */
|
/* Whether this is FNC1, whether next is */
|
||||||
/* numeric */
|
/* numeric */
|
||||||
if (T[runChar].CharacterSet==ZTFNC1)
|
if (T[runChar].CharacterSet==ZTFNC1)
|
||||||
/* FNC1 */
|
/* FNC1 */
|
||||||
@ -194,19 +193,18 @@ static int RemainingDigits(CharacterSetTable *T, int charCur,int emptyColumns)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find the Character distribution at a given column count.
|
/* Find the Character distribution at a given column count.
|
||||||
* If to many rows (>44) are requested the columns is extended.
|
* If too many rows (>44) are requested the columns are extended.
|
||||||
* A oneLigner may be choosen if shorter.
|
* A one-liner may be choosen if shorter.
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* T Pointer on the Characters which fit in the row
|
* T Pointer on the Characters which fit in the row
|
||||||
* If a different count is calculated it is corrected
|
* If a different count is calculated it is corrected
|
||||||
* in the callers workspace.
|
* in the callers workspace.
|
||||||
* pFillings Output of filling characters
|
* pFillings Output of filling characters
|
||||||
* pSet Output of the character sets used, allocated by me.
|
* pSet Output of the character sets used, allocated by me.
|
||||||
* Data The Data string to encode, exceptionnally not an out
|
|
||||||
* Return value Resulting row count
|
* Return value Resulting row count
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, unsigned char *data, const size_t dataLength,
|
static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength,
|
||||||
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
||||||
{
|
{
|
||||||
int useColumns; /* Usable Characters per line */
|
int useColumns; /* Usable Characters per line */
|
||||||
@ -398,7 +396,7 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, unsign
|
|||||||
switch (emptyColumns) {
|
switch (emptyColumns) {
|
||||||
case 1:
|
case 1:
|
||||||
pSet[charCur-1]|=CFill;
|
pSet[charCur-1]|=CFill;
|
||||||
/* Glide in following block without break */
|
/* fall through */
|
||||||
case 0:
|
case 0:
|
||||||
++rowsCur;
|
++rowsCur;
|
||||||
fillings=useColumns-2+emptyColumns;
|
fillings=useColumns-2+emptyColumns;
|
||||||
@ -429,7 +427,7 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, unsign
|
|||||||
}
|
}
|
||||||
/* Find columns if row count is given.
|
/* Find columns if row count is given.
|
||||||
*/
|
*/
|
||||||
static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, unsigned char *data, const size_t dataLength,
|
static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength,
|
||||||
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
int * pRows, int * pUseColumns, int * pSet, int * pFillings)
|
||||||
{
|
{
|
||||||
int rowsCur;
|
int rowsCur;
|
||||||
@ -440,7 +438,7 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, unsign
|
|||||||
int useColumns;
|
int useColumns;
|
||||||
int testColumns; /* To enter into Width2Rows */
|
int testColumns; /* To enter into Width2Rows */
|
||||||
int backupColumns = 0;
|
int backupColumns = 0;
|
||||||
int fBackupOk = 0; /* The memorysed set is o.k. */
|
int fBackupOk = 0; /* The memorised set is o.k. */
|
||||||
int testListSize = 0;
|
int testListSize = 0;
|
||||||
int pTestList[62];
|
int pTestList[62];
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
@ -472,7 +470,7 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, unsign
|
|||||||
pTestList[testListSize] = testColumns;
|
pTestList[testListSize] = testColumns;
|
||||||
testListSize++;
|
testListSize++;
|
||||||
useColumns=testColumns; /* Make a copy because it may be modified */
|
useColumns=testColumns; /* Make a copy because it may be modified */
|
||||||
errorCur = Columns2Rows(symbol, T, data, dataLength, &rowsCur, &useColumns, pSet, &fillings);
|
errorCur = Columns2Rows(symbol, T, dataLength, &rowsCur, &useColumns, pSet, &fillings);
|
||||||
if (errorCur != 0)
|
if (errorCur != 0)
|
||||||
return errorCur;
|
return errorCur;
|
||||||
if (rowsCur<=rowsRequested) {
|
if (rowsCur<=rowsRequested) {
|
||||||
@ -629,7 +627,7 @@ static void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet)
|
|||||||
/* Main function called by zint framework
|
/* Main function called by zint framework
|
||||||
*/
|
*/
|
||||||
INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[], const size_t length) {
|
INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[], const size_t length) {
|
||||||
size_t charCur,dataLength;
|
int charCur, dataLength;
|
||||||
int Error;
|
int Error;
|
||||||
int rows, columns, useColumns;
|
int rows, columns, useColumns;
|
||||||
int fillings;
|
int fillings;
|
||||||
@ -638,8 +636,8 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
int rowCur;
|
int rowCur;
|
||||||
int characterSetCur;
|
int characterSetCur;
|
||||||
int emptyColumns;
|
int emptyColumns;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
int r, c;
|
int r, c;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
CharacterSetTable *T;
|
CharacterSetTable *T;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -651,7 +649,7 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
/* option1: rows 0: automatic, 1..44 */
|
/* option1: rows 0: automatic, 1..44 */
|
||||||
rows = symbol->option_1;
|
rows = symbol->option_1;
|
||||||
if (rows > 44) {
|
if (rows > 44) {
|
||||||
strcpy(symbol->errtxt, "410: Row parameter not in 0..44");
|
strcpy(symbol->errtxt, "410: Rows parameter not in 0..44");
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
/* option_2: (usable data) columns: 0: automatic, 6..66 */
|
/* option_2: (usable data) columns: 0: automatic, 6..66 */
|
||||||
@ -677,7 +675,7 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
dataLength++;
|
dataLength++;
|
||||||
}
|
}
|
||||||
/* Replace all Codes>127 with <fnc4>Code-128 */
|
/* Replace all Codes>127 with <fnc4>Code-128 */
|
||||||
for (charCur=0;charCur<length;charCur++) {
|
for (charCur = 0; charCur < (int) length; charCur++) {
|
||||||
if (source[charCur]>127)
|
if (source[charCur]>127)
|
||||||
{
|
{
|
||||||
data[dataLength] = aFNC4;
|
data[dataLength] = aFNC4;
|
||||||
@ -711,7 +709,7 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
columns = 64;
|
columns = 64;
|
||||||
}
|
}
|
||||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||||
printf("Auto column count for %zu characters:%d\n",dataLength,columns);
|
printf("Auto column count for %d characters:%d\n", dataLength, columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -719,20 +717,20 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
useColumns = columns - 5;
|
useColumns = columns - 5;
|
||||||
if ( rows > 0 ) {
|
if ( rows > 0 ) {
|
||||||
/* row count given */
|
/* row count given */
|
||||||
Error = Rows2Columns(symbol, T, data, dataLength, &rows, &useColumns, pSet, &fillings);
|
Error = Rows2Columns(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
|
||||||
} else {
|
} else {
|
||||||
/* column count given */
|
/* column count given */
|
||||||
Error = Columns2Rows(symbol, T, data, dataLength, &rows, &useColumns, pSet, &fillings);
|
Error = Columns2Rows(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
|
||||||
}
|
}
|
||||||
if (Error != 0) {
|
if (Error != 0) {
|
||||||
strcpy(symbol->errtxt, "413: Data string to long");
|
strcpy(symbol->errtxt, "413: Data string too long");
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
/* Checksum */
|
/* Checksum */
|
||||||
Sum1=Sum2=0;
|
Sum1=Sum2=0;
|
||||||
if (rows>1)
|
if (rows>1)
|
||||||
{
|
{
|
||||||
size_t charCur;
|
int charCur;
|
||||||
for (charCur=0 ; charCur<dataLength ; charCur++) {
|
for (charCur=0 ; charCur<dataLength ; charCur++) {
|
||||||
Sum1=(Sum1 + (charCur%86+1)*data[charCur])%86;
|
Sum1=(Sum1 + (charCur%86+1)*data[charCur])%86;
|
||||||
Sum2=(Sum2 + (charCur%86)*data[charCur])%86;
|
Sum2=(Sum2 + (charCur%86)*data[charCur])%86;
|
||||||
@ -744,7 +742,6 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
printf("\nData:");
|
printf("\nData:");
|
||||||
for (DPos=0 ; DPos< dataLength ; DPos++)
|
for (DPos=0 ; DPos< dataLength ; DPos++)
|
||||||
fputc(data[DPos],stdout);
|
fputc(data[DPos],stdout);
|
||||||
|
|
||||||
printf("\n Set:");
|
printf("\n Set:");
|
||||||
for (DPos=0 ; DPos< dataLength ; DPos++) {
|
for (DPos=0 ; DPos< dataLength ; DPos++) {
|
||||||
switch (pSet[DPos]&(CodeA+CodeB+CodeC)) {
|
switch (pSet[DPos]&(CodeA+CodeB+CodeC)) {
|
||||||
@ -863,8 +860,8 @@ INTERNAL int codablock(struct zint_symbol *symbol,const unsigned char source[],
|
|||||||
while (emptyColumns>0)
|
while (emptyColumns>0)
|
||||||
{
|
{
|
||||||
/* ? Change character set */
|
/* ? Change character set */
|
||||||
/* not at first possition (It was then the start set) */
|
/* not at first position (It was then the start set) */
|
||||||
/* +++ special case for one-ligner */
|
/* +++ special case for one-liner */
|
||||||
if (emptyColumns<useColumns || (rows == 1 && charCur!=0) )
|
if (emptyColumns<useColumns || (rows == 1 && charCur!=0) )
|
||||||
{
|
{
|
||||||
if ((pSet[charCur]&CodeA)!=0)
|
if ((pSet[charCur]&CodeA)!=0)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -36,7 +36,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -684,7 +683,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
|
|||||||
if (is_extendable(symbol->symbology)) {
|
if (is_extendable(symbol->symbology)) {
|
||||||
/* For these symbols use dummy text to ensure formatting is done
|
/* For these symbols use dummy text to ensure formatting is done
|
||||||
* properly even if no text is required */
|
* properly even if no text is required */
|
||||||
for (i = 0; i < ustrlen(symbol->text); i++) {
|
for (i = 0; i < (int) ustrlen(symbol->text); i++) {
|
||||||
if (symbol->text[i] == '+') {
|
if (symbol->text[i] == '+') {
|
||||||
local_text[i] = '+';
|
local_text[i] = '+';
|
||||||
} else {
|
} else {
|
||||||
@ -769,7 +768,7 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
|
|||||||
r = 0;
|
r = 0;
|
||||||
/* Isolate add-on text */
|
/* Isolate add-on text */
|
||||||
if (is_extendable(symbol->symbology)) {
|
if (is_extendable(symbol->symbology)) {
|
||||||
for (i = 0; i < ustrlen(local_text); i++) {
|
for (i = 0; i < (int) ustrlen(local_text); i++) {
|
||||||
if (latch == 1) {
|
if (latch == 1) {
|
||||||
addon[r] = local_text[i];
|
addon[r] = local_text[i];
|
||||||
r++;
|
r++;
|
||||||
@ -1069,7 +1068,8 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (r = 1; r < symbol->rows; r++) {
|
for (r = 1; r < symbol->rows; r++) {
|
||||||
draw_bar(pixelbuf, (xoffset + 11) * 2 , (symbol->width - 25) * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height);
|
/* Avoid 11-module start and stop chars */
|
||||||
|
draw_bar(pixelbuf, (xoffset + 11) * 2 , (symbol->width - 22) * 2, ((r * row_height) + textoffset + yoffset - 1) * 2, 2 * 2, image_width, image_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,13 @@ zint_add_test(library, test_library)
|
|||||||
zint_add_test(mailmark, test_mailmark)
|
zint_add_test(mailmark, test_mailmark)
|
||||||
zint_add_test(maxicode, test_maxicode)
|
zint_add_test(maxicode, test_maxicode)
|
||||||
zint_add_test(pdf417, test_pdf417)
|
zint_add_test(pdf417, test_pdf417)
|
||||||
|
zint_add_test(png, test_png)
|
||||||
zint_add_test(postal, test_postal)
|
zint_add_test(postal, test_postal)
|
||||||
zint_add_test(qr, test_qr)
|
zint_add_test(qr, test_qr)
|
||||||
zint_add_test(raster, test_raster)
|
zint_add_test(raster, test_raster)
|
||||||
zint_add_test(rss, test_rss)
|
zint_add_test(rss, test_rss)
|
||||||
zint_add_test(sjis, test_sjis)
|
zint_add_test(sjis, test_sjis)
|
||||||
|
zint_add_test(svg, test_svg)
|
||||||
zint_add_test(telepen, test_telepen)
|
zint_add_test(telepen, test_telepen)
|
||||||
zint_add_test(upcean, test_upcean)
|
zint_add_test(upcean, test_upcean)
|
||||||
zint_add_test(vector, test_vector)
|
zint_add_test(vector, test_vector)
|
||||||
|
BIN
backend/tests/data/png/codablockf_3rows.png
Normal file
BIN
backend/tests/data/png/codablockf_3rows.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 347 B |
BIN
backend/tests/data/png/code128_aim.png
Normal file
BIN
backend/tests/data/png/code128_aim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 372 B |
63
backend/tests/data/svg/codablockf_3rows.svg
Normal file
63
backend/tests/data/svg/codablockf_3rows.svg
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="210" height="68" version="1.1"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<desc>Zint Generated Symbol
|
||||||
|
</desc>
|
||||||
|
|
||||||
|
<g id="barcode" fill="#000000">
|
||||||
|
<rect x="0" y="0" width="210" height="68" fill="#FFFFFF" />
|
||||||
|
<rect x="4.00" y="4.00" width="4.00" height="60.00" />
|
||||||
|
<rect x="10.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="20.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="26.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="30.00" y="4.00" width="8.00" height="60.00" />
|
||||||
|
<rect x="40.00" y="4.00" width="6.00" height="60.00" />
|
||||||
|
<rect x="48.00" y="4.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="54.00" y="4.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="58.00" y="4.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="70.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="74.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="82.00" y="4.00" width="4.00" height="60.00" />
|
||||||
|
<rect x="92.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="96.00" y="4.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="104.00" y="4.00" width="4.00" height="40.00" />
|
||||||
|
<rect x="114.00" y="4.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="118.00" y="4.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="126.00" y="4.00" width="4.00" height="40.00" />
|
||||||
|
<rect x="136.00" y="4.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="140.00" y="4.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="148.00" y="4.00" width="4.00" height="40.00" />
|
||||||
|
<rect x="158.00" y="4.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="164.00" y="4.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="172.00" y="4.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="180.00" y="4.00" width="4.00" height="60.00" />
|
||||||
|
<rect x="190.00" y="4.00" width="6.00" height="60.00" />
|
||||||
|
<rect x="198.00" y="4.00" width="2.00" height="60.00" />
|
||||||
|
<rect x="202.00" y="4.00" width="4.00" height="60.00" />
|
||||||
|
<rect x="48.00" y="24.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="58.00" y="24.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="64.00" y="24.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="158.00" y="24.00" width="8.00" height="20.00" />
|
||||||
|
<rect x="168.00" y="24.00" width="2.00" height="40.00" />
|
||||||
|
<rect x="176.00" y="24.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="48.00" y="44.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="52.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="60.00" y="44.00" width="6.00" height="20.00" />
|
||||||
|
<rect x="96.00" y="44.00" width="6.00" height="20.00" />
|
||||||
|
<rect x="104.00" y="44.00" width="8.00" height="20.00" />
|
||||||
|
<rect x="114.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="122.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="128.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="136.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="144.00" y="44.00" width="6.00" height="20.00" />
|
||||||
|
<rect x="154.00" y="44.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="158.00" y="44.00" width="4.00" height="20.00" />
|
||||||
|
<rect x="174.00" y="44.00" width="2.00" height="20.00" />
|
||||||
|
<rect x="26.00" y="22.00" width="158.00" height="4.00" />
|
||||||
|
<rect x="26.00" y="42.00" width="158.00" height="4.00" />
|
||||||
|
<rect x="4.00" y="0.00" width="202.00" height="4.00" />
|
||||||
|
<rect x="4.00" y="64.00" width="202.00" height="4.00" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
41
backend/tests/data/svg/code128_amperands.svg
Normal file
41
backend/tests/data/svg/code128_amperands.svg
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="180" height="118" version="1.1"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<desc>Zint Generated Symbol
|
||||||
|
</desc>
|
||||||
|
|
||||||
|
<g id="barcode" fill="#000000">
|
||||||
|
<rect x="0" y="0" width="180" height="118" fill="#FFFFFF" />
|
||||||
|
<rect x="0.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="6.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="12.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="22.00" y="0.00" width="6.00" height="100.00" />
|
||||||
|
<rect x="32.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="38.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="44.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="50.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="56.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="66.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="74.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="82.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="88.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="94.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="102.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="110.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="116.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="126.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="132.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="138.00" y="0.00" width="6.00" height="100.00" />
|
||||||
|
<rect x="146.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="154.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<rect x="164.00" y="0.00" width="6.00" height="100.00" />
|
||||||
|
<rect x="172.00" y="0.00" width="2.00" height="100.00" />
|
||||||
|
<rect x="176.00" y="0.00" width="4.00" height="100.00" />
|
||||||
|
<text x="90.00" y="118.00" text-anchor="middle"
|
||||||
|
font-family="Helvetica" font-size="18.0" fill="#000000" >
|
||||||
|
<>"&'
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -29,6 +29,8 @@
|
|||||||
*/
|
*/
|
||||||
/* vim: set ts=4 sw=4 et : */
|
/* vim: set ts=4 sw=4 et : */
|
||||||
|
|
||||||
|
//#define TEST_ENCODE_GENERATE_EXPECTED 1
|
||||||
|
|
||||||
#include "testcommon.h"
|
#include "testcommon.h"
|
||||||
|
|
||||||
static void test_options(void)
|
static void test_options(void)
|
||||||
@ -69,6 +71,105 @@ static void test_options(void)
|
|||||||
testFinish();
|
testFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_encode(void)
|
||||||
|
{
|
||||||
|
testStart("");
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
struct item {
|
||||||
|
int input_mode;
|
||||||
|
int option_1;
|
||||||
|
int option_2;
|
||||||
|
unsigned char* data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
int expected_rows;
|
||||||
|
int expected_width;
|
||||||
|
char* comment;
|
||||||
|
char* expected;
|
||||||
|
};
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { UNICODE_MODE, -1, -1, "AIM", 0, 1, 68, "Same as CODE128",
|
||||||
|
"11010010000101000110001100010001010111011000101110110001100011101011"
|
||||||
|
},
|
||||||
|
/* 1*/ { UNICODE_MODE, -1, -1, "AAAAAAAAA", 0, 4, 90, "",
|
||||||
|
"110100001001011110111010010000110101000110001010001100010100011000110010001001100011101011"
|
||||||
|
"110100001001011110111011000100100101000110001010001100010100011000100100110001100011101011"
|
||||||
|
"110100001001011110111010110011100101000110001010001100010100011000100010011001100011101011"
|
||||||
|
"110100001001011101111010111011000101111011101001011000010010011110111001001101100011101011"
|
||||||
|
},
|
||||||
|
/* 2*/ { UNICODE_MODE, 3, -1, "AAAAAAAAA", 0, 3, 101, "Verified manually against tec-it (bwipp differs)",
|
||||||
|
"11010000100101111011101001011000010100011000101000110001010001100010100011000110110011001100011101011"
|
||||||
|
"11010000100101111011101100010010010100011000101000110001010001100010100011000111101000101100011101011"
|
||||||
|
"11010000100101111011101011001110010100011000101110111101100110110011001110010110001001001100011101011"
|
||||||
|
},
|
||||||
|
/* 3*/ { UNICODE_MODE, -1, -1, "AAAAAAAAAAAAAAA", 0, 6, 90, "",
|
||||||
|
"110100001001011110111010000100110101000110001010001100010100011000100110011101100011101011"
|
||||||
|
"110100001001011110111011000100100101000110001010001100010100011000100100110001100011101011"
|
||||||
|
"110100001001011110111010110011100101000110001010001100010100011000100010011001100011101011"
|
||||||
|
"110100001001011110111010011011100101000110001010001100010100011000100110001001100011101011"
|
||||||
|
"110100001001011110111010011001110101000110001010001100010100011000110010010001100011101011"
|
||||||
|
"110100001001011101111010001110110101111011101000110001010111101000110111101101100011101011"
|
||||||
|
},
|
||||||
|
/* 4*/ { UNICODE_MODE, -1, 14, "AAAAAAAAAAAAAAA", 0, 2, 156, "",
|
||||||
|
"110100001001011110111010100001100101000110001010001100010100011000101000110001010001100010100011000101000110001010001100010100011000110001000101100011101011"
|
||||||
|
"110100001001011110111011000100100101000110001010001100010100011000101000110001010001100010100011000101110111101110111101011011000110111000101101100011101011"
|
||||||
|
},
|
||||||
|
/* 5*/ { UNICODE_MODE, 3, -1, "AAAAAAAAAAAAAAA", 0, 3, 123, "Differs from tec-it (and bwipp); TODO: verify",
|
||||||
|
"110100001001011110111010010110000101000110001010001100010100011000101000110001010001100010100011000101111001001100011101011"
|
||||||
|
"110100001001011110111011000100100101000110001010001100010100011000101000110001010001100010100011000110000101001100011101011"
|
||||||
|
"110100001001011110111010110011100101000110001010001100010100011000101110111101110111101011011000110110110001101100011101011"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
int data_size = sizeof(data) / sizeof(struct item);
|
||||||
|
|
||||||
|
char escaped[1024];
|
||||||
|
|
||||||
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
struct zint_symbol* symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
symbol->symbology = BARCODE_CODABLOCKF;
|
||||||
|
symbol->input_mode = data[i].input_mode;
|
||||||
|
if (data[i].option_1 != -1) {
|
||||||
|
symbol->option_1 = data[i].option_1;
|
||||||
|
}
|
||||||
|
if (data[i].option_2 != -1) {
|
||||||
|
symbol->option_2 = data[i].option_2;
|
||||||
|
}
|
||||||
|
//symbol->debug = ZINT_DEBUG_PRINT;
|
||||||
|
|
||||||
|
int length = strlen(data[i].data);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, data[i].data, length);
|
||||||
|
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||||
|
|
||||||
|
#ifdef TEST_ENCODE_GENERATE_EXPECTED
|
||||||
|
printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, \"%s\",\n",
|
||||||
|
i, testUtilInputModeName(data[i].input_mode), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
|
||||||
|
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment);
|
||||||
|
testUtilModulesDump(symbol, " ", "\n");
|
||||||
|
printf(" },\n");
|
||||||
|
#else
|
||||||
|
if (ret < 5) {
|
||||||
|
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
|
||||||
|
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
int width, row;
|
||||||
|
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
|
||||||
|
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
// #181 Christian Hartlage OSS-Fuzz
|
// #181 Christian Hartlage OSS-Fuzz
|
||||||
static void test_fuzz(void)
|
static void test_fuzz(void)
|
||||||
{
|
{
|
||||||
@ -109,6 +210,7 @@ static void test_fuzz(void)
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_options();
|
test_options();
|
||||||
|
test_encode();
|
||||||
test_fuzz();
|
test_fuzz();
|
||||||
|
|
||||||
testReport();
|
testReport();
|
||||||
|
118
backend/tests/test_png.c
Normal file
118
backend/tests/test_png.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the project nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/* vim: set ts=4 sw=4 et : */
|
||||||
|
|
||||||
|
#include "testcommon.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
//#define TEST_PRINT_GENERATE_EXPECTED 1
|
||||||
|
|
||||||
|
static void test_print(void)
|
||||||
|
{
|
||||||
|
testStart("");
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
struct item {
|
||||||
|
int symbology;
|
||||||
|
int option_1;
|
||||||
|
int option_2;
|
||||||
|
unsigned char* data;
|
||||||
|
char* expected_file;
|
||||||
|
};
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { BARCODE_CODE128, -1, -1, "AIM", "../data/png/code128_aim.png" },
|
||||||
|
/* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png" },
|
||||||
|
};
|
||||||
|
int data_size = sizeof(data) / sizeof(struct item);
|
||||||
|
|
||||||
|
char* data_dir = "../data/png";
|
||||||
|
char* png = "out.png";
|
||||||
|
char escaped[1024];
|
||||||
|
int escaped_size = 1024;
|
||||||
|
|
||||||
|
#ifdef TEST_PRINT_GENERATE_EXPECTED
|
||||||
|
if (!testUtilExists(data_dir)) {
|
||||||
|
ret = mkdir(data_dir, 0755);
|
||||||
|
assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
struct zint_symbol* symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
symbol->symbology = data[i].symbology;
|
||||||
|
if (data[i].option_1 != -1) {
|
||||||
|
symbol->option_1 = data[i].option_1;
|
||||||
|
}
|
||||||
|
if (data[i].option_2 != -1) {
|
||||||
|
symbol->option_2 = data[i].option_2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = strlen(data[i].data);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, data[i].data, length);
|
||||||
|
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||||
|
|
||||||
|
strcpy(symbol->outfile, png);
|
||||||
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
#ifdef TEST_PRINT_GENERATE_EXPECTED
|
||||||
|
|
||||||
|
printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
||||||
|
ret = rename(symbol->outfile, data[i].expected_file);
|
||||||
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
|
|
||||||
|
ret = testUtilCmpPngs(symbol->outfile, data[i].expected_file);
|
||||||
|
assert_zero(ret, "i:%d %s testUtilCmpPngs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
||||||
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_print();
|
||||||
|
|
||||||
|
testReport();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
118
backend/tests/test_svg.c
Normal file
118
backend/tests/test_svg.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2020 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the project nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/* vim: set ts=4 sw=4 et : */
|
||||||
|
|
||||||
|
#include "testcommon.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
//#define TEST_PRINT_GENERATE_EXPECTED 1
|
||||||
|
|
||||||
|
static void test_print(void)
|
||||||
|
{
|
||||||
|
testStart("");
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
struct item {
|
||||||
|
int symbology;
|
||||||
|
int option_1;
|
||||||
|
int option_2;
|
||||||
|
unsigned char* data;
|
||||||
|
char* expected_file;
|
||||||
|
};
|
||||||
|
struct item data[] = {
|
||||||
|
/* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" },
|
||||||
|
/* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg" },
|
||||||
|
};
|
||||||
|
int data_size = sizeof(data) / sizeof(struct item);
|
||||||
|
|
||||||
|
char* data_dir = "../data/svg";
|
||||||
|
char* svg = "out.svg";
|
||||||
|
char escaped[1024];
|
||||||
|
int escaped_size = 1024;
|
||||||
|
|
||||||
|
#ifdef TEST_PRINT_GENERATE_EXPECTED
|
||||||
|
if (!testUtilExists(data_dir)) {
|
||||||
|
ret = mkdir(data_dir, 0755);
|
||||||
|
assert_zero(ret, "mkdir(%s) ret %d != 0\n", data_dir, ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < data_size; i++) {
|
||||||
|
|
||||||
|
struct zint_symbol* symbol = ZBarcode_Create();
|
||||||
|
assert_nonnull(symbol, "Symbol not created\n");
|
||||||
|
|
||||||
|
symbol->symbology = data[i].symbology;
|
||||||
|
if (data[i].option_1 != -1) {
|
||||||
|
symbol->option_1 = data[i].option_1;
|
||||||
|
}
|
||||||
|
if (data[i].option_2 != -1) {
|
||||||
|
symbol->option_2 = data[i].option_2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = strlen(data[i].data);
|
||||||
|
|
||||||
|
ret = ZBarcode_Encode(symbol, data[i].data, length);
|
||||||
|
assert_zero(ret, "i:%d %s ZBarcode_Encode ret %d != 0 %s\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
|
||||||
|
|
||||||
|
strcpy(symbol->outfile, svg);
|
||||||
|
ret = ZBarcode_Print(symbol, 0);
|
||||||
|
assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret);
|
||||||
|
|
||||||
|
#ifdef TEST_PRINT_GENERATE_EXPECTED
|
||||||
|
|
||||||
|
printf(" /*%2d*/ { %s, \"%s\", \"%s\"},\n", i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file);
|
||||||
|
ret = rename(symbol->outfile, data[i].expected_file);
|
||||||
|
assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
assert_nonzero(testUtilExists(symbol->outfile), "i:%d testUtilExists(%s) == 0\n", i, symbol->outfile);
|
||||||
|
|
||||||
|
ret = testUtilCmpSvgs(symbol->outfile, data[i].expected_file);
|
||||||
|
assert_zero(ret, "i:%d %s testUtilCmpSvgs(%s, %s) %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, data[i].expected_file, ret);
|
||||||
|
assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZBarcode_Delete(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_print();
|
||||||
|
|
||||||
|
testReport();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
libzint - the open source barcode library
|
libzint - the open source barcode library
|
||||||
Copyright (C) 2008-2019 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
@ -142,6 +142,7 @@ static void test_buffer_vector(void)
|
|||||||
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 },
|
/* 89*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 },
|
||||||
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 },
|
/* 90*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 },
|
||||||
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 },
|
/* 91*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 },
|
||||||
|
/* 92*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 },
|
||||||
};
|
};
|
||||||
int data_size = sizeof(data) / sizeof(struct item);
|
int data_size = sizeof(data) / sizeof(struct item);
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -293,6 +292,9 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
|||||||
int this_row;
|
int this_row;
|
||||||
int addon_latch = 0;
|
int addon_latch = 0;
|
||||||
struct zint_vector_string *string;
|
struct zint_vector_string *string;
|
||||||
|
|
||||||
|
(void)rotate_angle; /* Not currently implemented */
|
||||||
|
|
||||||
// Sanity check colours
|
// Sanity check colours
|
||||||
to_upper((unsigned char*) symbol->fgcolour);
|
to_upper((unsigned char*) symbol->fgcolour);
|
||||||
to_upper((unsigned char*) symbol->bgcolour);
|
to_upper((unsigned char*) symbol->bgcolour);
|
||||||
@ -792,7 +794,8 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
|||||||
rectangle = vector_plot_create_rect((float)xoffset, (r * row_height) + yoffset - 1, (float)symbol->width, 2.0f);
|
rectangle = vector_plot_create_rect((float)xoffset, (r * row_height) + yoffset - 1, (float)symbol->width, 2.0f);
|
||||||
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
||||||
} else {
|
} else {
|
||||||
rectangle = vector_plot_create_rect(xoffset + 11.0f, (r * row_height) + yoffset - 1, symbol->width - 25.0f, 2.0);
|
/* Avoid 11-module start and stop chars */
|
||||||
|
rectangle = vector_plot_create_rect(xoffset + 11, (r * row_height) + yoffset - 1, symbol->width - 22, 2.0);
|
||||||
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user