]> gitweb.ps.run Git - iftint.zig/blob - src/main.zig
initial
[iftint.zig] / src / main.zig
1 const std = @import("std");
2 const default = @import("default");
3
4 pub 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 default.bufferedPrint();
8 }
9
10 test "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
18 test "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 }