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

This commit is contained in:
Andrew Kelley 2019-02-07 10:56:30 -05:00
commit a0590bda29
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -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" {