aboutsummaryrefslogtreecommitdiff
path: root/std/mem.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-07 10:56:30 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-07 10:56:30 -0500
commita0590bda29cc4e0882eda907cfb84df4f46767a6 (patch)
treee0146b01b28783cfe52138c982bfd65fffd7bad1 /std/mem.zig
parent7fc99c33bde54e3f4bc946e7e00351bf594daa37 (diff)
parent38a77161949dbae036d4172ceba2f698de9f18a1 (diff)
downloadzig-a0590bda29cc4e0882eda907cfb84df4f46767a6.tar.gz
zig-a0590bda29cc4e0882eda907cfb84df4f46767a6.zip
Merge branch 'kristate-zig-backport-std.mem.join'
Diffstat (limited to 'std/mem.zig')
-rw-r--r--std/mem.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/std/mem.zig b/std/mem.zig
index 48d1cb930c..a6cbae744f 100644
--- 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" {