summaryrefslogtreecommitdiff
path: root/core/views.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/views.zig')
-rw-r--r--core/views.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/views.zig b/core/views.zig
index 9d627a17..ee061964 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -925,3 +925,19 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o
try testing.expectEqual(@as(i32, 30), one.panes[id].?.body.cur_row);
try testing.expectEqual(@as(?u8, 1), one.openView());
}
+
+test "a pane's id and a view's id are two types: neither is taken for the other, nor for an integer" {
+ // An enum coerces into nothing but itself (an enum literal into it, it
+ // into a union of it): two distinct enum types never stand for each
+ // other, so `p.toView(pane_id)` or `p.setMessage(view_id, ..)` does not
+ // compile. What is left to show is that they are two, and a byte each.
+ comptime {
+ std.debug.assert(Pane.Id != View.Id);
+ for (.{ Pane.Id, View.Id }) |T| {
+ const e = @typeInfo(T).@"enum";
+ std.debug.assert(e.tag_type == u8 and e.mode == .nonexhaustive and @sizeOf(T) == 1);
+ }
+ }
+ for (0..MAX_PANES) |i| try testing.expectEqual(i, Pane.Id.at(i).index());
+ for (0..max) |k| try testing.expectEqual(k, View.Id.at(k).index());
+}