authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-04-11 18:38:04+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-04-11 18:38:04+02:00
logd97981f6fd4e98506404de4259230dc157cc50dd
tree2eb2c40f9b9cf29b485b09d0557bb2e89fec95d6
parentcab1d5c1a320239af5be88571d7989ba230b90be

std: Make a test-case independent of the target endianness


1 files changed, 5 insertions(+), 4 deletions(-)

test/stage1/behavior/cast.zig+5-4
...@@ -17,14 +17,15 @@ test "integer literal to pointer cast" {...@@ -17,14 +17,15 @@ test "integer literal to pointer cast" {
17}17}
1818
19test "pointer reinterpret const float to int" {19test "pointer reinterpret const float to int" {
20 // https://github.com/ziglang/zig/issues/334520 // The hex representation is 0x3fe3333333333303.
21 if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
22
23 const float: f64 = 5.99999999999994648725e-01;21 const float: f64 = 5.99999999999994648725e-01;
24 const float_ptr = &float;22 const float_ptr = &float;
25 const int_ptr = @ptrCast(*const i32, float_ptr);23 const int_ptr = @ptrCast(*const i32, float_ptr);
26 const int_val = int_ptr.*;24 const int_val = int_ptr.*;
27 expect(int_val == 858993411);25 if (std.builtin.endian == .Little)
26 expect(int_val == 0x33333303)
27 else
28 expect(int_val == 0x3fe33333);
28}29}
2930
30test "implicitly cast indirect pointer to maybe-indirect pointer" {31test "implicitly cast indirect pointer to maybe-indirect pointer" {