aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_null_terminated_slicing.zig
blob: e5a248bed388750efd18a3e80c8a078d1e22a0dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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