summaryrefslogtreecommitdiff
path: root/test/behaviour/settings.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/settings.zig')
-rw-r--r--test/behaviour/settings.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index ff24704a..027fd1c9 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -101,3 +101,26 @@ test "settings: Config without a configuration directory says so and opens nothi
try s.expect("/index", index);
try expectHas(try s.read("/log"), "Config: no startup file here: no configuration directory");
}
+
+test "settings: every on/off setting the root ctl reads flips when its word is written bare, and Theme and Shell take a value" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ var lines = std.mem.tokenizeScalar(u8, try s.read("/ctl"), '\n');
+ var flipped: usize = 0;
+ while (lines.next()) |line| {
+ const space = std.mem.indexOfScalar(u8, line, ' ') orelse continue;
+ const word, const was = .{ line[0..space], line[space + 1 ..] };
+ const on = std.mem.eql(u8, was, "on");
+ if (!on and !std.mem.eql(u8, was, "off")) continue;
+ try s.write("/ctl", s.at("{s}\n", .{word}));
+ try std.testing.expectEqualStrings(s.at("{s} {s}", .{ word, if (on) "off" else "on" }), try setting(&s, word));
+ flipped += 1;
+ }
+ try std.testing.expect(flipped > 20);
+ for ([_][]const u8{ "Colors off", "Wrap off", "Tagbottom on", "Debug on" }) |want|
+ try std.testing.expectEqualStrings(want, try setting(&s, want[0..std.mem.indexOfScalar(u8, want, ' ').?]));
+ try s.write("/ctl", "Theme acme\n");
+ try s.write("/ctl", "Shell /bin/sh\n");
+ try std.testing.expectEqualStrings("Theme acme", try setting(&s, "Theme"));
+ try std.testing.expectEqualStrings("Shell /bin/sh", try setting(&s, "Shell"));
+}