zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d97981f6fd4e98506404de4259230dc157cc50dd (tree)
parent cab1d5c1a320239af5be88571d7989ba230b90be
Author: LemonBoy <thatlemon@gmail.com>
Date:   Sun, 11 Apr 2021 18:38:04 +0200

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

Diffstat:
Mtest/stage1/behavior/cast.zig | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig @@ -17,14 +17,15 @@ test "integer literal to pointer cast" { } test "pointer reinterpret const float to int" { - // https://github.com/ziglang/zig/issues/3345 - if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest; - + // The hex representation is 0x3fe3333333333303. const float: f64 = 5.99999999999994648725e-01; const float_ptr = &float; const int_ptr = @ptrCast(*const i32, float_ptr); const int_val = int_ptr.*; - expect(int_val == 858993411); + if (std.builtin.endian == .Little) + expect(int_val == 0x33333303) + else + expect(int_val == 0x3fe33333); } test "implicitly cast indirect pointer to maybe-indirect pointer" {