1const std = @import("std");
2
3test "expect addOne adds one to 41" {
4
5 // The Standard Library contains useful functions to help create tests.
6 // `expect` is a function that verifies its argument is true.
7 // It will return an error if its argument is false to indicate a failure.
8 // `try` is used to return an error to the test runner to notify it that the test failed.
9 try std.testing.expect(addOne(41) == 42);
10
11 // However, in most cases it is more convenient to use a more specific function like `expectEqual`.
12 // This gives you much clearer and more helpful error messages when a test fails.
13 try std.testing.expectEqual(42, addOne(41));
14}
15
16test addOne {
17 // A test name can also be written using an identifier.
18 // This is a doctest, and serves as documentation for `addOne`.
19 try std.testing.expectEqual(42, addOne(41));
20}
21
22/// The function `addOne` adds one to the number given as its argument.
23fn addOne(number: i32) i32 {
24 return number + 1;
25}
26
27// test