mirror of
https://git.code.sf.net/p/zint/code
synced 2026-06-09 23:23:36 +00:00
raster/vector: allow for separator height being > twice row height
(ticket #353, props Simon Resch)
This commit is contained in:
+26
-17
@@ -742,6 +742,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
int border_width;
|
||||
int option_1;
|
||||
int option_3;
|
||||
float height;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
@@ -756,15 +757,18 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 },
|
||||
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Same as default */
|
||||
/* 2*/ { BARCODE_CODABLOCKF, -1, -1, 1, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Same as default */
|
||||
/* 3*/ { BARCODE_CODABLOCKF, -1, -1, 2, "A", 0, 20, 2, 101, 242, 44, 20, 42, 4 },
|
||||
/* 4*/ { BARCODE_CODABLOCKF, -1, -1, 3, "A", 0, 20, 2, 101, 242, 44, 19, 42, 6 },
|
||||
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, 4, "A", 0, 20, 2, 101, 242, 44, 18, 42, 8 },
|
||||
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, 5, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* > 4 ignored, same as default */
|
||||
/* 7*/ { BARCODE_CODABLOCKF, -1, 1, -1, "A", 0, 5, 1, 46, 132, 14, 0, 20 + 2, 2 }, /* CODE128 top separator, add 2 to skip over end of start char; note no longer includes HRT */
|
||||
/* 8*/ { BARCODE_CODABLOCKF, 0, -1, -1, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Border width zero, same as default */
|
||||
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 },
|
||||
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, 0, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Same as default */
|
||||
/* 2*/ { BARCODE_CODABLOCKF, -1, -1, 1, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Same as default */
|
||||
/* 3*/ { BARCODE_CODABLOCKF, -1, -1, 2, 0, "A", 0, 20, 2, 101, 242, 44, 20, 42, 4 },
|
||||
/* 4*/ { BARCODE_CODABLOCKF, -1, -1, 3, 0, "A", 0, 20, 2, 101, 242, 44, 19, 42, 6 },
|
||||
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, 4, 0, "A", 0, 20, 2, 101, 242, 44, 18, 42, 8 },
|
||||
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, 5, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* > 4 ignored, same as default */
|
||||
/* 7*/ { BARCODE_CODABLOCKF, -1, 1, -1, 0, "A", 0, 5, 1, 46, 132, 14, 0, 20 + 2, 2 }, /* CODE128 top separator, add 2 to skip over end of start char; note no longer includes HRT */
|
||||
/* 8*/ { BARCODE_CODABLOCKF, 0, -1, -1, 0, "A", 0, 20, 2, 101, 242, 44, 21, 42, 2 }, /* Border width zero, same as default */
|
||||
/* 9*/ { BARCODE_CODABLOCKF, -1, -1, 4, 2, "A", 0, 2, 2, 101, 242, 8, 0, 42, 8 }, /* Ticket #353, props Simon Resch */
|
||||
/* 10*/ { BARCODE_CODABLOCKF, -1, -1, 4, 1.5, "A", 0, 2, 2, 101, 242, 8, 0, 42, 8 }, /* Height gets rounded up as not integral */
|
||||
/* 11*/ { BARCODE_CODABLOCKF, -1, -1, 4, 1, "A", 0, 1, 2, 101, 242, 6, 0, 42, 6 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -785,6 +789,9 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
if (data[i].border_width != -1) {
|
||||
symbol->border_width = data[i].border_width;
|
||||
}
|
||||
if (data[i].height) {
|
||||
symbol->height = data[i].height;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode_and_Buffer(symbol, (unsigned char *) data[i].data, length, 0);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
@@ -805,15 +812,17 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
assert_nonzero(separator_bits_set, "i:%d (%s) separator_bits_set (%d, %d) zero\n", i, testUtilBarcodeName(data[i].symbology), j, data[i].expected_separator_col);
|
||||
}
|
||||
|
||||
if (symbol->rows > 1) {
|
||||
j = data[i].expected_separator_row - 1;
|
||||
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); /* Need to add 2 to skip to 1st blank of start row character */
|
||||
assert_zero(separator_bits_set, "i:%d (%s) separator_bits_set (%d, %d) before non-zero\n", i, testUtilBarcodeName(data[i].symbology), j, data[i].expected_separator_col);
|
||||
}
|
||||
if (data[i].expected_separator_row > 0) {
|
||||
if (symbol->rows > 1) {
|
||||
j = data[i].expected_separator_row - 1;
|
||||
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); /* Need to add 2 to skip to 1st blank of start row character */
|
||||
assert_zero(separator_bits_set, "i:%d (%s) separator_bits_set (%d, %d) before non-zero\n", i, testUtilBarcodeName(data[i].symbology), j, data[i].expected_separator_col);
|
||||
}
|
||||
|
||||
j = data[i].expected_separator_row + data[i].expected_separator_height;
|
||||
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); /* Need to add 2 to skip to 1st blank of start row character */
|
||||
assert_zero(separator_bits_set, "i:%d (%s) separator_bits_set (%d, %d) after non-zero\n", i, testUtilBarcodeName(data[i].symbology), j, data[i].expected_separator_col);
|
||||
j = data[i].expected_separator_row + data[i].expected_separator_height;
|
||||
separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col + 2); /* Need to add 2 to skip to 1st blank of start row character */
|
||||
assert_zero(separator_bits_set, "i:%d (%s) separator_bits_set (%d, %d) after non-zero\n", i, testUtilBarcodeName(data[i].symbology), j, data[i].expected_separator_col);
|
||||
}
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
|
||||
+25
-14
@@ -1123,7 +1123,7 @@ static void test_upcean_hrt(const testCtx *const p_ctx) {
|
||||
i, testUtilBarcodeName(data[i].symbology), symbol->vector->height,
|
||||
data[i].expected_vector_height);
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
@@ -1165,6 +1165,7 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
int border_width;
|
||||
int option_1;
|
||||
int option_3;
|
||||
float height;
|
||||
const char *data;
|
||||
int ret;
|
||||
|
||||
@@ -1177,15 +1178,18 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, "A", 0, 20, 2, 101, 42, 21, 2 },
|
||||
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, 0, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Same as default */
|
||||
/* 2*/ { BARCODE_CODABLOCKF, -1, -1, 1, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Same as default */
|
||||
/* 3*/ { BARCODE_CODABLOCKF, -1, -1, 2, "A", 0, 20, 2, 101, 42, 20, 4 },
|
||||
/* 4*/ { BARCODE_CODABLOCKF, -1, -1, 3, "A", 0, 20, 2, 101, 42, 19, 6 },
|
||||
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, 4, "A", 0, 20, 2, 101, 42, 18, 8 },
|
||||
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, 5, "A", 0, 20, 2, 101, 42, 21, 2 }, /* > 4 ignored, same as default */
|
||||
/* 7*/ { BARCODE_CODABLOCKF, -1, 1, -1, "A", 0, 5, 1, 46, 20, 0, 2 }, /* CODE128 top separator */
|
||||
/* 8*/ { BARCODE_CODABLOCKF, 0, -1, -1, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Border width zero, same as default */
|
||||
/* 0*/ { BARCODE_CODABLOCKF, -1, -1, -1, 0, "A", 0, 20, 2, 101, 42, 21, 2 },
|
||||
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, 0, 0, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Same as default */
|
||||
/* 2*/ { BARCODE_CODABLOCKF, -1, -1, 1, 0, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Same as default */
|
||||
/* 3*/ { BARCODE_CODABLOCKF, -1, -1, 2, 0, "A", 0, 20, 2, 101, 42, 20, 4 },
|
||||
/* 4*/ { BARCODE_CODABLOCKF, -1, -1, 3, 0, "A", 0, 20, 2, 101, 42, 19, 6 },
|
||||
/* 5*/ { BARCODE_CODABLOCKF, -1, -1, 4, 0, "A", 0, 20, 2, 101, 42, 18, 8 },
|
||||
/* 6*/ { BARCODE_CODABLOCKF, -1, -1, 5, 0, "A", 0, 20, 2, 101, 42, 21, 2 }, /* > 4 ignored, same as default */
|
||||
/* 7*/ { BARCODE_CODABLOCKF, -1, 1, -1, 0, "A", 0, 5, 1, 46, 20, 0, 2 }, /* CODE128 top separator */
|
||||
/* 8*/ { BARCODE_CODABLOCKF, 0, -1, -1, 0, "A", 0, 20, 2, 101, 42, 21, 2 }, /* Border width zero, same as default */
|
||||
/* 9*/ { BARCODE_CODABLOCKF, -1, -1, 4, 2, "A", 0, 2, 2, 101, 42, 0, 8 }, /* Ticket #353, props Simon Resch */
|
||||
/* 10*/ { BARCODE_CODABLOCKF, -1, -1, 4, 1.5, "A", 0, 1.5, 2, 101, 42, 0, 8 },
|
||||
/* 11*/ { BARCODE_CODABLOCKF, -1, -1, 4, 1, "A", 0, 1, 2, 101, 42, 0, 8 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -1206,6 +1210,9 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
if (data[i].border_width != -1) {
|
||||
symbol->border_width = data[i].border_width;
|
||||
}
|
||||
if (data[i].height) {
|
||||
symbol->height = data[i].height;
|
||||
}
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_zero(ret, "i:%d ZBarcode_Encode(%d) ret %d != 0 %s\n", i, data[i].symbology, ret, symbol->errtxt);
|
||||
@@ -1214,6 +1221,10 @@ static void test_row_separator(const testCtx *const p_ctx) {
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
|
||||
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %.9g != %.9g\n", i, data[i].symbology, symbol->height, data[i].expected_height);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
|
||||
@@ -1286,7 +1297,7 @@ static void test_stacking(const testCtx *const p_ctx) {
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width);
|
||||
|
||||
if (data[i].expected_separator_y != -1) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
@@ -1424,7 +1435,7 @@ static void test_output_options(const testCtx *const p_ctx) {
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
@@ -1558,7 +1569,7 @@ static void test_upcean_whitespace_width(const testCtx *const p_ctx) {
|
||||
assert_zero(ret, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != 0\n", i, data[i].symbology, ret);
|
||||
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
@@ -1656,7 +1667,7 @@ static void test_scale(const testCtx *const p_ctx) {
|
||||
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret_vector, symbol->errtxt);
|
||||
assert_nonnull(symbol->vector, "i:%d ZBarcode_Buffer_Vector(%d) vector NULL\n", i, data[i].symbology);
|
||||
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
|
||||
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) { /* ZINT_DEBUG_TEST_PRINT 16 */
|
||||
testUtilVectorPrint(symbol);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user