test: move all module tests to the test/ directory
This commit is contained in:
43
test/ds/strings.c
Normal file
43
test/ds/strings.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("-------------\n");
|
||||
b_string *str = b_string_create_from_cstr("Hello, world!\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
|
||||
b_string_insert_cstr(str, "WOW!", 4);
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
|
||||
b_string_replace(str, 4, 4, "+");
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", b_string_ptr(str));
|
||||
printf("len:%zu, max:%zu\n", b_string_get_size(str, B_STRLEN_NORMAL),
|
||||
b_string_get_capacity(str));
|
||||
printf("-------------\n");
|
||||
|
||||
b_string_unref(str);
|
||||
|
||||
b_stringstream *strv = b_stringstream_create();
|
||||
b_stream_write_string(strv, "Hello", NULL);
|
||||
b_stream_write_string(strv, ", world", NULL);
|
||||
b_stream_write_string(strv, "!", NULL);
|
||||
|
||||
char *s = b_stringstream_steal(strv);
|
||||
b_stringstream_unref(strv);
|
||||
|
||||
printf("%s\n", s);
|
||||
free(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user