zig/test/cases/cast.zig
Andrew Kelley af536ac343 introduce new test syntax
* remove setFnTest builtin
 * add test "name" { ... } syntax
 * remove --check-unused argument. functions are always lazy now.
2017-03-16 16:02:35 -04:00

22 lines
500 B
Zig

const assert = @import("std").debug.assert;
test "intToPtrCast" {
const x = isize(13);
const y = (&u8)(x);
const z = usize(y);
assert(z == 13);
}
test "numLitIntToPtrCast" {
const vga_mem = (&u16)(0xB8000);
assert(usize(vga_mem) == 0xB8000);
}
test "pointerReinterpretConstFloatToInt" {
const float: f64 = 5.99999999999994648725e-01;
const float_ptr = &float;
const int_ptr = (&i32)(float_ptr);
const int_val = *int_ptr;
assert(int_val == 858993411);
}