diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-02-28 17:18:03 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-02-28 17:18:03 +0700 |
commit | ee9b8fc921f48dc893808e1c9dbfbef321aa362c (patch) | |
tree | 0d0a5247b139ba68d2c2aa2d94e1d631476dbc62 /lang/zig/sentinel-terminated.zig | |
parent | 2b91f9554b326aea138bd8a0acbfaa10d9ad59aa (diff) | |
download | cp-ee9b8fc921f48dc893808e1c9dbfbef321aa362c.tar.gz |
[lang/zig] Learn some Zig
Diffstat (limited to 'lang/zig/sentinel-terminated.zig')
-rw-r--r-- | lang/zig/sentinel-terminated.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lang/zig/sentinel-terminated.zig b/lang/zig/sentinel-terminated.zig new file mode 100644 index 0000000..dd9775c --- /dev/null +++ b/lang/zig/sentinel-terminated.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +const expect = std.testing.expect; + +test "null terminated array" { + const array = [_:0]u8 {1, 2, 3, 4}; + + expect(@TypeOf(array) == [4:0]u8); + expect(array.len == 4); + expect(array[4] == 0); +} |