X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fccan_tokenizer%2Ftest%2Frun.c;h=92fe43c68a67d818bd64133bf681f9af11f66407;hp=9a4ae19ba9ce587ced48631c14011dbef6628f1b;hb=f725bbb1987284933e0f21dfb8f2ce7a1f0806e5;hpb=3c81225fc0a4fb99d10282ebf11b7ec6ae1eabdd diff --git a/ccan/ccan_tokenizer/test/run.c b/ccan/ccan_tokenizer/test/run.c index 9a4ae19b..92fe43c6 100644 --- a/ccan/ccan_tokenizer/test/run.c +++ b/ccan/ccan_tokenizer/test/run.c @@ -25,23 +25,23 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "ccan_tokenizer/read_cnumber.c" -#include "ccan_tokenizer/read_cstring.c" -#include "ccan_tokenizer/dict.c" -#include "ccan_tokenizer/ccan_tokenizer.c" -#include "ccan_tokenizer/queue.c" -#include "ccan_tokenizer/charflag.c" +#include +#include +#include +#include +#include +#include -#include "ccan_tokenizer/ccan_tokenizer.h" +#include -#include "tap/tap.h" +#include #include #define array_count_pair(type, ...) (const type []){__VA_ARGS__}, sizeof((const type []){__VA_ARGS__})/sizeof(type) static void test_read_cstring(void) { - #define next() do {array_free(str); array_init(str, NULL); csp++;} while(0) + #define next() do {darray_free(str); darray_init(str); csp++;} while(0) #define cs (*csp) #define verify_quotechar(correct, correct_continuation_offset, quotechar) do { \ const size_t s = sizeof(correct)-1; \ @@ -69,7 +69,7 @@ static void test_read_cstring(void) { }; const char * const *csp = cstrings; const char *p; - array_char str = array_new(NULL); + darray_char str = darray_new(); tok_message_queue mq; queue_init(mq, NULL); @@ -107,7 +107,7 @@ static void test_read_cstring(void) { //Check a series of hex escapes verify("\x50\x35\x12\xEF\xFE\x12\x45", 32); - array_free(str); + darray_free(str); //tok_message_queue_dump(&mq); @@ -147,7 +147,7 @@ static void test_read_cstring(void) { queue_skip(mq); } if (iorig != txt || tl->orig_size != txt_size) failed("tokenize() did not replicate orig/orig_size from arguments"); @@ -1271,10 +1271,10 @@ static void test_tokenizer_single(struct tokenizer_test *t, tok_message_queue *m case TOK_CHAR: case TOK_STRING: //anything using string - if (tok_gen->string.size != tok_correct->string.size || - memcmp(tok_gen->string.item, tok_correct->string.item, - tok_gen->string.size) || - tok_gen->string.item[tok_gen->string.size] != 0 ) + if (tok_gen->string->size != tok_correct->string->size || + memcmp(tok_gen->string->item, tok_correct->string->item, + tok_gen->string->size) || + tok_gen->string->item[tok_gen->string->size] != 0 ) failed("Token \"%s\": String value incorrect", tok_correct->txt); break; case TOK_STRING_IQUOTE: @@ -1309,7 +1309,7 @@ done: static void test_tokenizer_file(const char *file_name, tok_message_queue *mq) { FILE *f = fopen(file_name, "rb"); - array_char text = array_new(NULL); + darray_char *text = talloc_darray(NULL); const size_t inc = 1024; struct token_list *tl; @@ -1321,10 +1321,10 @@ static void test_tokenizer_file(const char *file_name, tok_message_queue *mq) { for (;;) { size_t read_len; - array_realloc(text, text.size+inc+1); - read_len = fread(text.item+text.size, 1, inc, f); - text.size += read_len; - text.item[text.size] = 0; + darray_realloc(*text, text->size+inc+1); + read_len = fread(text->item+text->size, 1, inc, f); + text->size += read_len; + text->item[text->size] = 0; if (read_len < inc) break; @@ -1335,7 +1335,7 @@ static void test_tokenizer_file(const char *file_name, tok_message_queue *mq) { goto end; } - tl = tokenize(text.item, text.size, mq); + tl = tokenize(text, text->item, text->size, mq); tl->filename = file_name; //printf("File '%s' has %zu tokens\n", file_name, token_list_count(tl)); @@ -1354,7 +1354,7 @@ static void test_tokenizer_file(const char *file_name, tok_message_queue *mq) { }*/ end: - array_free(text); + talloc_free(text); if (f) fclose(f); } @@ -1411,7 +1411,7 @@ static void test_tokenizer(void) { msg_fail:; } - test_tokenizer_file("ccan/ccan_tokenizer/test/run.c", &mq); + test_tokenizer_file("test/run.c", &mq); while (queue_count(mq)) { struct tok_message msg = dequeue(mq);