mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
31 lines
587 B
Zig
31 lines
587 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
const expect = std.testing.expect;
|
|
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 expect(f == a);
|
|
}
|
|
|
|
test "implicit unsigned integer to signed integer" {
|
|
const a: u8 = 250;
|
|
const b: i16 = a;
|
|
try expect(b == 250);
|
|
}
|
|
|
|
test "float widening" {
|
|
const a: f16 = 12.34;
|
|
const b: f32 = a;
|
|
const c: f64 = b;
|
|
const d: f128 = c;
|
|
try expect(d == a);
|
|
}
|
|
|
|
// test
|