1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
//! docs/typ/reference.typ, Rules for every file <rules>.
const std = @import("std");
const Session = @import("session").Session;
test "rules: a control character in a write to any ctl refuses the whole write, and a quoted line shows a tab as a blank" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
const n = try s.focused();
// The first column's serial, /layout's first word.
const col = std.mem.sliceTo(try s.read("/layout"), ' ');
for ([_][]const u8{ "/ctl", s.at("/pane/{d}/ctl", .{n}), s.at("/col/{s}/ctl", .{col}) }) |ctl| {
try std.testing.expectEqual(@as(u16, 22), try s.refused(ctl, "Wrap off\nbo\x01gus\n"));
try std.testing.expectEqualStrings("invalid command line: it holds a control character (or DEL) other than a tab", s.said);
}
try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/ctl", .{n}), "bogus\tword\n"));
// The offending word alone is quoted: a tab ends it.
try std.testing.expect(std.mem.indexOf(u8, s.said, "\"bogus\"") != null);
try std.testing.expect(std.mem.indexOfScalar(u8, s.said, '\t') == null);
}
|