diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-11-27 01:07:35 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-11-29 23:30:38 -0700 |
| commit | ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86 (patch) | |
| tree | 3c174281ab0b9d51b6c78234b0648e197412eea8 /test | |
| parent | deda6b514691c3a7ffc7931469886d0e7be2f67e (diff) | |
| download | zig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.tar.gz zig-ceb0a632cfd6a4eada6bd27bf6a3754e95dcac86.zip | |
std.mem.Allocator: allow shrink to fail
closes #13535
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/compile_errors/dereference_anyopaque.zig | 12 | ||||
| -rw-r--r-- | test/compare_output.zig | 11 | ||||
| -rw-r--r-- | test/tests.zig | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/test/cases/compile_errors/dereference_anyopaque.zig b/test/cases/compile_errors/dereference_anyopaque.zig index 854d2f2dfb..df58a11085 100644 --- a/test/cases/compile_errors/dereference_anyopaque.zig +++ b/test/cases/compile_errors/dereference_anyopaque.zig @@ -47,9 +47,9 @@ pub export fn entry() void { // :11:22: error: comparison of 'void' with null // :25:51: error: values of type 'anyopaque' must be comptime-known, but operand value is runtime-known // :25:51: note: opaque type 'anyopaque' has undefined size -// :25:51: error: values of type 'fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' must be comptime-known, but operand value is runtime-known -// :25:51: note: use '*const fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' for a function pointer type -// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' must be comptime-known, but operand value is runtime-known -// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' for a function pointer type -// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize) void' must be comptime-known, but operand value is runtime-known -// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize) void' for a function pointer type +// :25:51: error: values of type 'fn(*anyopaque, usize, u8, usize) ?[*]u8' must be comptime-known, but operand value is runtime-known +// :25:51: note: use '*const fn(*anyopaque, usize, u8, usize) ?[*]u8' for a function pointer type +// :25:51: error: values of type 'fn(*anyopaque, []u8, u8, usize, usize) bool' must be comptime-known, but operand value is runtime-known +// :25:51: note: use '*const fn(*anyopaque, []u8, u8, usize, usize) bool' for a function pointer type +// :25:51: error: values of type 'fn(*anyopaque, []u8, u8, usize) void' must be comptime-known, but operand value is runtime-known +// :25:51: note: use '*const fn(*anyopaque, []u8, u8, usize) void' for a function pointer type diff --git a/test/compare_output.zig b/test/compare_output.zig index 1ebed82221..c2bfdf8062 100644 --- a/test/compare_output.zig +++ b/test/compare_output.zig @@ -504,9 +504,10 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ const allocator = logging_allocator.allocator(); \\ \\ var a = try allocator.alloc(u8, 10); - \\ a = allocator.shrink(a, 5); + \\ try std.testing.expect(allocator.resize(a, 5)); + \\ a = a[0..5]; \\ try std.testing.expect(a.len == 5); - \\ try std.testing.expect(allocator.resize(a, 20) == null); + \\ try std.testing.expect(!allocator.resize(a, 20)); \\ allocator.free(a); \\} \\ @@ -522,9 +523,9 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ nosuspend stdout.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; \\} , - \\debug: alloc - success - len: 10, ptr_align: 1, len_align: 0 - \\debug: shrink - success - 10 to 5, len_align: 0, buf_align: 1 - \\error: expand - failure - 5 to 20, len_align: 0, buf_align: 1 + \\debug: alloc - success - len: 10, ptr_align: 0 + \\debug: shrink - success - 10 to 5, buf_align: 0 + \\error: expand - failure - 5 to 20, buf_align: 0 \\debug: free - len: 5 \\ ); diff --git a/test/tests.zig b/test/tests.zig index 61758f3aa3..0057e562f2 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -992,7 +992,7 @@ pub const StackTracesContext = struct { } try buf.appendSlice("\n"); } - break :got_result buf.toOwnedSlice(); + break :got_result try buf.toOwnedSlice(); }; if (!mem.eql(u8, self.expect_output, got)) { |
