1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/generics_union_dump_test.v

29 lines
525 B
V

union Convertor[T] {
value T
bytes [8]u8
}
fn test_conversion_works() {
a := Convertor[i64]{
value: 21474837714
}
$if little_endian {
assert unsafe { a.bytes } == [u8(210), 4, 0, 0, 5, 0, 0, 0]!
}
}
fn test_dumping_of_a_generic_union_value() {
dump(Convertor[u8]{
bytes: [u8(210), 4, 0, 0, 5, 0, 0, 0]!
})
dump(Convertor[i16]{
bytes: [u8(210), 4, 0, 0, 5, 0, 0, 0]!
})
dump(Convertor[int]{
bytes: [u8(210), 4, 0, 0, 5, 0, 0, 0]!
})
dump(Convertor[i64]{
bytes: [u8(210), 4, 0, 0, 5, 0, 0, 0]!
})
}