v2 / vlib / v / tests / c_structs / cstruct_fields_are_pub_test.c.v
26 lines · 23 sloc · 794 bytes · 5d6de17f708abcf79877f70e677d60a4e23bb727
Raw
1module main
2
3import fontstash
4
5fn test_c_struct_fields_are_pub() {
6 params := &C.FONSparams{
7 width: 512
8 height: 512
9 flags: 0
10 userPtr: unsafe { nil }
11 renderCreate: fn (uptr voidptr, width int, height int) int {
12 return 1
13 }
14 renderResize: fn (uptr voidptr, width int, height int) int {
15 return 1
16 }
17 renderUpdate: fn (uptr voidptr, rect &int, data &u8) {}
18 renderDraw: fn (uptr voidptr, verts &f32, tcoords &f32, colors &u32, nverts int) {}
19 renderDelete: fn (uptr voidptr) {}
20 }
21
22 context := fontstash.create_internal(params)
23 // After porting sfons/fontstash to V, C.FONScontext now has public fields
24 // so the string representation shows the fields instead of being empty
25 assert context.str().starts_with('fontstash.Context(C.FONScontext{')
26}
27