From 38d33a761b62926b53dd5cea4719d9df10375307 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 11 Jul 2024 18:34:05 -0700 Subject: [PATCH] terminal: test DCS to make sure we don't regress --- src/terminal/Parser.zig | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index e18d14df6..9aebdbd3a 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -800,7 +800,31 @@ test "csi: too many params" { } } -test "dcs" { +test "dcs: XTGETTCAP" { + var p = init(); + _ = p.next(0x1B); + for ("P+") |c| { + const a = p.next(c); + try testing.expect(a[0] == null); + try testing.expect(a[1] == null); + try testing.expect(a[2] == null); + } + + { + const a = p.next('q'); + try testing.expect(p.state == .dcs_passthrough); + try testing.expect(a[0] == null); + try testing.expect(a[1] == null); + try testing.expect(a[2].? == .dcs_hook); + + const hook = a[2].?.dcs_hook; + try testing.expectEqualSlices(u8, &[_]u8{'+'}, hook.intermediates); + try testing.expectEqualSlices(u16, &[_]u16{}, hook.params); + try testing.expectEqual('q', hook.final); + } +} + +test "dcs: params" { var p = init(); _ = p.next(0x1B); for ("P1000") |c| {