2024-04-25 01:41:47 +01:00
|
|
|
const std = @import("std");
|
|
|
|
const expect = std.testing.expect;
|
|
|
|
|
|
|
|
test "0-terminated sentinel array" {
|
2024-05-04 19:29:17 +01:00
|
|
|
const array = [_:0]u8{ 1, 2, 3, 4 };
|
2024-04-25 01:41:47 +01:00
|
|
|
|
|
|
|
try expect(@TypeOf(array) == [4:0]u8);
|
|
|
|
try expect(array.len == 4);
|
|
|
|
try expect(array[4] == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
test "extra 0s in 0-terminated sentinel array" {
|
|
|
|
// The sentinel value may appear earlier, but does not influence the compile-time 'len'.
|
2024-05-04 19:29:17 +01:00
|
|
|
const array = [_:0]u8{ 1, 0, 0, 4 };
|
2024-04-25 01:41:47 +01:00
|
|
|
|
|
|
|
try expect(@TypeOf(array) == [4:0]u8);
|
|
|
|
try expect(array.len == 4);
|
|
|
|
try expect(array[4] == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// test
|