v2 / vlib / v / tests / comptime / comptime_voidptr_unsafe_nil_test.v
16 lines · 15 sloc · 242 bytes · b68897c6d7b13254a41f827e3c8b91b48705459c
Raw
1fn encode[T](t T) {
2 $if T is voidptr {
3 assert true
4 } $else $if T is $pointer {
5 if voidptr(t) == unsafe { nil } {
6 assert false
7 }
8 }
9}
10
11// vfmt off
12fn test_main() {
13 encode(unsafe { voidptr(0) })
14 encode(unsafe { nil })
15}
16// vfmt on
17