summaryrefslogtreecommitdiff
path: root/test/number.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-24 00:56:48 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-24 00:56:48 +0000
commitd8b5dd586db230db3f09bedba9bfc0bdb254fe57 (patch)
treecc03414893089bec421e755efb949a76d470fe6e /test/number.c
parentf235d82dccb499f1af06e7ef3e1d7b9b57c12014 (diff)
downloadlibcss-d8b5dd586db230db3f09bedba9bfc0bdb254fe57.tar.gz
libcss-d8b5dd586db230db3f09bedba9bfc0bdb254fe57.tar.bz2
Fix number parsing and make test code automatically determine correctness.
More test data, which covers everything. Fix includes in libcss/types.h svn path=/trunk/libcss/; revision=5764
Diffstat (limited to 'test/number.c')
-rw-r--r--test/number.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/number.c b/test/number.c
index 87dcbcd..7e793a2 100644
--- a/test/number.c
+++ b/test/number.c
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
/* and run final test */
if (ctx.bufused > 0)
- run_test(ctx.buf, ctx.bufused, ctx.exp, ctx.explen);
+ run_test(ctx.buf, ctx.bufused - 1, ctx.exp, ctx.explen);
free(ctx.buf);
@@ -69,7 +69,7 @@ bool handle_line(const char *data, size_t datalen, void *pw)
if (ctx->inexp) {
/* This marks end of testcase, so run it */
- run_test(ctx->buf, ctx->bufused,
+ run_test(ctx->buf, ctx->bufused - 1,
ctx->exp, ctx->explen);
ctx->buf[0] = '\0';
@@ -110,13 +110,17 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen)
css_string in = { (uint8_t *) data, len };
size_t consumed;
fixed result;
+ char buf[256];
UNUSED(exp);
UNUSED(explen);
result = number_from_css_string(&in, &consumed);
- /** \todo some kind of verification of the result */
- printf("%d\n", result);
+ snprintf(buf, sizeof buf, "%.3f", FIXTOFLT(result));
+
+ printf("got: %s expected: %.*s\n", buf, (int) explen, exp);
+
+ assert(strncmp(buf, exp, explen) == 0);
}