mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
16 lines
403 B
Zig
16 lines
403 B
Zig
|
const expect = @import("std").testing.expect;
|
||
|
|
||
|
test "pointer slicing" {
|
||
|
var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||
|
var start: usize = 2; // var to make it runtime-known
|
||
|
_ = &start; // suppress 'var is never mutated' error
|
||
|
const slice = array[start..4];
|
||
|
try expect(slice.len == 2);
|
||
|
|
||
|
try expect(array[3] == 4);
|
||
|
slice[1] += 1;
|
||
|
try expect(array[3] == 5);
|
||
|
}
|
||
|
|
||
|
// test
|