| ... | ... | @@ -163,7 +163,7 @@ fn failAllocatorAlloc(_: *anyopaque, n: usize, alignment: u29, len_align: u29, r |
| 163 | 163 | return error.OutOfMemory; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | | test "mem.Allocator basics" { |
| 166 | test "Allocator basics" { |
| 167 | 167 | try testing.expectError(error.OutOfMemory, fail_allocator.alloc(u8, 1)); |
| 168 | 168 | try testing.expectError(error.OutOfMemory, fail_allocator.allocSentinel(u8, 1, 0)); |
| 169 | 169 | } |
| ... | ... | @@ -330,7 +330,7 @@ pub fn zeroes(comptime T: type) T { |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | | test "mem.zeroes" { |
| 333 | test "zeroes" { |
| 334 | 334 | const C_struct = extern struct { |
| 335 | 335 | x: u32, |
| 336 | 336 | y: u32, |
| ... | ... | @@ -544,7 +544,7 @@ pub fn lessThan(comptime T: type, lhs: []const T, rhs: []const T) bool { |
| 544 | 544 | return order(T, lhs, rhs) == .lt; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | | test "mem.lessThan" { |
| 547 | test "lessThan" { |
| 548 | 548 | try testing.expect(lessThan(u8, "abcd", "bee")); |
| 549 | 549 | try testing.expect(!lessThan(u8, "abc", "abc")); |
| 550 | 550 | try testing.expect(lessThan(u8, "abc", "abc0")); |
| ... | ... | @@ -970,7 +970,7 @@ pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []co |
| 970 | 970 | return slice[begin..end]; |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | | test "mem.trim" { |
| 973 | test "trim" { |
| 974 | 974 | try testing.expectEqualSlices(u8, "foo\n ", trimLeft(u8, " foo\n ", " \n")); |
| 975 | 975 | try testing.expectEqualSlices(u8, " foo", trimRight(u8, " foo\n ", " \n")); |
| 976 | 976 | try testing.expectEqualSlices(u8, "foo", trim(u8, " foo\n ", " \n")); |
| ... | ... | @@ -1132,7 +1132,7 @@ pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, nee |
| 1132 | 1132 | return null; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | | test "mem.indexOf" { |
| 1135 | test "indexOf" { |
| 1136 | 1136 | try testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8); |
| 1137 | 1137 | try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8); |
| 1138 | 1138 | try testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null); |
| ... | ... | @@ -1157,7 +1157,7 @@ test "mem.indexOf" { |
| 1157 | 1157 | try testing.expect(lastIndexOfScalar(u8, "boo", 'o').? == 2); |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | | test "mem.indexOf multibyte" { |
| 1160 | test "indexOf multibyte" { |
| 1161 | 1161 | { |
| 1162 | 1162 | // make haystack and needle long enough to trigger boyer-moore-horspool algorithm |
| 1163 | 1163 | const haystack = [1]u16{0} ** 100 ++ [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff }; |
| ... | ... | @@ -1185,7 +1185,7 @@ test "mem.indexOf multibyte" { |
| 1185 | 1185 | } |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | | test "mem.indexOfPos empty needle" { |
| 1188 | test "indexOfPos empty needle" { |
| 1189 | 1189 | try testing.expectEqual(indexOfPos(u8, "abracadabra", 5, ""), 5); |
| 1190 | 1190 | } |
| 1191 | 1191 | |
| ... | ... | @@ -1205,7 +1205,7 @@ pub fn count(comptime T: type, haystack: []const T, needle: []const T) usize { |
| 1205 | 1205 | return found; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | | test "mem.count" { |
| 1208 | test "count" { |
| 1209 | 1209 | try testing.expect(count(u8, "", "h") == 0); |
| 1210 | 1210 | try testing.expect(count(u8, "h", "h") == 1); |
| 1211 | 1211 | try testing.expect(count(u8, "hh", "h") == 2); |
| ... | ... | @@ -1237,7 +1237,7 @@ pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: us |
| 1237 | 1237 | return false; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | | test "mem.containsAtLeast" { |
| 1240 | test "containsAtLeast" { |
| 1241 | 1241 | try testing.expect(containsAtLeast(u8, "aa", 0, "a")); |
| 1242 | 1242 | try testing.expect(containsAtLeast(u8, "aa", 1, "a")); |
| 1243 | 1243 | try testing.expect(containsAtLeast(u8, "aa", 2, "a")); |
| ... | ... | @@ -1583,7 +1583,7 @@ pub fn tokenize(comptime T: type, buffer: []const T, delimiter_bytes: []const T) |
| 1583 | 1583 | }; |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | | test "mem.tokenize" { |
| 1586 | test "tokenize" { |
| 1587 | 1587 | var it = tokenize(u8, " abc def ghi ", " "); |
| 1588 | 1588 | try testing.expect(eql(u8, it.next().?, "abc")); |
| 1589 | 1589 | try testing.expect(eql(u8, it.next().?, "def")); |
| ... | ... | @@ -1625,7 +1625,7 @@ test "mem.tokenize" { |
| 1625 | 1625 | try testing.expect(it16.next() == null); |
| 1626 | 1626 | } |
| 1627 | 1627 | |
| 1628 | | test "mem.tokenize (multibyte)" { |
| 1628 | test "tokenize (multibyte)" { |
| 1629 | 1629 | var it = tokenize(u8, "a|b,c/d e", " /,|"); |
| 1630 | 1630 | try testing.expect(eql(u8, it.next().?, "a")); |
| 1631 | 1631 | try testing.expect(eql(u8, it.next().?, "b")); |
| ... | ... | @@ -1647,7 +1647,7 @@ test "mem.tokenize (multibyte)" { |
| 1647 | 1647 | try testing.expect(it16.next() == null); |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | | test "mem.tokenize (reset)" { |
| 1650 | test "tokenize (reset)" { |
| 1651 | 1651 | var it = tokenize(u8, " abc def ghi ", " "); |
| 1652 | 1652 | try testing.expect(eql(u8, it.next().?, "abc")); |
| 1653 | 1653 | try testing.expect(eql(u8, it.next().?, "def")); |
| ... | ... | @@ -1678,7 +1678,7 @@ pub fn split(comptime T: type, buffer: []const T, delimiter: []const T) SplitIte |
| 1678 | 1678 | }; |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | | test "mem.split" { |
| 1681 | test "split" { |
| 1682 | 1682 | var it = split(u8, "abc|def||ghi", "|"); |
| 1683 | 1683 | try testing.expect(eql(u8, it.next().?, "abc")); |
| 1684 | 1684 | try testing.expect(eql(u8, it.next().?, "def")); |
| ... | ... | @@ -1708,7 +1708,7 @@ test "mem.split" { |
| 1708 | 1708 | try testing.expect(it16.next() == null); |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | | test "mem.split (multibyte)" { |
| 1711 | test "split (multibyte)" { |
| 1712 | 1712 | var it = split(u8, "a, b ,, c, d, e", ", "); |
| 1713 | 1713 | try testing.expect(eql(u8, it.next().?, "a")); |
| 1714 | 1714 | try testing.expect(eql(u8, it.next().?, "b ,")); |
| ... | ... | @@ -1734,7 +1734,7 @@ pub fn startsWith(comptime T: type, haystack: []const T, needle: []const T) bool |
| 1734 | 1734 | return if (needle.len > haystack.len) false else eql(T, haystack[0..needle.len], needle); |
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | | test "mem.startsWith" { |
| 1737 | test "startsWith" { |
| 1738 | 1738 | try testing.expect(startsWith(u8, "Bob", "Bo")); |
| 1739 | 1739 | try testing.expect(!startsWith(u8, "Needle in haystack", "haystack")); |
| 1740 | 1740 | } |
| ... | ... | @@ -1743,7 +1743,7 @@ pub fn endsWith(comptime T: type, haystack: []const T, needle: []const T) bool { |
| 1743 | 1743 | return if (needle.len > haystack.len) false else eql(T, haystack[haystack.len - needle.len ..], needle); |
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | | test "mem.endsWith" { |
| 1746 | test "endsWith" { |
| 1747 | 1747 | try testing.expect(endsWith(u8, "Needle in haystack", "haystack")); |
| 1748 | 1748 | try testing.expect(!endsWith(u8, "Bob", "Bo")); |
| 1749 | 1749 | } |
| ... | ... | @@ -1867,7 +1867,7 @@ fn joinMaybeZ(allocator: Allocator, separator: []const u8, slices: []const []con |
| 1867 | 1867 | return buf; |
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | | test "mem.join" { |
| 1870 | test "join" { |
| 1871 | 1871 | { |
| 1872 | 1872 | const str = try join(testing.allocator, ",", &[_][]const u8{}); |
| 1873 | 1873 | defer testing.allocator.free(str); |
| ... | ... | @@ -1890,7 +1890,7 @@ test "mem.join" { |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | | test "mem.joinZ" { |
| 1893 | test "joinZ" { |
| 1894 | 1894 | { |
| 1895 | 1895 | const str = try joinZ(testing.allocator, ",", &[_][]const u8{}); |
| 1896 | 1896 | defer testing.allocator.free(str); |
| ... | ... | @@ -2168,7 +2168,7 @@ pub fn min(comptime T: type, slice: []const T) T { |
| 2168 | 2168 | return best; |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | | test "mem.min" { |
| 2171 | test "min" { |
| 2172 | 2172 | try testing.expectEqual(min(u8, "abcdefg"), 'a'); |
| 2173 | 2173 | try testing.expectEqual(min(u8, "bcdefga"), 'a'); |
| 2174 | 2174 | try testing.expectEqual(min(u8, "a"), 'a'); |
| ... | ... | @@ -2185,7 +2185,7 @@ pub fn max(comptime T: type, slice: []const T) T { |
| 2185 | 2185 | return best; |
| 2186 | 2186 | } |
| 2187 | 2187 | |
| 2188 | | test "mem.max" { |
| 2188 | test "max" { |
| 2189 | 2189 | try testing.expectEqual(max(u8, "abcdefg"), 'g'); |
| 2190 | 2190 | try testing.expectEqual(max(u8, "gabcdef"), 'g'); |
| 2191 | 2191 | try testing.expectEqual(max(u8, "g"), 'g'); |
| ... | ... | @@ -2205,7 +2205,7 @@ pub fn minMax(comptime T: type, slice: []const T) struct { min: T, max: T } { |
| 2205 | 2205 | return .{ .min = minVal, .max = maxVal }; |
| 2206 | 2206 | } |
| 2207 | 2207 | |
| 2208 | | test "mem.minMax" { |
| 2208 | test "minMax" { |
| 2209 | 2209 | try testing.expectEqual(minMax(u8, "abcdefg"), .{ .min = 'a', .max = 'g' }); |
| 2210 | 2210 | try testing.expectEqual(minMax(u8, "bcdefga"), .{ .min = 'a', .max = 'g' }); |
| 2211 | 2211 | try testing.expectEqual(minMax(u8, "a"), .{ .min = 'a', .max = 'a' }); |
| ... | ... | @@ -2226,7 +2226,7 @@ pub fn indexOfMin(comptime T: type, slice: []const T) usize { |
| 2226 | 2226 | return index; |
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | | test "mem.indexOfMin" { |
| 2229 | test "indexOfMin" { |
| 2230 | 2230 | try testing.expectEqual(indexOfMin(u8, "abcdefg"), 0); |
| 2231 | 2231 | try testing.expectEqual(indexOfMin(u8, "bcdefga"), 6); |
| 2232 | 2232 | try testing.expectEqual(indexOfMin(u8, "a"), 0); |
| ... | ... | @@ -2247,7 +2247,7 @@ pub fn indexOfMax(comptime T: type, slice: []const T) usize { |
| 2247 | 2247 | return index; |
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | | test "mem.indexOfMax" { |
| 2250 | test "indexOfMax" { |
| 2251 | 2251 | try testing.expectEqual(indexOfMax(u8, "abcdefg"), 6); |
| 2252 | 2252 | try testing.expectEqual(indexOfMax(u8, "gabcdef"), 0); |
| 2253 | 2253 | try testing.expectEqual(indexOfMax(u8, "a"), 0); |
| ... | ... | @@ -2275,7 +2275,7 @@ pub fn indexOfMinMax(comptime T: type, slice: []const T) struct { index_min: usi |
| 2275 | 2275 | return .{ .index_min = minIdx, .index_max = maxIdx }; |
| 2276 | 2276 | } |
| 2277 | 2277 | |
| 2278 | | test "mem.indexOfMinMax" { |
| 2278 | test "indexOfMinMax" { |
| 2279 | 2279 | try testing.expectEqual(indexOfMinMax(u8, "abcdefg"), .{ .index_min = 0, .index_max = 6 }); |
| 2280 | 2280 | try testing.expectEqual(indexOfMinMax(u8, "gabcdef"), .{ .index_min = 1, .index_max = 0 }); |
| 2281 | 2281 | try testing.expectEqual(indexOfMinMax(u8, "a"), .{ .index_min = 0, .index_max = 0 }); |