Browse Source

add two tests

master
Felix von Leitner 19 years ago
parent
commit
9568d23fe6
  1. 10
      test/stralloc_buffer.c
  2. 15
      test/stralloc_chomp.c

10
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);
}
}

15
test/stralloc_chomp.c

@ -0,0 +1,15 @@
#include <assert.h>
#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;
}
Loading…
Cancel
Save