mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
15 lines
336 B
Zig
15 lines
336 B
Zig
|
const std = @import("std");
|
||
|
const expect = std.testing.expect;
|
||
|
|
||
|
test "0-terminated slicing" {
|
||
|
var array = [_]u8{ 3, 2, 1, 0, 3, 2, 1, 0 };
|
||
|
var runtime_length: usize = 3;
|
||
|
_ = &runtime_length;
|
||
|
const slice = array[0..runtime_length :0];
|
||
|
|
||
|
try expect(@TypeOf(slice) == [:0]u8);
|
||
|
try expect(slice.len == 3);
|
||
|
}
|
||
|
|
||
|
// test
|