mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
19 lines
547 B
Zig
19 lines
547 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
test "sentinel mismatch" {
|
|
var array = [_]u8{ 3, 2, 1, 0 };
|
|
|
|
// Creating a sentinel-terminated slice from the array with a length of 2
|
|
// will result in the value `1` occupying the sentinel element position.
|
|
// This does not match the indicated sentinel value of `0` and will lead
|
|
// to a runtime panic.
|
|
var runtime_length: usize = 2;
|
|
_ = &runtime_length;
|
|
const slice = array[0..runtime_length :0];
|
|
|
|
_ = slice;
|
|
}
|
|
|
|
// test_safety=sentinel mismatch
|