mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 08:24:49 +01:00
30 lines
606 B
Zig
30 lines
606 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
const expectEqual = std.testing.expectEqual;
|
|
const mem = std.mem;
|
|
|
|
test "integer widening" {
|
|
const a: u8 = 250;
|
|
const b: u16 = a;
|
|
const c: u32 = b;
|
|
const d: u64 = c;
|
|
const e: u64 = d;
|
|
const f: u128 = e;
|
|
try expectEqual(f, a);
|
|
}
|
|
|
|
test "implicit unsigned integer to signed integer" {
|
|
const a: u8 = 250;
|
|
const b: i16 = a;
|
|
try expectEqual(250, b);
|
|
}
|
|
|
|
test "float widening" {
|
|
const a: f16 = 12.34;
|
|
const b: f32 = a;
|
|
const c: f64 = b;
|
|
const d: f128 = c;
|
|
try expectEqual(d, a);
|
|
}
|
|
|
|
// test
|