commit 1bc55022dccbbf88df4b6e908b4710ad6d807255 parent 2eeb98fe358d0536a4f45577eadd61733f07c005 Author: Drew DeVault <sir@cmpwn.com> Date: Sun, 10 Jan 2021 14:26:11 -0500 Expand string test Diffstat:
M | tests/04-strings.ha | | | 21 | ++++++++++++++++++++- |
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/tests/04-strings.ha b/tests/04-strings.ha @@ -16,10 +16,29 @@ fn charptr() void = { assert(z[3] == 'l': u32: u8); assert(z[4] == 'o': u32: u8); assert(z[5] == '!': u32: u8); + assert(z[6] == 0u8); +}; + +fn storage() void = { + const string = "Hello!"; + const ptr = &string: *struct { + data: *[*]u8, + length: size, + capacity: size, + }; + assert(ptr.length == 6z); + assert(ptr.capacity == 6z); + assert(ptr.data[0] == 'H': u32: u8); + assert(ptr.data[1] == 'e': u32: u8); + assert(ptr.data[2] == 'l': u32: u8); + assert(ptr.data[3] == 'l': u32: u8); + assert(ptr.data[4] == 'o': u32: u8); + assert(ptr.data[5] == '!': u32: u8); + assert(ptr.data[6] == 0u8); }; export fn main() void = { - // TODO: Expand this test (blocked on structs, more or less) measurements(); charptr(); + storage(); };