summaryrefslogtreecommitdiff
path: root/test/behaviour/settings.zig
blob: e62539e4c5d7e6b96c7a52a208507d37188ce2cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! docs/typ/reference.typ, Settings <settings>.
const std = @import("std");
const Session = @import("session").Session;

test "settings: Pet is the window's: a terminal's view refuses it, from a pane and the root; a window takes only its pets" {
    var s = try Session.initFile(std.testing.allocator, "x\n");
    defer s.deinit();
    // Which build, from its options, not from the answer: a terminal's view
    // taking Pet must fail here, not pass as a window.
    if (comptime @import("pardes_config").platform == .gui) {
        try s.write("/ctl", "Pet cat\n");
        // A window's: dog is no pet of its, and off is.
        try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet cat\n") != null);
        _ = try s.refused("/ctl", "Pet dog\n");
        try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet cat\n") != null);
        try s.write("/ctl", "Pet frog\n");
        try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet frog\n") != null);
        try s.write("/ctl", "Pet off\n");
        try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nPet off\n") != null);
        return;
    }
    try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Pet cat\n"));
    try std.testing.expect(std.mem.startsWith(u8, s.said, "Pet is GUI-only, invalid here"));
    try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Pet cat\n"));
    try std.testing.expectEqualStrings("Pet is GUI-only, invalid here", s.said);
    try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "Pet ") == null);
}