Basic framework for day modules
This commit is contained in:
parent
03ce9032f7
commit
960737ff42
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
zig-cache
|
||||
zig-out
|
17
src/day01.zig
Normal file
17
src/day01.zig
Normal file
@ -0,0 +1,17 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn solve_part1() !u32 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pub fn solve_part2() !u32 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
test "solves part1" {
|
||||
try std.testing.expectEqual(solve_part1(), 0);
|
||||
}
|
||||
|
||||
test "solves part2" {
|
||||
try std.testing.expectEqual(solve_part2(), 0);
|
||||
}
|
21
src/main.zig
21
src/main.zig
@ -1,24 +1,19 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
// Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
const day01 = @import("day01.zig");
|
||||
|
||||
// stdout is for the actual output of your application, for example if you
|
||||
// are implementing gzip, then only the compressed bytes should be sent to
|
||||
// stdout, not any debugging messages.
|
||||
pub fn main() !void {
|
||||
const stdout_file = std.io.getStdOut().writer();
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
const stdout = bw.writer();
|
||||
|
||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
||||
try stdout.print("Day 1\nPart 1: {}\nPart 2: {}\n\n", .{ try day01.solve_part1(), try day01.solve_part2() });
|
||||
|
||||
try bw.flush(); // don't forget to flush!
|
||||
try bw.flush();
|
||||
}
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
test {
|
||||
std.testing.refAllDecls(@This());
|
||||
|
||||
_ = day01;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user