- commit
- 7b22ead
- parent
- 0ca4141
- author
- Eric Bower
- date
- 2025-10-15 14:59:35 -0400 EDT
chore: tests
1 files changed,
+54,
-1
+54,
-1
1@@ -255,8 +255,61 @@ test "wide character handling: skip spacer cells" {
2 const result = try render(&vt, allocator);
3 defer allocator.free(result);
4
5- // Should have emoji + AB + newline (not emoji + A + B with drift)
6+ // Should have emoji + AB (not emoji + A + B with drift)
7 // The emoji is UTF-8 encoded, so we just check we have content
8 try testing.expect(result.len > 0);
9 try testing.expect(std.mem.indexOf(u8, result, "AB") != null);
10 }
11+
12+test "render: colored text with SGR sequences" {
13+ const testing = std.testing;
14+ const allocator = testing.allocator;
15+
16+ var vt = try ghostty.Terminal.init(allocator, 80, 24, 100);
17+ defer vt.deinit(allocator);
18+
19+ // Set bold and write text
20+ try vt.setAttribute(.{ .bold = {} });
21+ try vt.print('B');
22+ try vt.print('O');
23+ try vt.print('L');
24+ try vt.print('D');
25+
26+ // Reset and write normal text
27+ try vt.setAttribute(.{ .reset = {} });
28+ try vt.print(' ');
29+ try vt.print('n');
30+ try vt.print('o');
31+ try vt.print('r');
32+ try vt.print('m');
33+
34+ const result = try render(&vt, allocator);
35+ defer allocator.free(result);
36+
37+ // Should contain bold SGR (ESC[1m) and text "BOLD"
38+ try testing.expect(std.mem.indexOf(u8, result, "\x1b[1m") != null);
39+ try testing.expect(std.mem.indexOf(u8, result, "BOLD") != null);
40+ try testing.expect(std.mem.indexOf(u8, result, "norm") != null);
41+}
42+
43+test "render: cursor position restoration" {
44+ const testing = std.testing;
45+ const allocator = testing.allocator;
46+
47+ var vt = try ghostty.Terminal.init(allocator, 80, 24, 100);
48+ defer vt.deinit(allocator);
49+
50+ // Write some text and move cursor
51+ try vt.print('T');
52+ try vt.print('e');
53+ try vt.print('s');
54+ try vt.print('t');
55+
56+ const result = try render(&vt, allocator);
57+ defer allocator.free(result);
58+
59+ // Should contain cursor positioning sequences
60+ try testing.expect(std.mem.indexOf(u8, result, "\x1b[1;1H") != null); // First row positioning
61+ try testing.expect(std.mem.indexOf(u8, result, "\x1b[?25h") != null); // Show cursor at end
62+ try testing.expect(std.mem.indexOf(u8, result, "Test") != null);
63+}