2020-11-07 05:36:18 +08:00
|
|
|
const expect = @import("std").testing.expect;
|
2019-02-23 00:09:17 +08:00
|
|
|
|
|
|
|
test "bitCast to array" {
|
2021-05-05 02:23:22 +08:00
|
|
|
comptime try testBitCastArray();
|
|
|
|
try testBitCastArray();
|
2019-02-23 00:09:17 +08:00
|
|
|
}
|
|
|
|
|
2021-05-05 02:23:22 +08:00
|
|
|
fn testBitCastArray() !void {
|
|
|
|
try expect(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
|
2019-02-23 00:09:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn extractOne64(a: u128) u64 {
|
|
|
|
const x = @bitCast([2]u64, a);
|
|
|
|
return x[1];
|
|
|
|
}
|