1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-10-29 06:12:31 +00:00

QRCODE: qr_evaluate: float sufficient for Test 4 percentage calc;

add const to func def; augment ZINTLOG stuff; add direct tests
common.c: fix vsnprintf guard ZINT_IS_C89 -> Z_NO_VSNPRINTF
GRIDMATRIX: fix arg conversion warning (MSVC)
This commit is contained in:
gitlost
2026-10-21 07:07:07 +01:00
parent f5fd98106d
commit c20bd251f0
5 changed files with 300 additions and 14 deletions
+1 -1
View File
@@ -1230,7 +1230,7 @@ INTERNAL int z_ct_printf_256(struct zint_symbol *symbol, const char *fmt, ...) {
va_start(ap, fmt);
#ifdef ZINT_IS_C89
#ifdef Z_NO_VSNPRINTF
size = vsprintf((char *) symbol->content_segs[0].source, fmt, ap);
#else
size = vsnprintf((char *) symbol->content_segs[0].source, 256, fmt, ap);
+1
View File
@@ -126,6 +126,7 @@ typedef unsigned __int64 uint64_t;
# define ceilf (float) ceil
# define floorf (float) floor
# define fmodf (float) fmod
# define fabsf (float) fabs
#endif
/* `round()` (C99) not before MSVC 2013 (C++ 12.0) */
#if (defined(_MSC_VER) && _MSC_VER < 1800) || defined(ZINT_IS_C89)
+1 -1
View File
@@ -448,7 +448,7 @@ static int gm_encode(const unsigned int ddata[], const int length, char binary[]
if (punt == 13) {
glyph = 15;
} else {
glyph = z_posn(gm_numeral_nondigits, punt) * 3;
glyph = z_posn(gm_numeral_nondigits, (const char) punt) * 3;
}
glyph += nondigit_posn;
glyph += 1000;
+22 -12
View File
@@ -1041,12 +1041,15 @@ static void qr_populate_grid(unsigned char *grid, const int h_size, const int v_
}
}
#if 0
#define ZINTLOG
#endif
#ifdef ZINTLOG
static void append_log(const unsigned char log) {
FILE *file;
if ((file = fopen("zintlog.txt", "a+"))) {
fprintf(file, "%02X", log);
fprintf(file, "%d", log);
(void) fclose(file);
}
}
@@ -1061,18 +1064,18 @@ static void write_log(const char log[]) {
}
#endif
static int qr_evaluate(unsigned char *local, const int size) {
static int qr_evaluate(const unsigned char *local, const int size) {
static const unsigned char h1011101[7] = { 1, 0, 1, 1, 1, 0, 1 };
int x, y, r, k, block;
int result = 0;
char state;
int dark_mods;
double percentage;
float percentage;
int a, b, afterCount, beforeCount;
#ifdef ZINTLOG
int result_b = 0;
char str[15];
char str[64];
#endif
/* Suppresses clang-tidy clang-analyzer-core.UndefinedBinaryOperatorResult warnings */
@@ -1080,6 +1083,7 @@ static int qr_evaluate(unsigned char *local, const int size) {
#ifdef ZINTLOG
/* bitmask output */
write_log("\n+++++");
for (y = 0; y < size; y++) {
for (x = 0; x < size; x++) {
append_log(local[(y * size) + x]);
@@ -1136,7 +1140,7 @@ static int qr_evaluate(unsigned char *local, const int size) {
#ifdef ZINTLOG
/* output Test 1 */
sprintf(str, "%d", result);
sprintf(str, " 1: %d", result);
result_b = result;
write_log(str);
#endif
@@ -1154,7 +1158,7 @@ static int qr_evaluate(unsigned char *local, const int size) {
#ifdef ZINTLOG
/* output Test 2 */
sprintf(str, "%d", result - result_b);
sprintf(str, " 2: %d", result - result_b);
result_b = result;
write_log(str);
#endif
@@ -1248,29 +1252,35 @@ static int qr_evaluate(unsigned char *local, const int size) {
#ifdef ZINTLOG
/* output Test 3 */
sprintf(str, "%d", result - result_b);
sprintf(str, " 3: %d", result - result_b);
result_b = result;
write_log(str);
#endif
/* Test 4: Proportion of dark modules in entire symbol */
percentage = (100.0 * dark_mods) / (size * size);
k = (int) (fabs(percentage - 50.0) / 5.0);
percentage = (100.0f * dark_mods) / (size * size);
k = (int) (fabsf(percentage - 50.0f) / 5.0f);
result += 10 * k;
#ifdef ZINTLOG
/* output Test 4+summary */
sprintf(str, "%d", result - result_b);
sprintf(str, " 4: %d (%g%%, %d, %d)", result - result_b, percentage, k, dark_mods);
write_log(str);
write_log("==========");
sprintf(str, "%d", result);
write_log( " ====");
sprintf(str, " %d", result);
write_log(str);
#endif
return result;
}
#ifdef ZINT_TEST /* Wrapper for direct testing */
INTERNAL int zint_test_qr_evaluate(const unsigned char *local, const int size) {
return qr_evaluate(local, size);
}
#endif
/* Add format information to grid */
static void qr_add_format_info(unsigned char *grid, const int size, const int ecc_level, const int pattern) {
int format = pattern;
+275
View File
@@ -30,6 +30,7 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
#include <math.h>
static void test_qr_large(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@@ -9745,6 +9746,278 @@ static void test_fuzz(const testCtx *const p_ctx) {
testFinish();
}
INTERNAL int zint_test_qr_evaluate(const unsigned char *local, const int size);
static void test_qr_evaluate(const testCtx *const p_ctx) {
struct item {
const char *data;
int size;
int ret;
};
/* s/\v(\/\*)[ 0-9]*(\*\/)/\=printf("%s%3d%s", submatch(1), (@z+setreg('z',@z+1)), submatch(2))/ | let @z=0: */
static const struct item data[] = {
/* 0*/ { "\001\001\001\001\001\001\000\001\001\001\000\001\000\001\001\001\000\001\000\000\000"
"\000\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001"
"\000\001\000\001\000\001\000\000\001\001\000\001\001\001\000\000\000\001\001\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\001\001\000\001\001\001\001\000\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\000"
"\001\000\000\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\000\001"
"\000\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001"
"\001\000\001\000\001\000\001\001\001\001\000\000\001\001\001\001\000\001\001\001\001", 21, 146 }, /* 1 horz. 6-run (4), 1 vert. 5-run (3), 3 2x2 blocks (9), 1 horz. 11311s (80), 1 vert. 11311 (40), 55.33% dark (10) */
/* 1*/ { "\001\000\001\001\001\001\000\001\001\001\001\000\001\001\001\001\000\001\001\000\001"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001"
"\000\001\000\001\000\001\000\000\001\001\000\001\001\001\000\000\000\001\001\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\001\001\000\001\001\001\001\000\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\000"
"\001\000\000\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\000\000\001"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\001\001\001\000\000\001\001\001\001\000\001\001\001\001", 21, 0 }, /* 54.88% dark */
/* 2*/ { "\001\000\001\001\001\001\000\001\001\001\001\000\001\001\001\001\000\001\001\000\001"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001"
"\000\001\000\001\000\001\000\000\001\001\000\001\001\001\000\000\000\001\001\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\001\001\000\001\001\001\001\000\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\000"
"\001\000\000\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\000\000\001"
"\001\001\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\001\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\001\001\001\000\000\001\001\001\001\000\000\001\001\001\001\000\001\001\001\001", 21, 10 }, /* 55.1% dark */
/* 3*/ { "\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000", 21, 10 }, /* 40.17% dark */
/* 4*/ { "\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"
"\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000", 21, 20 }, /* 39.91% dark */
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
ret = zint_test_qr_evaluate(ZCUCP(data[i].data), data[i].size);
assert_equal(ret, data[i].ret, "i:%d zint_test_qr_evaluate() ret %d != %d\n", i, ret, data[i].ret);
}
testFinish();
}
static int qr_evaluate_k(const int dark_mods, const int size, float *p_percentage) {
/* Must be same as Test 4 code in `qr_evaluate()` */
*p_percentage = (100.0 * dark_mods) / (size * size);
return (int) (fabsf(*p_percentage - 50.0f) / 5.0f);
}
static void test_qr_evaluate_k(const testCtx *const p_ctx) {
struct item {
int dark_mods;
int size;
int k;
float percentage;
};
/* s/\v(\/\*)[ 0-9]*(\*\/)/\=printf("%s%3d%s", submatch(1), (@z+setreg('z',@z+1)), submatch(2))/ | let @z=0: */
static const struct item data[] = {
/* 0*/ { 264, 21, 1, 59.863945f },
/* 1*/ { 265, 21, 2, 60.0907021f },
/* 2*/ { 286, 21, 2, 64.8526077f },
/* 3*/ { 287, 21, 3, 65.0793686f },
/* 4*/ { 308, 21, 3, 69.8412704f },
/* 5*/ { 309, 21, 4, 70.0680237f },
/* 6*/ { 330, 21, 4, 74.8299332f },
/* 7*/ { 331, 21, 5, 75.0566864f },
/* 8*/ { 352, 21, 5, 79.8185959f },
/* 9*/ { 353, 21, 6, 80.0453491f },
/* 10*/ { 374, 21, 6, 84.8072586f },
/* 11*/ { 375, 21, 7, 85.0340118f },
/* 12*/ { 396, 21, 7, 89.7959213f },
/* 13*/ { 397, 21, 8, 90.0226746f },
/* 14*/ { 418, 21, 8, 94.784584f },
/* 15*/ { 419, 21, 9, 95.0113373f },
/* 16*/ { 1560, 51, 1, 59.9769325f },
/* 17*/ { 1561, 51, 2, 60.015377f },
/* 18*/ { 1690, 51, 2, 64.9750061f },
/* 19*/ { 1691, 51, 3, 65.0134583f },
/* 20*/ { 1820, 51, 3, 69.9730835f },
/* 21*/ { 1821, 51, 4, 70.0115356f },
/* 22*/ { 1950, 51, 4, 74.9711685f },
/* 23*/ { 1951, 51, 5, 75.009613f },
/* 24*/ { 2080, 51, 5, 79.9692459f },
/* 25*/ { 2081, 51, 6, 80.0076904f },
/* 26*/ { 2210, 51, 6, 84.9673233f },
/* 27*/ { 2211, 51, 7, 85.0057678f },
/* 28*/ { 2340, 51, 7, 89.9654007f },
/* 29*/ { 2341, 51, 8, 90.0038452f },
/* 30*/ { 2470, 51, 8, 94.9634781f },
/* 31*/ { 2471, 51, 9, 95.0019226f },
/* 32*/ { 510, 101, 9, 4.99950981f },
/* 33*/ { 511, 101, 8, 5.00931263f },
/* 34*/ { 1020, 101, 8, 9.99901962f },
/* 35*/ { 1021, 101, 7, 10.0088224f },
/* 36*/ { 1530, 101, 7, 14.9985294f },
/* 37*/ { 1531, 101, 6, 15.0083323f },
/* 38*/ { 2040, 101, 6, 19.9980392f },
/* 39*/ { 2041, 101, 5, 20.007843f },
/* 40*/ { 2550, 101, 5, 24.9975491f },
/* 41*/ { 2551, 101, 4, 25.0073528f },
/* 42*/ { 3060, 101, 4, 29.9970589f },
/* 43*/ { 3061, 101, 3, 30.0068626f },
/* 44*/ { 3570, 101, 3, 34.9965706f },
/* 45*/ { 3571, 101, 2, 35.0063705f },
/* 46*/ { 4080, 101, 2, 39.9960785f },
/* 47*/ { 4081, 101, 1, 40.0058823f },
/* 48*/ { 6120, 101, 1, 59.9941177f },
/* 49*/ { 6121, 101, 2, 60.0039215f },
/* 50*/ { 6630, 101, 2, 64.9936295f },
/* 51*/ { 6631, 101, 3, 65.0034332f },
/* 52*/ { 7140, 101, 3, 69.9931412f },
/* 53*/ { 7141, 101, 4, 70.0029373f },
/* 54*/ { 7650, 101, 4, 74.9926453f },
/* 55*/ { 7651, 101, 5, 75.002449f },
/* 56*/ { 8160, 101, 5, 79.992157f },
/* 57*/ { 8161, 101, 6, 80.0019608f },
/* 58*/ { 8670, 101, 6, 84.9916687f },
/* 59*/ { 8671, 101, 7, 85.0014725f },
/* 60*/ { 9180, 101, 7, 89.9911804f },
/* 61*/ { 9181, 101, 8, 90.0009766f },
/* 62*/ { 9690, 101, 8, 94.9906845f },
/* 63*/ { 9691, 101, 9, 95.0004883f },
/* 64*/ { 11928, 141, 1, 59.9969826f },
/* 65*/ { 11929, 141, 2, 60.0020103f },
/* 66*/ { 12922, 141, 2, 64.996727f },
/* 67*/ { 12923, 141, 3, 65.0017624f },
/* 68*/ { 13916, 141, 3, 69.9964828f },
/* 69*/ { 13917, 141, 4, 70.0015106f },
/* 70*/ { 14910, 141, 4, 74.9962311f },
/* 71*/ { 14911, 141, 5, 75.0012589f },
/* 72*/ { 15904, 141, 5, 79.9959793f },
/* 73*/ { 15905, 141, 6, 80.0010071f },
/* 74*/ { 16898, 141, 6, 84.9957275f },
/* 75*/ { 16899, 141, 7, 85.0007553f },
/* 76*/ { 17892, 141, 7, 89.9954758f },
/* 77*/ { 17893, 141, 8, 90.0005035f },
/* 78*/ { 18886, 141, 8, 94.995224f },
/* 79*/ { 18887, 141, 9, 95.0002518f },
/* 80*/ { 17544, 171, 1, 59.9979477f },
/* 81*/ { 17545, 171, 2, 60.0013695f },
/* 82*/ { 19006, 171, 2, 64.9977798f },
/* 83*/ { 19007, 171, 3, 65.0011978f },
/* 84*/ { 20468, 171, 3, 69.9976044f },
/* 85*/ { 20469, 171, 4, 70.0010223f },
/* 86*/ { 21930, 171, 4, 74.9974365f },
/* 87*/ { 21931, 171, 5, 75.0008545f },
/* 88*/ { 23392, 171, 5, 79.997261f },
/* 89*/ { 23393, 171, 6, 80.0006866f },
/* 90*/ { 24854, 171, 6, 84.9970932f },
/* 91*/ { 24855, 171, 7, 85.0005112f },
/* 92*/ { 26316, 171, 7, 89.9969254f },
/* 93*/ { 26317, 171, 8, 90.0003433f },
/* 94*/ { 27778, 171, 8, 94.9967499f },
/* 95*/ { 27779, 171, 9, 95.0001678f },
};
const int data_size = ARRAY_SIZE(data);
int i;
float percentage;
int k;
testStart(p_ctx->func_name);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
k = qr_evaluate_k(data[i].dark_mods, data[i].size, &percentage);
if (p_ctx->generate) {
printf(" /*%3d*/ { %d, %d, %d, %.9gf },\n", i, data[i].dark_mods, data[i].size, k, percentage);
} else {
assert_equal(k, data[i].k, "i:%d zint_test_qr_evaluate() k %d != %d\n", i, k, data[i].k);
assert_nonzero(percentage == data[i].percentage, "i:%d test_qr_evaluate_k percentage %.9g != %.9g\n",
i, percentage, data[i].percentage);
}
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */
@@ -9780,6 +10053,8 @@ int main(int argc, char *argv[]) {
{ "test_rmqr_rt_segs", test_rmqr_rt_segs },
{ "test_fuzz", test_fuzz },
{ "test_qr_evaluate", test_qr_evaluate },
{ "test_qr_evaluate_k", test_qr_evaluate_k },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));