mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
23 lines
671 B
Zig
23 lines
671 B
Zig
const std = @import("std");
|
|
|
|
test "expectEqual demo" {
|
|
const expected: i32 = 42;
|
|
const actual = 42;
|
|
|
|
// The first argument to `expectEqual` is the known, expected, result.
|
|
// The second argument is the result of some expression.
|
|
// The actual's type is casted to the type of expected.
|
|
try std.testing.expectEqual(expected, actual);
|
|
}
|
|
|
|
test "expectError demo" {
|
|
const expected_error = error.DemoError;
|
|
const actual_error_union: anyerror!void = error.DemoError;
|
|
|
|
// `expectError` will fail when the actual error is different than
|
|
// the expected error.
|
|
try std.testing.expectError(expected_error, actual_error_union);
|
|
}
|
|
|
|
// test
|