summaryrefslogtreecommitdiff
path: root/src/surface.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/surface.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/surface.zig')
-rw-r--r--src/surface.zig74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/surface.zig b/src/surface.zig
index 5bee28d7..9333a75e 100644
--- a/src/surface.zig
+++ b/src/surface.zig
@@ -54,21 +54,6 @@ pub const Cell = struct {
}
};
-test "cell visual equality ignores dead grapheme tail bytes" {
- var a: Cell = .{ .default = false };
- var b = a;
- a.text[0] = 'x';
- b.text[0] = 'x';
- a.text[4] = 'a';
- b.text[4] = 'b';
- try std.testing.expect(a.visuallyEqual(&b));
- b.style.bold = true;
- try std.testing.expect(!a.visuallyEqual(&b));
- a.default = true;
- b.default = true;
- try std.testing.expect(a.visuallyEqual(&b));
-}
-
/// A rectangle in pixels.
pub const RectPx = struct {
x: u32 = 0,
@@ -128,20 +113,6 @@ pub fn containGeometry(iw: usize, ih: usize, max_w: u32, max_h: u32) ?NativeGeom
return .{ .src = .{ .w = src_w, .h = src_h }, .dst = dst };
}
-test "native image contain keeps aspect, bounds, top-left, and small-image size" {
- try std.testing.expectEqual(RectPx{ .w = 40, .h = 20 }, containGeometry(400, 200, 40, 40).?.dst);
- try std.testing.expectEqual(RectPx{ .w = 20, .h = 40 }, containGeometry(200, 400, 40, 40).?.dst);
- try std.testing.expectEqual(RectPx{ .w = 17, .h = 9 }, containGeometry(17, 9, 40, 40).?.dst);
- try std.testing.expect(containGeometry(17, 9, 0, 40) == null);
-
- const odd = containGeometry(403, 211, 101, 47).?;
- try std.testing.expectEqual(RectPx{ .w = 89, .h = 47 }, odd.dst);
- try std.testing.expectEqual(RectPx{ .w = 403, .h = 211 }, odd.src);
- // Nothing its backend contract cannot represent.
- try std.testing.expect(containGeometry(0, 10, 20, 20) == null);
- if (@bitSizeOf(usize) > 32) try std.testing.expect(containGeometry(@as(usize, std.math.maxInt(u32)) + 1, 10, 20, 20) == null);
-}
-
/// A rectangle in the frame's cells.
pub const RectCell = struct { x: u16 = 0, y: u16 = 0, w: u16 = 0, h: u16 = 0 };
@@ -210,14 +181,6 @@ pub const Placement = struct {
}
};
-test "a placement's key follows its pane, its page and the revision of its pixels, and nothing of where it goes" {
- const first = Placement.keyOf(41, 7, 3);
- try std.testing.expectEqual(first, Placement.keyOf(41, 7, 3));
- try std.testing.expect(first != Placement.keyOf(41, 8, 3));
- try std.testing.expect(first != Placement.keyOf(41, 7, 4));
- try std.testing.expect(first != Placement.keyOf(42, 7, 3));
-}
-
/// One part of the frame and where it is, placed once by `draw.place`
/// before anything is painted: every painter and every shell reads the
/// geometry here instead of working it out again. `rect` is in grid cells
@@ -517,6 +480,43 @@ pub const Surface = struct {
}
};
+test "cell visual equality ignores dead grapheme tail bytes" {
+ var a: Cell = .{ .default = false };
+ var b = a;
+ a.text[0] = 'x';
+ b.text[0] = 'x';
+ a.text[4] = 'a';
+ b.text[4] = 'b';
+ try std.testing.expect(a.visuallyEqual(&b));
+ b.style.bold = true;
+ try std.testing.expect(!a.visuallyEqual(&b));
+ a.default = true;
+ b.default = true;
+ try std.testing.expect(a.visuallyEqual(&b));
+}
+
+test "native image contain keeps aspect, bounds, top-left, and small-image size" {
+ try std.testing.expectEqual(RectPx{ .w = 40, .h = 20 }, containGeometry(400, 200, 40, 40).?.dst);
+ try std.testing.expectEqual(RectPx{ .w = 20, .h = 40 }, containGeometry(200, 400, 40, 40).?.dst);
+ try std.testing.expectEqual(RectPx{ .w = 17, .h = 9 }, containGeometry(17, 9, 40, 40).?.dst);
+ try std.testing.expect(containGeometry(17, 9, 0, 40) == null);
+
+ const odd = containGeometry(403, 211, 101, 47).?;
+ try std.testing.expectEqual(RectPx{ .w = 89, .h = 47 }, odd.dst);
+ try std.testing.expectEqual(RectPx{ .w = 403, .h = 211 }, odd.src);
+ // Nothing its backend contract cannot represent.
+ try std.testing.expect(containGeometry(0, 10, 20, 20) == null);
+ if (@bitSizeOf(usize) > 32) try std.testing.expect(containGeometry(@as(usize, std.math.maxInt(u32)) + 1, 10, 20, 20) == null);
+}
+
+test "a placement's key follows its pane, its page and the revision of its pixels, and nothing of where it goes" {
+ const first = Placement.keyOf(41, 7, 3);
+ try std.testing.expectEqual(first, Placement.keyOf(41, 7, 3));
+ try std.testing.expect(first != Placement.keyOf(41, 8, 3));
+ try std.testing.expect(first != Placement.keyOf(41, 7, 4));
+ try std.testing.expect(first != Placement.keyOf(42, 7, 3));
+}
+
test "surface print expands configured tabs and normalizes other controls" {
const tab_cells: usize = @as(usize, config.tab_width) * 2;
const replacement_cells = 5;