From 5589008c7791771f04e83d370884242effca476f Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 17 Oct 2002 20:32:25 +0000 Subject: [PATCH] add two tests --- test/stralloc_buffer.c | 10 ++++++++++ test/stralloc_chomp.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/stralloc_buffer.c create mode 100644 test/stralloc_chomp.c diff --git a/test/stralloc_buffer.c b/test/stralloc_buffer.c new file mode 100644 index 0000000..61d50d9 --- /dev/null +++ b/test/stralloc_buffer.c @@ -0,0 +1,10 @@ +#include "stralloc.h" +#include "buffer.h" + +main() { + static stralloc sa; + if (buffer_get_token_sa(buffer_0,&sa," \t\n",3)==0) { + buffer_putsa(buffer_1,&sa); + buffer_putnlflush(buffer_1); + } +} diff --git a/test/stralloc_chomp.c b/test/stralloc_chomp.c new file mode 100644 index 0000000..34ba476 --- /dev/null +++ b/test/stralloc_chomp.c @@ -0,0 +1,15 @@ +#include +#include "stralloc.h" +#include "buffer.h" + +main() { + static stralloc sa; + stralloc_copys(&sa,"foo\r\n"); + assert(sa.len==5); + assert(stralloc_chomp(&sa)==2); + assert(stralloc_chop(&sa)=='o'); + assert(stralloc_chop(&sa)=='o'); + assert(stralloc_chop(&sa)=='f'); + assert(stralloc_chop(&sa)==-1); + return 0; +}