v2 / vlib / v / tests / fns / variadic_voidptr_rvalue_test.v
15 lines · 13 sloc · 386 bytes · 927b23997afb45d960cdb4180dce2fa98b4609ee
Raw
1import strconv
2
3struct VariadicVoidptrValue {
4mut:
5 x u8
6}
7
8fn test_variadic_voidptr_rvalues_are_boxed_with_promotions() {
9 mut value := VariadicVoidptrValue{
10 x: 1
11 }
12 assert unsafe { strconv.v_sprintf('x=%02d', value.x) } == 'x=01'
13 assert unsafe { strconv.v_sprintf('x=%02d', int(value.x)) } == 'x=01'
14 assert unsafe { strconv.v_sprintf('%s %.1f', 'abc', f32(1.5)) } == 'abc 1.5'
15}
16