Added "clear" to VarString

This commit is contained in:
Christoffer Lerno
2023-02-10 08:38:00 +01:00
parent 0a0cc4b5df
commit b3f15a867c
2 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
module string_test;
fn void! test_clear() @test
{
DynString s = string::new_with_capacity(32);
assert(s.len() == 0);
assert(s.capacity() == 32);
s.append_repeat('x', 63);
assert(s.capacity() == 64);
assert(s.len() == 63);
char* addr = &s[0];
s.clear();
assert(s.capacity() == 64);
assert(s.len() == 0);
s.append_repeat('x', 63);
assert(s.capacity() == 64);
assert(s.len() == 63);
assert(addr == &s[0]);
}