diff --git a/.vscode/launch.json b/.vscode/launch.json index b32996f..a37980f 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,16 +8,17 @@ "target": "${workspaceFolder}/zig-out/bin/ona", "cwd": "${workspaceRoot}", "valuesFormatting": "parseText", - "preLaunchTask": "build", + "preLaunchTask": "Build", }, { "name": "Test", "type": "gdb", "request": "launch", "target": "${workspaceFolder}/zig-cache/o/b57ef32c79a05339fbe4a8eb648ff6df/test", + "arguments": "main.zig", "cwd": "${workspaceRoot}", "valuesFormatting": "parseText", - "preLaunchTask": "test" + "preLaunchTask": "Build Test", }, ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index ab2351a..4beb35f 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,5 @@ }, "git.detectSubmodulesLimit": 0, - "git.ignoreSubmodules": true + "git.ignoreSubmodules": true, } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index eb31fd2..2a24dae 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -44,11 +44,17 @@ { "label": "Test", "type": "shell", - "command": "zig build test", + "command": "zig test src/main.zig", "group": { "kind": "test", "isDefault": true }, }, + { + "label": "Build Test", + "type": "shell", + "command": "zig build test", + "group": "test" + }, ], } diff --git a/build.zig b/build.zig index b30c0e8..7eef4a8 100644 --- a/build.zig +++ b/build.zig @@ -6,7 +6,7 @@ pub fn build(builder: *std.build.Builder) void { // Ona executable. { - const ona_exe = builder.addExecutable("ona", "src/main.zig"); + const ona_exe = builder.addExecutable("ona", "./src/main.zig"); ona_exe.setTarget(target); ona_exe.setBuildMode(mode); @@ -25,7 +25,7 @@ pub fn build(builder: *std.build.Builder) void { // Ona tests. { - const ona_tests = builder.addTest("src/main.zig"); + const ona_tests = builder.addTestExe("test", "./src/main.zig"); ona_tests.setTarget(target); ona_tests.setBuildMode(mode); diff --git a/src/stack.zig b/src/stack.zig index afc2a99..4f3b6b3 100755 --- a/src/stack.zig +++ b/src/stack.zig @@ -92,28 +92,26 @@ pub const FixedPushError = error { }; test "fixed stack" { - const testing = @import("std").testing; - const expectError = testing.expectError; - const expectEqual = testing.expectEqual; + const testing = std.testing; var buffer = std.mem.zeroes([4]u8); var stack = Fixed(u8){.buffer = &buffer}; - try expectEqual(stack.count(), 0); - try expectEqual(stack.pop(), null); + try testing.expectEqual(stack.count(), 0); + try testing.expectEqual(stack.pop(), null); try stack.push(69); - try expectEqual(stack.count(), 1); - try expectEqual(stack.pop(), 69); + try testing.expectEqual(stack.count(), 1); + try testing.expectEqual(stack.pop(), 69); try stack.pushAll(&.{42, 10, 95, 0}); - try expectEqual(stack.count(), 4); - try expectError(FixedPushError.Overflow, stack.push(1)); - try expectError(FixedPushError.Overflow, stack.pushAll(&.{1, 11, 11})); + try testing.expectEqual(stack.count(), 4); + try testing.expectError(FixedPushError.Overflow, stack.push(1)); + try testing.expectError(FixedPushError.Overflow, stack.pushAll(&.{1, 11, 11})); stack.clear(); - try expectEqual(stack.count(), 0); + try testing.expectEqual(stack.count(), 0); const writer = stack.writer(); - try expectEqual(writer.write(&.{0, 0, 0, 0}), 4); - try expectEqual(writer.writeByte(0), false); + try testing.expectEqual(writer.write(&.{0, 0, 0, 0}), 4); + try testing.expectEqual(writer.writeByte(0), false); }