When zig test is running under some continuous integration process it does display the test and OK:
> zig test xor.zig 2>&1 | /bin/cat -
1/1 test.xor... OK
All 1 tests passed.
But to get KO
instead of FAIL
you need your own test_runner.
It compares boolean values, that’s why it says the failed test name and expected true, found false
. If some of the expectString does not suit your needs you can copy it from the std lib and change it, no big deal.
An example of custom expect is:
fn expectEqual(expected: Decimal, actual: Decimal) !void {
if (actual.isNaN() and !expected.isNaN()) {
std.debug.print(
\\
\\------------------------
\\ expected {}
\\ found NaN ({!})
\\------------------------
\\
, .{ expected, actual.unwrap() });
return error.TestExpectedEqual;
}
if (actual.identical(expected))
return;
std.debug.print(
\\
\\------------------------
\\ expected {}
\\ found {}
\\------------------------
\\
, .{ expected, actual });
return error.TestExpectedEqual;
}