diff options
Diffstat (limited to 'test/behaviour/root_ctl.zig')
| -rw-r--r-- | test/behaviour/root_ctl.zig | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/behaviour/root_ctl.zig b/test/behaviour/root_ctl.zig index c00c3cfe..3e546237 100644 --- a/test/behaviour/root_ctl.zig +++ b/test/behaviour/root_ctl.zig @@ -92,3 +92,34 @@ test "root-ctl: Kill with a name and nothing running says so and does not fail, try s.write("/ctl", "Kill zzz\n"); try std.testing.expect(has(try s.read("/log"), "Kill: nothing running")); } + +test "root-ctl: a bad Tab width and a bad Incl directory are refused invalid, changing nothing" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const before = try s.read("/ctl"); + // Bare, Incl lists its directories. + try s.write("/ctl", "Incl\n"); + const listed = try lastIncl(&s); + for ([_][]const u8{ "Tab 0\n", "Tab 17\n", "Tab x\n" }) |line| { + try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", line)); + // Run from a pane, as a tag click runs it: said invalid too. + try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), line)); + try std.testing.expect(has(s.said, "invalid tab width")); + } + try s.expect("/ctl", before); + try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Incl rel/dir\n")); + try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Incl - /usr/include\n")); + try std.testing.expectEqual(@as(u16, 2), try s.refused("/ctl", "Incl /tmp/pardes-surely-no-such-dir\n")); + // The same list again: none taken. + try s.write("/ctl", "Incl\n"); + try std.testing.expectEqual(@as(usize, 2), std.mem.count(u8, try s.read("/log"), listed)); + // Bare Tab on the root ctl says the width, as from a pane. + try s.write("/ctl", "Tab\n"); +} + +/// The log's one `msg - Incl:` record, whole. +fn lastIncl(s: *Session) ![]const u8 { + const log = try s.read("/log"); + const at = std.mem.indexOf(u8, log, "\nmsg - Incl:") orelse return error.NoIncl; + return log[at .. std.mem.indexOfScalarPos(u8, log, at + 1, '\n').? + 1]; +} |
