Compare commits
	
		
			4 Commits
		
	
	
		
			be94963cb7
			...
			3ca0bd5724
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3ca0bd5724 | |||
| 11b6040237 | |||
| 3f2f37e0f5 | |||
| 9c1ddd6e8f | 
							
								
								
									
										18
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@ -1,16 +1,24 @@
 | 
			
		||||
{
 | 
			
		||||
    // Use IntelliSense to learn about possible attributes.
 | 
			
		||||
    // Hover to view descriptions of existing attributes.
 | 
			
		||||
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 | 
			
		||||
	"version": "0.2.0",
 | 
			
		||||
	"configurations": [
 | 
			
		||||
		{
 | 
			
		||||
            "name": "Ona",
 | 
			
		||||
			"name": "Build",
 | 
			
		||||
			"type": "gdb",
 | 
			
		||||
			"request": "launch",
 | 
			
		||||
			"target": "${workspaceFolder}/zig-out/bin/ona",
 | 
			
		||||
			"cwd": "${workspaceRoot}",
 | 
			
		||||
			"valuesFormatting": "parseText",
 | 
			
		||||
        }
 | 
			
		||||
			"preLaunchTask": "Build",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			"name": "Test",
 | 
			
		||||
			"type": "gdb",
 | 
			
		||||
			"request": "launch",
 | 
			
		||||
			"target": "${workspaceFolder}/zig-cache/o/b57ef32c79a05339fbe4a8eb648ff6df/test",
 | 
			
		||||
			"arguments": "main.zig",
 | 
			
		||||
			"cwd": "${workspaceRoot}",
 | 
			
		||||
			"valuesFormatting": "parseText",
 | 
			
		||||
			"preLaunchTask": "Build Test",
 | 
			
		||||
		},
 | 
			
		||||
	]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@ -13,5 +13,5 @@
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    "git.detectSubmodulesLimit": 0,
 | 
			
		||||
    "git.ignoreSubmodules": true
 | 
			
		||||
    "git.ignoreSubmodules": true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@ -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"
 | 
			
		||||
		},
 | 
			
		||||
	],
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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/stack.zig");
 | 
			
		||||
        const ona_tests = builder.addTestExe("test", "./src/main.zig");
 | 
			
		||||
 | 
			
		||||
        ona_tests.setTarget(target);
 | 
			
		||||
        ona_tests.setBuildMode(mode);
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ pub fn main() anyerror!void {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    // Empty test is here to run all others (for now).
 | 
			
		||||
    _ = @import("./mem.zig");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn run(event_loop: *sys.EventLoop, graphics: *sys.GraphicsContext) anyerror!void {
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user