1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn FlippedInt(comptime T: type) type {
6 const info = @typeInfo(T).int;
7 return @Int(
8 switch (info.signedness) {
9 .signed => .unsigned,
10 .unsigned => .signed,
11 },
12 info.bits,
13 );
14}
15
16test {
17 try std.testing.expect(FlippedInt(u1) == i1);
18}
19test {
20 try std.testing.expect(FlippedInt(u2) == i2);
21}
22test {
23 try std.testing.expect(FlippedInt(u3) == i3);
24}
25test {
26 try std.testing.expect(FlippedInt(u4) == i4);
27}
28test {
29 try std.testing.expect(FlippedInt(u5) == i5);
30}
31test {
32 try std.testing.expect(FlippedInt(i1) == u1);
33}
34test {
35 try std.testing.expect(FlippedInt(i2) == u2);
36}
37test {
38 try std.testing.expect(FlippedInt(i3) == u3);
39}
40test {
41 try std.testing.expect(FlippedInt(i4) == u4);
42}
43test {
44 try std.testing.expect(FlippedInt(i5) == u5);
45}