mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +00:00
24 lines
758 B
Zig
24 lines
758 B
Zig
const std = @import("std");
|
|
|
|
test "expect addOne adds one to 41" {
|
|
|
|
// The Standard Library contains useful functions to help create tests.
|
|
// `expect` is a function that verifies its argument is true.
|
|
// It will return an error if its argument is false to indicate a failure.
|
|
// `try` is used to return an error to the test runner to notify it that the test failed.
|
|
try std.testing.expect(addOne(41) == 42);
|
|
}
|
|
|
|
test addOne {
|
|
// A test name can also be written using an identifier.
|
|
// This is a doctest, and serves as documentation for `addOne`.
|
|
try std.testing.expect(addOne(41) == 42);
|
|
}
|
|
|
|
/// The function `addOne` adds one to the number given as its argument.
|
|
fn addOne(number: i32) i32 {
|
|
return number + 1;
|
|
}
|
|
|
|
// test
|