string and StringBuilder
This commit is contained in:
@@ -5,8 +5,7 @@ Maybe dont_throw(){
|
||||
}
|
||||
|
||||
Maybe throw_error(){
|
||||
char* k=malloc(64);
|
||||
safethrow("test exception",free(k));
|
||||
safethrow("test exception", kprintf("\e[94on_safethrow_free called\n"));
|
||||
}
|
||||
|
||||
Maybe throw_errcode(){
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
void test_string(){
|
||||
optime(__func__,1,
|
||||
kprintf("\e[96m-------------[test_string]------------\n");
|
||||
LinearAllocator _al;
|
||||
LinearAllocator_construct(&_al, 64);
|
||||
allocator_ptr al=(allocator_ptr)&_al;
|
||||
char c[]="0123456789abcdef";
|
||||
string s={.ptr=c, .length=cptr_length(c)};
|
||||
if(s.length!=sizeof(c)-1) throw("string created with incorrect length");
|
||||
char* p=string_extract(s);
|
||||
kprintf("\e[94mstring_extract() -> \e[92m\"%s\"\n",p);
|
||||
free(p);
|
||||
char* p=string_extract(al, s);
|
||||
kprintf("\e[94mstring_extract -> \e[92m\"%s\"\n",p);
|
||||
LinearAllocator_destruct(&_al);
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user