mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 07:44:51 +01:00
21 lines
581 B
Zig
21 lines
581 B
Zig
const std = @import("std");
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
test "0-terminated sentinel array" {
|
|
const array = [_:0]u8{ 1, 2, 3, 4 };
|
|
|
|
try expectEqual([4:0]u8, @TypeOf(array));
|
|
try expectEqual(4, array.len);
|
|
try expectEqual(0, array[4]);
|
|
}
|
|
|
|
test "extra 0s in 0-terminated sentinel array" {
|
|
// The sentinel value may appear earlier, but does not influence the compile-time 'len'.
|
|
const array = [_:0]u8{ 1, 0, 0, 4 };
|
|
|
|
try expectEqual([4:0]u8, @TypeOf(array));
|
|
try expectEqual(4, array.len);
|
|
try expectEqual(0, array[4]);
|
|
}
|
|
|
|
// test
|