aboutsummaryrefslogtreecommitdiff
path: root/std/crypto/test.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-08 18:18:47 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-08 18:23:38 -0500
commitc2db077574be841da586fa62d67619c901dd535d (patch)
treec8eb64846fa7ffb9027fa1ca035dd8ca5712b9d4 /std/crypto/test.zig
parentbe6d022257d8d7e99bd080823d4d8f0175f320c5 (diff)
downloadzig-c2db077574be841da586fa62d67619c901dd535d.tar.gz
zig-c2db077574be841da586fa62d67619c901dd535d.zip
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds, if the assertion failed. Now, it's always `unreachable`. This makes release mode test builds more accurately test the actual code that will be run. However this requires tests to call `std.testing.expect` rather than `std.debug.assert` to make sure output is correct. Here is the explanation of when to use either one, copied from the assert doc comments: Inside a test block, it is best to use the `std.testing` module rather than assert, because assert may not detect a test failure in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert is the correct function to use. closes #1304
Diffstat (limited to 'std/crypto/test.zig')
-rw-r--r--std/crypto/test.zig9
1 files changed, 5 insertions, 4 deletions
diff --git a/std/crypto/test.zig b/std/crypto/test.zig
index 3fa24272e5..258cdf7320 100644
--- a/std/crypto/test.zig
+++ b/std/crypto/test.zig
@@ -1,6 +1,7 @@
-const debug = @import("../debug/index.zig");
-const mem = @import("../mem.zig");
-const fmt = @import("../fmt/index.zig");
+const std = @import("../index.zig");
+const testing = std.testing;
+const mem = std.mem;
+const fmt = std.fmt;
// Hash using the specified hasher `H` asserting `expected == H(input)`.
pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, input: []const u8) void {
@@ -17,5 +18,5 @@ pub fn assertEqual(comptime expected: []const u8, input: []const u8) void {
r.* = fmt.parseInt(u8, expected[2 * i .. 2 * i + 2], 16) catch unreachable;
}
- debug.assert(mem.eql(u8, expected_bytes, input));
+ testing.expectEqualSlices(u8, expected_bytes, input);
}