| 1 | const std = @import("std"); |
| 2 | const testing = std.testing; |
| 3 | |
| 4 | const Config = struct { |
| 5 | terminal: []const u8 = "st", |
| 6 | font: []const u8 = "monospace:size=10", |
| 7 | border_width: i32 = 2, |
| 8 | border_focused: u32 = 0x6dade3, |
| 9 | border_unfocused: u32 = 0x444444, |
| 10 | gaps_enabled: bool = true, |
| 11 | gap_inner_h: i32 = 5, |
| 12 | gap_inner_v: i32 = 5, |
| 13 | gap_outer_h: i32 = 5, |
| 14 | gap_outer_v: i32 = 5, |
| 15 | modkey: u32 = (1 << 6), |
| 16 | auto_tile: bool = false, |
| 17 | tag_back_and_forth: bool = false, |
| 18 | hide_vacant_tags: bool = false, |
| 19 | }; |
| 20 | |
| 21 | test "config has correct default terminal" { |
| 22 | const cfg = Config{}; |
| 23 | try testing.expectEqualStrings("st", cfg.terminal); |
| 24 | } |
| 25 | |
| 26 | test "config has correct default font" { |
| 27 | const cfg = Config{}; |
| 28 | try testing.expectEqualStrings("monospace:size=10", cfg.font); |
| 29 | } |
| 30 | |
| 31 | test "config has correct default border width" { |
| 32 | const cfg = Config{}; |
| 33 | try testing.expectEqual(@as(i32, 2), cfg.border_width); |
| 34 | } |
| 35 | |
| 36 | test "config has correct default focused border color" { |
| 37 | const cfg = Config{}; |
| 38 | try testing.expectEqual(@as(u32, 0x6dade3), cfg.border_focused); |
| 39 | } |
| 40 | |
| 41 | test "config has correct default unfocused border color" { |
| 42 | const cfg = Config{}; |
| 43 | try testing.expectEqual(@as(u32, 0x444444), cfg.border_unfocused); |
| 44 | } |
| 45 | |
| 46 | test "config gaps are enabled by default" { |
| 47 | const cfg = Config{}; |
| 48 | try testing.expect(cfg.gaps_enabled); |
| 49 | } |
| 50 | |
| 51 | test "config has correct default gap values" { |
| 52 | const cfg = Config{}; |
| 53 | try testing.expectEqual(@as(i32, 5), cfg.gap_inner_h); |
| 54 | try testing.expectEqual(@as(i32, 5), cfg.gap_inner_v); |
| 55 | try testing.expectEqual(@as(i32, 5), cfg.gap_outer_h); |
| 56 | try testing.expectEqual(@as(i32, 5), cfg.gap_outer_v); |
| 57 | } |
| 58 | |
| 59 | test "config auto_tile is disabled by default" { |
| 60 | const cfg = Config{}; |
| 61 | try testing.expect(!cfg.auto_tile); |
| 62 | } |
| 63 | |
| 64 | test "config tag_back_and_forth is disabled by default" { |
| 65 | const cfg = Config{}; |
| 66 | try testing.expect(!cfg.tag_back_and_forth); |
| 67 | } |
| 68 | |
| 69 | test "config hide_vacant_tags is disabled by default" { |
| 70 | const cfg = Config{}; |
| 71 | try testing.expect(!cfg.hide_vacant_tags); |
| 72 | } |
| 73 | |
| 74 | test "config default modkey is Mod4 (super)" { |
| 75 | const cfg = Config{}; |
| 76 | try testing.expectEqual(@as(u32, 1 << 6), cfg.modkey); |
| 77 | } |
| 78 | |
| 79 | test "can override config defaults" { |
| 80 | const cfg = Config{ |
| 81 | .terminal = "alacritty", |
| 82 | .border_width = 3, |
| 83 | .gaps_enabled = false, |
| 84 | }; |
| 85 | try testing.expectEqualStrings("alacritty", cfg.terminal); |
| 86 | try testing.expectEqual(@as(i32, 3), cfg.border_width); |
| 87 | try testing.expect(!cfg.gaps_enabled); |
| 88 | } |