mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add char_at method in DString
This commit is contained in:
committed by
Christoffer Lerno
parent
44c2486a74
commit
a0f4976b07
@@ -246,4 +246,29 @@ fn void test_insert_at_overlaps()
|
||||
str.chop(3);
|
||||
s = str.str_view();
|
||||
assert(s == "def", "got '%s'; want 'def'", s);
|
||||
}
|
||||
}
|
||||
|
||||
fn void test_char_at()
|
||||
{
|
||||
DString str = dstring::new("hello");
|
||||
defer str.free();
|
||||
|
||||
char c = str.char_at(1);
|
||||
assert(c == 'e');
|
||||
|
||||
char c_with_operator = str[4];
|
||||
assert(c_with_operator == 'o');
|
||||
}
|
||||
|
||||
fn void test_operators()
|
||||
{
|
||||
DString str = dstring::new("hello");
|
||||
defer str.free();
|
||||
|
||||
str[0] = 'p';
|
||||
assert(str.str_view() == "pello");
|
||||
|
||||
char* c = &str[1];
|
||||
assert(*c == 'e');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user