Compare commits

..

No commits in common. "3ca0bd5724c560a9b48f79b9ee6ca183b175cbc4" and "be94963cb7602ae7ca7da17f665457ff5be63cab" have entirely different histories.

6 changed files with 32 additions and 44 deletions

36
.vscode/launch.json vendored
View File

@ -1,24 +1,16 @@
{ {
"version": "0.2.0", // Use IntelliSense to learn about possible attributes.
"configurations": [ // Hover to view descriptions of existing attributes.
{ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"name": "Build", "version": "0.2.0",
"type": "gdb", "configurations": [
"request": "launch", {
"target": "${workspaceFolder}/zig-out/bin/ona", "name": "Ona",
"cwd": "${workspaceRoot}", "type": "gdb",
"valuesFormatting": "parseText", "request": "launch",
"preLaunchTask": "Build", "target": "${workspaceFolder}/zig-out/bin/ona",
}, "cwd": "${workspaceRoot}",
{ "valuesFormatting": "parseText",
"name": "Test", }
"type": "gdb", ]
"request": "launch",
"target": "${workspaceFolder}/zig-cache/o/b57ef32c79a05339fbe4a8eb648ff6df/test",
"arguments": "main.zig",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText",
"preLaunchTask": "Build Test",
},
]
} }

View File

@ -13,5 +13,5 @@
}, },
"git.detectSubmodulesLimit": 0, "git.detectSubmodulesLimit": 0,
"git.ignoreSubmodules": true, "git.ignoreSubmodules": true
} }

8
.vscode/tasks.json vendored
View File

@ -44,17 +44,11 @@
{ {
"label": "Test", "label": "Test",
"type": "shell", "type": "shell",
"command": "zig test src/main.zig", "command": "zig build test",
"group": { "group": {
"kind": "test", "kind": "test",
"isDefault": true "isDefault": true
}, },
}, },
{
"label": "Build Test",
"type": "shell",
"command": "zig build test",
"group": "test"
},
], ],
} }

View File

@ -6,7 +6,7 @@ pub fn build(builder: *std.build.Builder) void {
// Ona executable. // 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.setTarget(target);
ona_exe.setBuildMode(mode); ona_exe.setBuildMode(mode);
@ -25,7 +25,7 @@ pub fn build(builder: *std.build.Builder) void {
// Ona tests. // Ona tests.
{ {
const ona_tests = builder.addTestExe("test", "./src/main.zig"); const ona_tests = builder.addTest("src/stack.zig");
ona_tests.setTarget(target); ona_tests.setTarget(target);
ona_tests.setBuildMode(mode); ona_tests.setBuildMode(mode);

View File

@ -15,7 +15,7 @@ pub fn main() anyerror!void {
} }
test { test {
_ = @import("./mem.zig"); // Empty test is here to run all others (for now).
} }
fn run(event_loop: *sys.EventLoop, graphics: *sys.GraphicsContext) anyerror!void { fn run(event_loop: *sys.EventLoop, graphics: *sys.GraphicsContext) anyerror!void {

View File

@ -92,26 +92,28 @@ pub const FixedPushError = error {
}; };
test "fixed stack" { test "fixed stack" {
const testing = std.testing; const testing = @import("std").testing;
const expectError = testing.expectError;
const expectEqual = testing.expectEqual;
var buffer = std.mem.zeroes([4]u8); var buffer = std.mem.zeroes([4]u8);
var stack = Fixed(u8){.buffer = &buffer}; var stack = Fixed(u8){.buffer = &buffer};
try testing.expectEqual(stack.count(), 0); try expectEqual(stack.count(), 0);
try testing.expectEqual(stack.pop(), null); try expectEqual(stack.pop(), null);
try stack.push(69); try stack.push(69);
try testing.expectEqual(stack.count(), 1); try expectEqual(stack.count(), 1);
try testing.expectEqual(stack.pop(), 69); try expectEqual(stack.pop(), 69);
try stack.pushAll(&.{42, 10, 95, 0}); try stack.pushAll(&.{42, 10, 95, 0});
try testing.expectEqual(stack.count(), 4); try expectEqual(stack.count(), 4);
try testing.expectError(FixedPushError.Overflow, stack.push(1)); try expectError(FixedPushError.Overflow, stack.push(1));
try testing.expectError(FixedPushError.Overflow, stack.pushAll(&.{1, 11, 11})); try expectError(FixedPushError.Overflow, stack.pushAll(&.{1, 11, 11}));
stack.clear(); stack.clear();
try testing.expectEqual(stack.count(), 0); try expectEqual(stack.count(), 0);
const writer = stack.writer(); const writer = stack.writer();
try testing.expectEqual(writer.write(&.{0, 0, 0, 0}), 4); try expectEqual(writer.write(&.{0, 0, 0, 0}), 4);
try testing.expectEqual(writer.writeByte(0), false); try expectEqual(writer.writeByte(0), false);
} }