authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-09 15:44:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-09 15:44:08-07:00
logfd85cfe15457bd695b978e327ce8af84c7990c28
treeba1eaa93392066f88b4362cd840373c85daad887
parent83bb3d1ad692127cd51c101b6a01fc853ab72990

std.mem: remove redundant namespaces in test names

related: #7923

1 files changed, 24 insertions(+), 24 deletions(-)

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