master
1const std = @import("std");
2const _NAME = @import(".NAME");
3
4pub fn main() !void {
5 // Prints to stderr, ignoring potential errors.
6 std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
7 try _NAME.bufferedPrint();
8}
9
10test "simple test" {
11 const gpa = std.testing.allocator;
12 var list: std.ArrayList(i32) = .empty;
13 defer list.deinit(gpa); // Try commenting this out and see if zig detects the memory leak!
14 try list.append(gpa, 42);
15 try std.testing.expectEqual(@as(i32, 42), list.pop());
16}
17
18test "fuzz example" {
19 const Context = struct {
20 fn testOne(context: @This(), input: []const u8) anyerror!void {
21 _ = context;
22 // Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
23 try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input));
24 }
25 };
26 try std.testing.fuzz(Context{}, Context.testOne, .{});
27}