Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
archived/test/t_strbuf.c
2010-10-22 13:59:06 +02:00

52 lines
780 B
C

#include <assert.h>
#include <stdio.h>
#include <malloc.h>
#include "../src/common/strbuf.h"
void print_strbuf(strbuf_t *s) {
assert(s->len = strlen(s->buf));
printf("block: %i, len: %i |%s|\n", s->alloc_size, s->len, s->buf);
}
int main() {
strbuf_t b = STRBUF_INIT;
char *str;
strbuf_append(&b, " ", 4);
strbuf_append(&b, "abcdef", 6);
print_strbuf(&b);
strbuf_append(&b, "012345678901234567890123456789", 30);
strbuf_append(&b, " ", 6);
print_strbuf(&b);
strbuf_rtrim(&b);
print_strbuf(&b);
strbuf_ltrim(&b);
print_strbuf(&b);
strbuf_trim(&b);
print_strbuf(&b);
strbuf_rev(&b);
print_strbuf(&b);
str = strbuf_release(&b);
printf("released |%s|\n", str);
free(str);
return 0;
}