authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-05-16 03:24:32 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-05-16 03:24:32 -07:00
logc3e439f86b0484e4428f38c4d8b07b7b5ae1634b
treec0829ad00b13224bdc25702ffb92409f2d4fefcb
parent2d1861381432e1ca631ba1ce4f9460d29e265ccc

add back tests


2 files changed, 31 insertions(+), 0 deletions(-)

build.zig+12
......@@ -20,4 +20,16 @@ pub fn build(b: *std.Build) void {
2020
2121 const run_step = b.step("run", "Run the app");
2222 run_step.dependOn(&run_cmd.step);
23
24 const tests = b.addTest(.{
25 .root_source_file = b.path("src/test.zig"),
26 .target = target,
27 .optimize = mode,
28 });
29
30 const run_test = b.addRunArtifact(tests);
31 run_test.step.dependOn(&tests.step);
32
33 const test_step = b.step("test", "Run the test suite");
34 test_step.dependOn(&run_test.step);
2335}
src/test.zig created+19
......@@ -0,0 +1,19 @@
1const std = @import("std");
2const ansi = @import("./lib.zig");
3
4fn expectFmt(comptime actual: []const u8, expected: []const u8) !void {
5 return std.testing.expectEqualSlices(u8, expected, actual);
6}
7
8test {
9 try expectFmt(
10 ansi.color.Fg(.Blue, "All your codebase"),
11 &(.{ 27, '[', '3', '4', 'm' } ++ "All your codebase".* ++ .{ 27, '[', '3', '9', 'm' }),
12 );
13}
14test {
15 try expectFmt(
16 ansi.color.Bg(.Cyan, "All your codebase"),
17 &(.{ 27, '[', '4', '6', 'm' } ++ "All your codebase".* ++ .{ 27, '[', '4', '9', 'm' }),
18 );
19}