mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
add test for allowing slice[slice.len..slice.len]
This commit is contained in:
parent
d295279b16
commit
84619abe9f
@ -1,4 +1,5 @@
|
||||
const assert = @import("std").debug.assert;
|
||||
const mem = @import("std").mem;
|
||||
|
||||
const x = @intToPtr(&i32, 0x1000)[0..0x500];
|
||||
const y = x[0x100..];
|
||||
@ -15,3 +16,12 @@ test "slice child property" {
|
||||
var slice = array[0..];
|
||||
assert(@typeOf(slice).Child == i32);
|
||||
}
|
||||
|
||||
test "debug safety lets us slice from len..len" {
|
||||
var an_array = []u8{1, 2, 3};
|
||||
assert(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), ""));
|
||||
}
|
||||
|
||||
fn sliceFromLenToLen(a_slice: []u8, start: usize, end: usize) -> []u8 {
|
||||
return a_slice[start..end];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user