| ... | ... | @@ -92,7 +92,7 @@ pub fn join(allocator: *Allocator, paths: []const []const u8) ![]u8 { |
| 92 | 92 | /// Naively combines a series of paths with the native path seperator and null terminator. |
| 93 | 93 | /// Allocates memory for the result, which must be freed by the caller. |
| 94 | 94 | pub fn joinZ(allocator: *Allocator, paths: []const []const u8) ![:0]u8 { |
| 95 | | const out = joinSepMaybeZ(allocator, sep, isSep, paths, true); |
| 95 | const out = try joinSepMaybeZ(allocator, sep, isSep, paths, true); |
| 96 | 96 | return out[0 .. out.len - 1 :0]; |
| 97 | 97 | } |
| 98 | 98 | |
| ... | ... | @@ -119,6 +119,16 @@ fn testJoinMaybeZPosix(paths: []const []const u8, expected: []const u8, zero: bo |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | test "join" { |
| 122 | { |
| 123 | const actual: []u8 = try join(testing.allocator, &[_][]const u8{}); |
| 124 | defer testing.allocator.free(actual); |
| 125 | testing.expectEqualSlices(u8, "", actual); |
| 126 | } |
| 127 | { |
| 128 | const actual: [:0]u8 = try joinZ(testing.allocator, &[_][]const u8{}); |
| 129 | defer testing.allocator.free(actual); |
| 130 | testing.expectEqualSlices(u8, "", actual); |
| 131 | } |
| 122 | 132 | for (&[_]bool{ false, true }) |zero| { |
| 123 | 133 | testJoinMaybeZWindows(&[_][]const u8{}, "", zero); |
| 124 | 134 | testJoinMaybeZWindows(&[_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c", zero); |