zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

test_null_terminated_slicing.zig (336B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 test "0-terminated slicing" {
      5     var array = [_]u8{ 3, 2, 1, 0, 3, 2, 1, 0 };
      6     var runtime_length: usize = 3;
      7     _ = &runtime_length;
      8     const slice = array[0..runtime_length :0];
      9 
     10     try expect(@TypeOf(slice) == [:0]u8);
     11     try expect(slice.len == 3);
     12 }
     13 
     14 // test