zig

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

commit a0590bda29cc4e0882eda907cfb84df4f46767a6 (tree)
parent 7fc99c33bde54e3f4bc946e7e00351bf594daa37
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Thu,  7 Feb 2019 10:56:30 -0500

Merge branch 'kristate-zig-backport-std.mem.join'

Diffstat:
Mstd/mem.zig | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/std/mem.zig b/std/mem.zig @@ -911,8 +911,11 @@ pub fn join(allocator: *Allocator, separator: []const u8, slices: []const []cons } test "mem.join" { - assert(eql(u8, try join(debug.global_allocator, ",", [][]const u8{ "a", "b", "c" }), "a,b,c")); - assert(eql(u8, try join(debug.global_allocator, ",", [][]const u8{"a"}), "a")); + var buf: [1024]u8 = undefined; + const a = &std.heap.FixedBufferAllocator.init(&buf).allocator; + assert(eql(u8, try join(a, ",", [][]const u8{ "a", "b", "c" }), "a,b,c")); + assert(eql(u8, try join(a, ",", [][]const u8{"a"}), "a")); + assert(eql(u8, try join(a, ",", [][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c")); } test "testStringEquality" {