| author | |
| committer | |
| log | 7ef45fbcd11d2af38fa372137d45c2fd4d9e94b8 |
| tree | ec160c395275eedfe1b9543a4c2f47837ce58690 |
| parent | 74f0ddb0a4dfa7921739b88cc381951a6b6e73ce |
2 files changed, 41 insertions(+), 0 deletions(-)
src/OneSmallerInt.zig created+40| ... | @@ -0,0 +1,40 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const string = []const u8; | ||
| 3 | const extras = @import("./lib.zig"); | ||
| 4 | |||
| 5 | pub fn OneSmallerInt(comptime T: type) type { | ||
| 6 | var info = @typeInfo(T); | ||
| 7 | info.Int.bits -= 1; | ||
| 8 | return @Type(info); | ||
| 9 | } | ||
| 10 | |||
| 11 | test { | ||
| 12 | try std.testing.expect(OneSmallerInt(u1) == u0); | ||
| 13 | } | ||
| 14 | test { | ||
| 15 | try std.testing.expect(OneSmallerInt(u2) == u1); | ||
| 16 | } | ||
| 17 | test { | ||
| 18 | try std.testing.expect(OneSmallerInt(u3) == u2); | ||
| 19 | } | ||
| 20 | test { | ||
| 21 | try std.testing.expect(OneSmallerInt(u4) == u3); | ||
| 22 | } | ||
| 23 | test { | ||
| 24 | try std.testing.expect(OneSmallerInt(u5) == u4); | ||
| 25 | } | ||
| 26 | test { | ||
| 27 | try std.testing.expect(OneSmallerInt(i1) == i0); | ||
| 28 | } | ||
| 29 | test { | ||
| 30 | try std.testing.expect(OneSmallerInt(i2) == i1); | ||
| 31 | } | ||
| 32 | test { | ||
| 33 | try std.testing.expect(OneSmallerInt(i3) == i2); | ||
| 34 | } | ||
| 35 | test { | ||
| 36 | try std.testing.expect(OneSmallerInt(i4) == i3); | ||
| 37 | } | ||
| 38 | test { | ||
| 39 | try std.testing.expect(OneSmallerInt(i5) == i4); | ||
| 40 | } | ||
src/lib.zig+1| ... | @@ -93,3 +93,4 @@ pub usingnamespace @import("./rawInt.zig"); | ... | @@ -93,3 +93,4 @@ pub usingnamespace @import("./rawInt.zig"); |
| 93 | pub usingnamespace @import("./expectSimilarType.zig"); | 93 | pub usingnamespace @import("./expectSimilarType.zig"); |
| 94 | pub usingnamespace @import("./rawIntBytes.zig"); | 94 | pub usingnamespace @import("./rawIntBytes.zig"); |
| 95 | pub usingnamespace @import("./globalOption.zig"); | 95 | pub usingnamespace @import("./globalOption.zig"); |
| 96 | pub usingnamespace @import("./OneSmallerInt.zig"); |