@@ -199,6 +199,11 @@ func TestBasicStruct(t *testing.T) {
199
199
}
200
200
201
201
runTest (t , []* testCase {
202
+ {
203
+ v : struct {}{},
204
+ b : nil ,
205
+ name : "empty struct" ,
206
+ },
202
207
{
203
208
v : MyStruct {
204
209
Boolean : true ,
@@ -338,9 +343,7 @@ func TestMap(t *testing.T) {
338
343
type Option0 struct {
339
344
Data uint32
340
345
}
341
- type Option1 struct {
342
- Data uint64
343
- }
346
+ type Option1 struct {}
344
347
type Option2 bool
345
348
type isOption interface {
346
349
isOption ()
@@ -350,7 +353,7 @@ type Option struct {
350
353
}
351
354
352
355
func (* Option0 ) isOption () {}
353
- func (* Option1 ) isOption () {}
356
+ func (Option1 ) isOption () {}
354
357
func (Option2 ) isOption () {}
355
358
func (* Option ) EnumTypes () []EnumVariant {
356
359
return []EnumVariant {
@@ -362,7 +365,7 @@ func (*Option) EnumTypes() []EnumVariant {
362
365
{
363
366
Name : "option" ,
364
367
Value : 1 ,
365
- Template : ( * Option1 )( nil ) ,
368
+ Template : Option1 {} ,
366
369
},
367
370
{
368
371
Name : "option" ,
@@ -379,28 +382,28 @@ func TestEnum(t *testing.T) {
379
382
Option : & Option0 {5 },
380
383
},
381
384
b : hexMustDecode ("0000 0000 0500 0000" ),
382
- name : "ptr to struct with ptr interface 0 " ,
385
+ name : "ptr to struct with ptr enum variant " ,
383
386
},
384
387
{
385
388
v : & Option {
386
- Option : & Option1 {6 },
389
+ Option : Option1 {},
387
390
},
388
- b : hexMustDecode ("0100 0000 0600 0000 0000 0000 " ),
389
- name : "ptr to struct with ptr interface 1 " ,
391
+ b : hexMustDecode ("0100 0000" ),
392
+ name : "ptr to struct with non- ptr empty variant " ,
390
393
},
391
394
{
392
395
v : & Option {
393
396
Option : Option2 (true ),
394
397
},
395
398
b : hexMustDecode ("0200 0000 01" ),
396
- name : "ptr to struct with real value as interface " ,
399
+ name : "ptr to struct with real value as enum variant " ,
397
400
},
398
401
{
399
402
v : Option {
400
- Option : & Option1 {6 },
403
+ Option : Option1 {},
401
404
},
402
- b : hexMustDecode ("0100 0000 0600 0000 0000 0000 " ),
403
- name : "struct with enum with real struct interface " ,
405
+ b : hexMustDecode ("0100 0000" ),
406
+ name : "non-ptr struct with variant " ,
404
407
},
405
408
})
406
409
}
@@ -419,7 +422,7 @@ func (*Wrapper) EnumTypes() []EnumVariant {
419
422
{
420
423
Name : "option" ,
421
424
Value : 1 ,
422
- Template : ( * Option1 )( nil ) ,
425
+ Template : Option1 {} ,
423
426
},
424
427
{
425
428
Name : "option" ,
@@ -435,11 +438,11 @@ func TestEnumSlice(t *testing.T) {
435
438
v : & Wrapper {
436
439
Option : []isOption {
437
440
& Option0 {5 },
438
- & Option1 {6 },
441
+ Option1 {},
439
442
Option2 (true ),
440
443
},
441
444
},
442
- b : hexMustDecode ("03000000 00000000 05000000 01000000 0600000000000000 02000000 01" ),
445
+ b : hexMustDecode ("03000000 00000000 05000000 01000000 02000000 01" ),
443
446
name : "enum slice" ,
444
447
},
445
448
})
0 commit comments