Deleted tests that are not helpful for end user.
Browse files
+0 −137 tests/keybind_tests.zig deleted file mode 100644
| @@ -1,137 +0,0 @@ | |||
| 1 | -const std = @import("std"); | ||
| 2 | -const testing = std.testing; | ||
| 3 | - | ||
| 4 | -const Mod4Mask: u32 = 1 << 6; | ||
| 5 | -const Mod1Mask: u32 = 1 << 3; | ||
| 6 | -const ShiftMask: u32 = 1 << 0; | ||
| 7 | -const ControlMask: u32 = 1 << 2; | ||
| 8 | - | ||
| 9 | -fn parse_modifier(name: []const u8) u32 { | ||
| 10 | - if (std.mem.eql(u8, name, "Mod4") or std.mem.eql(u8, name, "mod4") or std.mem.eql(u8, name, "super")) { | ||
| 11 | - return Mod4Mask; | ||
| 12 | - } else if (std.mem.eql(u8, name, "Mod1") or std.mem.eql(u8, name, "mod1") or std.mem.eql(u8, name, "alt")) { | ||
| 13 | - return Mod1Mask; | ||
| 14 | - } else if (std.mem.eql(u8, name, "Shift") or std.mem.eql(u8, name, "shift")) { | ||
| 15 | - return ShiftMask; | ||
| 16 | - } else if (std.mem.eql(u8, name, "Control") or std.mem.eql(u8, name, "control") or std.mem.eql(u8, name, "ctrl")) { | ||
| 17 | - return ControlMask; | ||
| 18 | - } | ||
| 19 | - return 0; | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -fn parse_modifiers(names: []const []const u8) u32 { | ||
| 23 | - var mask: u32 = 0; | ||
| 24 | - for (names) |name| { | ||
| 25 | - mask |= parse_modifier(name); | ||
| 26 | - } | ||
| 27 | - return mask; | ||
| 28 | -} | ||
| 29 | - | ||
| 30 | -test "parse_modifier: Mod4 variants" { | ||
| 31 | - try testing.expectEqual(Mod4Mask, parse_modifier("Mod4")); | ||
| 32 | - try testing.expectEqual(Mod4Mask, parse_modifier("mod4")); | ||
| 33 | - try testing.expectEqual(Mod4Mask, parse_modifier("super")); | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -test "parse_modifier: Mod1 (Alt) variants" { | ||
| 37 | - try testing.expectEqual(Mod1Mask, parse_modifier("Mod1")); | ||
| 38 | - try testing.expectEqual(Mod1Mask, parse_modifier("mod1")); | ||
| 39 | - try testing.expectEqual(Mod1Mask, parse_modifier("alt")); | ||
| 40 | -} | ||
| 41 | - | ||
| 42 | -test "parse_modifier: Shift variants" { | ||
| 43 | - try testing.expectEqual(ShiftMask, parse_modifier("Shift")); | ||
| 44 | - try testing.expectEqual(ShiftMask, parse_modifier("shift")); | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -test "parse_modifier: Control variants" { | ||
| 48 | - try testing.expectEqual(ControlMask, parse_modifier("Control")); | ||
| 49 | - try testing.expectEqual(ControlMask, parse_modifier("control")); | ||
| 50 | - try testing.expectEqual(ControlMask, parse_modifier("ctrl")); | ||
| 51 | -} | ||
| 52 | - | ||
| 53 | -test "parse_modifier: unknown returns 0" { | ||
| 54 | - try testing.expectEqual(@as(u32, 0), parse_modifier("Unknown")); | ||
| 55 | - try testing.expectEqual(@as(u32, 0), parse_modifier("")); | ||
| 56 | -} | ||
| 57 | - | ||
| 58 | -test "parse_modifiers: combines multiple modifiers" { | ||
| 59 | - const mods = &[_][]const u8{ "Mod4", "Shift" }; | ||
| 60 | - try testing.expectEqual(Mod4Mask | ShiftMask, parse_modifiers(mods)); | ||
| 61 | -} | ||
| 62 | - | ||
| 63 | -test "parse_modifiers: triple combination" { | ||
| 64 | - const mods = &[_][]const u8{ "super", "shift", "ctrl" }; | ||
| 65 | - try testing.expectEqual(Mod4Mask | ShiftMask | ControlMask, parse_modifiers(mods)); | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -test "parse_modifiers: empty list returns 0" { | ||
| 69 | - const mods = &[_][]const u8{}; | ||
| 70 | - try testing.expectEqual(@as(u32, 0), parse_modifiers(mods)); | ||
| 71 | -} | ||
| 72 | - | ||
| 73 | -fn key_name_to_keysym(name: []const u8) ?u64 { | ||
| 74 | - const key_map = .{ | ||
| 75 | - .{ "Return", 0xff0d }, | ||
| 76 | - .{ "Enter", 0xff0d }, | ||
| 77 | - .{ "Tab", 0xff09 }, | ||
| 78 | - .{ "Escape", 0xff1b }, | ||
| 79 | - .{ "BackSpace", 0xff08 }, | ||
| 80 | - .{ "Delete", 0xffff }, | ||
| 81 | - .{ "space", 0x0020 }, | ||
| 82 | - .{ "Space", 0x0020 }, | ||
| 83 | - }; | ||
| 84 | - | ||
| 85 | - inline for (key_map) |entry| { | ||
| 86 | - if (std.mem.eql(u8, name, entry[0])) { | ||
| 87 | - return entry[1]; | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - if (name.len == 1) { | ||
| 92 | - const char = name[0]; | ||
| 93 | - if (char >= 'a' and char <= 'z') { | ||
| 94 | - return char; | ||
| 95 | - } | ||
| 96 | - if (char >= 'A' and char <= 'Z') { | ||
| 97 | - return char + 32; | ||
| 98 | - } | ||
| 99 | - if (char >= '0' and char <= '9') { | ||
| 100 | - return char; | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - return null; | ||
| 105 | -} | ||
| 106 | - | ||
| 107 | -test "key_name_to_keysym: special keys" { | ||
| 108 | - try testing.expectEqual(@as(?u64, 0xff0d), key_name_to_keysym("Return")); | ||
| 109 | - try testing.expectEqual(@as(?u64, 0xff0d), key_name_to_keysym("Enter")); | ||
| 110 | - try testing.expectEqual(@as(?u64, 0xff09), key_name_to_keysym("Tab")); | ||
| 111 | - try testing.expectEqual(@as(?u64, 0xff1b), key_name_to_keysym("Escape")); | ||
| 112 | -} | ||
| 113 | - | ||
| 114 | -test "key_name_to_keysym: lowercase letters" { | ||
| 115 | - try testing.expectEqual(@as(?u64, 'a'), key_name_to_keysym("a")); | ||
| 116 | - try testing.expectEqual(@as(?u64, 'z'), key_name_to_keysym("z")); | ||
| 117 | -} | ||
| 118 | - | ||
| 119 | -test "key_name_to_keysym: uppercase converts to lowercase" { | ||
| 120 | - try testing.expectEqual(@as(?u64, 'a'), key_name_to_keysym("A")); | ||
| 121 | - try testing.expectEqual(@as(?u64, 'z'), key_name_to_keysym("Z")); | ||
| 122 | -} | ||
| 123 | - | ||
| 124 | -test "key_name_to_keysym: numbers" { | ||
| 125 | - try testing.expectEqual(@as(?u64, '0'), key_name_to_keysym("0")); | ||
| 126 | - try testing.expectEqual(@as(?u64, '9'), key_name_to_keysym("9")); | ||
| 127 | -} | ||
| 128 | - | ||
| 129 | -test "key_name_to_keysym: unknown returns null" { | ||
| 130 | - try testing.expectEqual(@as(?u64, null), key_name_to_keysym("UnknownKey")); | ||
| 131 | - try testing.expectEqual(@as(?u64, null), key_name_to_keysym("")); | ||
| 132 | -} | ||
| 133 | - | ||
| 134 | -test "key_name_to_keysym: space variants" { | ||
| 135 | - try testing.expectEqual(@as(?u64, 0x0020), key_name_to_keysym("space")); | ||
| 136 | - try testing.expectEqual(@as(?u64, 0x0020), key_name_to_keysym("Space")); | ||
| 137 | -} | ||
+0 −138 tests/layout_tests.zig deleted file mode 100644
| @@ -1,138 +0,0 @@ | |||
| 1 | -const std = @import("std"); | ||
| 2 | -const testing = std.testing; | ||
| 3 | - | ||
| 4 | -const Rect = struct { | ||
| 5 | - x: i32, | ||
| 6 | - y: i32, | ||
| 7 | - w: i32, | ||
| 8 | - h: i32, | ||
| 9 | -}; | ||
| 10 | - | ||
| 11 | -fn calculate_master_stack_layout( | ||
| 12 | - area: Rect, | ||
| 13 | - num_clients: usize, | ||
| 14 | - num_master: usize, | ||
| 15 | - master_factor: f32, | ||
| 16 | - gap: i32, | ||
| 17 | -) []Rect { | ||
| 18 | - var rects: [16]Rect = undefined; | ||
| 19 | - if (num_clients == 0) return rects[0..0]; | ||
| 20 | - | ||
| 21 | - const actual_master = @min(num_master, num_clients); | ||
| 22 | - const stack_count = if (num_clients > actual_master) num_clients - actual_master else 0; | ||
| 23 | - | ||
| 24 | - const master_width: i32 = if (stack_count > 0) | ||
| 25 | - @intFromFloat(@as(f32, @floatFromInt(area.w - gap)) * master_factor) | ||
| 26 | - else | ||
| 27 | - area.w; | ||
| 28 | - | ||
| 29 | - var i: usize = 0; | ||
| 30 | - while (i < actual_master) : (i += 1) { | ||
| 31 | - const h = @divTrunc(area.h - @as(i32, @intCast(actual_master - 1)) * gap, @as(i32, @intCast(actual_master))); | ||
| 32 | - rects[i] = .{ | ||
| 33 | - .x = area.x, | ||
| 34 | - .y = area.y + @as(i32, @intCast(i)) * (h + gap), | ||
| 35 | - .w = master_width, | ||
| 36 | - .h = h, | ||
| 37 | - }; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - const stack_width = area.w - master_width - gap; | ||
| 41 | - var j: usize = 0; | ||
| 42 | - while (j < stack_count) : (j += 1) { | ||
| 43 | - const h = @divTrunc(area.h - @as(i32, @intCast(stack_count - 1)) * gap, @as(i32, @intCast(stack_count))); | ||
| 44 | - rects[actual_master + j] = .{ | ||
| 45 | - .x = area.x + master_width + gap, | ||
| 46 | - .y = area.y + @as(i32, @intCast(j)) * (h + gap), | ||
| 47 | - .w = stack_width, | ||
| 48 | - .h = h, | ||
| 49 | - }; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - return rects[0..num_clients]; | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -test "tiling layout: single window fills area" { | ||
| 56 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 57 | - const rects = calculate_master_stack_layout(area, 1, 1, 0.55, 5); | ||
| 58 | - | ||
| 59 | - try testing.expectEqual(@as(usize, 1), rects.len); | ||
| 60 | - try testing.expectEqual(@as(i32, 0), rects[0].x); | ||
| 61 | - try testing.expectEqual(@as(i32, 0), rects[0].y); | ||
| 62 | - try testing.expectEqual(@as(i32, 800), rects[0].w); | ||
| 63 | - try testing.expectEqual(@as(i32, 600), rects[0].h); | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | -test "tiling layout: two windows split horizontally" { | ||
| 67 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 68 | - const rects = calculate_master_stack_layout(area, 2, 1, 0.5, 0); | ||
| 69 | - | ||
| 70 | - try testing.expectEqual(@as(usize, 2), rects.len); | ||
| 71 | - try testing.expectEqual(@as(i32, 400), rects[0].w); | ||
| 72 | - try testing.expectEqual(@as(i32, 400), rects[1].w); | ||
| 73 | -} | ||
| 74 | - | ||
| 75 | -test "tiling layout: respects master factor" { | ||
| 76 | - const area = Rect{ .x = 0, .y = 0, .w = 1000, .h = 600 }; | ||
| 77 | - const rects = calculate_master_stack_layout(area, 2, 1, 0.6, 0); | ||
| 78 | - | ||
| 79 | - try testing.expectEqual(@as(usize, 2), rects.len); | ||
| 80 | - try testing.expectEqual(@as(i32, 600), rects[0].w); | ||
| 81 | - try testing.expectEqual(@as(i32, 400), rects[1].w); | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -test "tiling layout: no clients returns empty" { | ||
| 85 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 86 | - const rects = calculate_master_stack_layout(area, 0, 1, 0.55, 5); | ||
| 87 | - | ||
| 88 | - try testing.expectEqual(@as(usize, 0), rects.len); | ||
| 89 | -} | ||
| 90 | - | ||
| 91 | -test "tiling layout: multiple stack windows divide height" { | ||
| 92 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 93 | - const rects = calculate_master_stack_layout(area, 3, 1, 0.5, 0); | ||
| 94 | - | ||
| 95 | - try testing.expectEqual(@as(usize, 3), rects.len); | ||
| 96 | - try testing.expectEqual(@as(i32, 600), rects[0].h); | ||
| 97 | - try testing.expectEqual(@as(i32, 300), rects[1].h); | ||
| 98 | - try testing.expectEqual(@as(i32, 300), rects[2].h); | ||
| 99 | -} | ||
| 100 | - | ||
| 101 | -fn calculate_monocle_layout(area: Rect, num_clients: usize) []Rect { | ||
| 102 | - var rects: [16]Rect = undefined; | ||
| 103 | - if (num_clients == 0) return rects[0..0]; | ||
| 104 | - | ||
| 105 | - var i: usize = 0; | ||
| 106 | - while (i < num_clients) : (i += 1) { | ||
| 107 | - rects[i] = area; | ||
| 108 | - } | ||
| 109 | - return rects[0..num_clients]; | ||
| 110 | -} | ||
| 111 | - | ||
| 112 | -test "monocle layout: all windows get full area" { | ||
| 113 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 114 | - const rects = calculate_monocle_layout(area, 3); | ||
| 115 | - | ||
| 116 | - try testing.expectEqual(@as(usize, 3), rects.len); | ||
| 117 | - for (rects) |rect| { | ||
| 118 | - try testing.expectEqual(@as(i32, 0), rect.x); | ||
| 119 | - try testing.expectEqual(@as(i32, 0), rect.y); | ||
| 120 | - try testing.expectEqual(@as(i32, 800), rect.w); | ||
| 121 | - try testing.expectEqual(@as(i32, 600), rect.h); | ||
| 122 | - } | ||
| 123 | -} | ||
| 124 | - | ||
| 125 | -test "monocle layout: no clients returns empty" { | ||
| 126 | - const area = Rect{ .x = 0, .y = 0, .w = 800, .h = 600 }; | ||
| 127 | - const rects = calculate_monocle_layout(area, 0); | ||
| 128 | - | ||
| 129 | - try testing.expectEqual(@as(usize, 0), rects.len); | ||
| 130 | -} | ||
| 131 | - | ||
| 132 | -test "monocle layout: respects area offset" { | ||
| 133 | - const area = Rect{ .x = 100, .y = 50, .w = 800, .h = 600 }; | ||
| 134 | - const rects = calculate_monocle_layout(area, 1); | ||
| 135 | - | ||
| 136 | - try testing.expectEqual(@as(i32, 100), rects[0].x); | ||
| 137 | - try testing.expectEqual(@as(i32, 50), rects[0].y); | ||
| 138 | -} | ||
+0 −2 tests/main_tests.zig
| @@ -2,6 +2,4 @@ const std = @import("std"); | |||
| 2 | 2 | ||
| 3 | test { | 3 | test { |
| 4 | _ = @import("config_tests.zig"); | 4 | _ = @import("config_tests.zig"); |
| 5 | - _ = @import("layout_tests.zig"); | ||
| 6 | - _ = @import("keybind_tests.zig"); | ||
| 7 | } | 5 | } |