add behavior test case for previous commit

This commit is contained in:
Andrew Kelley 2023-03-04 14:04:58 -07:00
parent 2cf27c5718
commit 16302578d5

View File

@ -747,3 +747,18 @@ test "slice decays to many pointer" {
const p: [*:0]const u8 = buf[0..7 :0];
try expectEqualStrings(buf[0..7], std.mem.span(p));
}
test "write through pointer to optional slice arg" {
const S = struct {
fn bar(foo: *?[]const u8) !void {
foo.* = try baz();
}
fn baz() ![]const u8 {
return "ok";
}
};
var foo: ?[]const u8 = null;
try S.bar(&foo);
try expectEqualStrings(foo.?, "ok");
}