From f1f3155ef6f28fb8595920e5423336b39bba4ed0 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 14 Feb 2009 22:55:32 +0000 Subject: Port libcss to libwapcaplet. It passes the tests, perhaps we need more of them. Lifetimes of lwc_string objects really need attention before we can consider this finished. svn path=/trunk/libcss/; revision=6517 --- test/number.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/number.c') diff --git a/test/number.c b/test/number.c index 0140ce9..7bb57c3 100644 --- a/test/number.c +++ b/test/number.c @@ -8,6 +8,13 @@ #include "testutils.h" +static void *myrealloc(void *ptr, size_t len, void *pw) +{ + UNUSED(pw); + + return realloc(ptr, len); +} + typedef struct line_ctx { size_t buflen; size_t bufused; @@ -110,21 +117,27 @@ bool handle_line(const char *data, size_t datalen, void *pw) void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen) { - css_string in = { len, (uint8_t *) data }; + lwc_string *in; + lwc_context *ctx; size_t consumed; css_fixed result; char buf[256]; UNUSED(exp); UNUSED(explen); - - result = number_from_css_string(&in, false, &consumed); + + assert(lwc_create_context(myrealloc, NULL, &ctx) == lwc_error_ok); + lwc_context_ref(ctx); + assert(lwc_context_intern(ctx, (const char *)data, len, &in) == lwc_error_ok); + + result = number_from_lwc_string(in, false, &consumed); print_css_fixed(buf, sizeof(buf), result); printf("got: %s expected: %.*s\n", buf, (int) explen, exp); assert(strncmp(buf, exp, explen) == 0); + lwc_context_unref(ctx); } void print_css_fixed(char *buf, size_t len, css_fixed f) -- cgit v1.2.3