master
1const std = @import("std");
2
3test "expectEqual demo" {
4 const expected: i32 = 42;
5 const actual = 42;
6
7 // The first argument to `expectEqual` is the known, expected, result.
8 // The second argument is the result of some expression.
9 // The actual's type is casted to the type of expected.
10 try std.testing.expectEqual(expected, actual);
11}
12
13test "expectError demo" {
14 const expected_error = error.DemoError;
15 const actual_error_union: anyerror!void = error.DemoError;
16
17 // `expectError` will fail when the actual error is different than
18 // the expected error.
19 try std.testing.expectError(expected_error, actual_error_union);
20}
21
22// test