Add some test cases
Tim Hockin
2 years ago
494 | 494 | Complex6: 6i, |
495 | 495 | }, |
496 | 496 | exp: `{"complex1":"(0+1i)","-":"(0+3i)","complex4":"(0+4i)","Complex5":"(0+5i)","Complex6":"(0+6i)"}`, |
497 | }, { | |
498 | val: TjsontagsComplex{}, | |
499 | exp: `{"complex1":"(0+0i)","-":"(0+0i)","Complex5":"(0+0i)"}`, | |
500 | }, { | |
501 | val: TjsontagsPtr{ | |
502 | Ptr1: newStr("1"), | |
503 | Ptr2: newStr("2"), | |
504 | Ptr3: newStr("3"), | |
505 | Ptr4: newStr("4"), | |
506 | Ptr5: newStr("5"), | |
507 | Ptr6: newStr("6"), | |
508 | }, | |
509 | }, { | |
510 | val: TjsontagsPtr{}, | |
511 | }, { | |
512 | val: TjsontagsArray{ | |
513 | Array1: [2]string{"v1", "v1"}, | |
514 | Array2: [2]string{"v2", "v2"}, | |
515 | Array3: [2]string{"v3", "v3"}, | |
516 | Array4: [2]string{"v4", "v4"}, | |
517 | Array5: [2]string{"v5", "v5"}, | |
518 | Array6: [2]string{"v6", "v6"}, | |
519 | }, | |
520 | }, { | |
521 | val: TjsontagsArray{}, | |
522 | }, { | |
523 | val: TjsontagsSlice{ | |
524 | Slice1: []string{"v1", "v1"}, | |
525 | Slice2: []string{"v2", "v2"}, | |
526 | Slice3: []string{"v3", "v3"}, | |
527 | Slice4: []string{"v4", "v4"}, | |
528 | Slice5: []string{"v5", "v5"}, | |
529 | Slice6: []string{"v6", "v6"}, | |
530 | }, | |
531 | }, { | |
532 | val: TjsontagsSlice{}, | |
533 | exp: `{"slice1":[],"-":[],"Slice5":[]}`, | |
534 | }, { | |
535 | val: TjsontagsMap{ | |
536 | Map1: map[string]string{"k1": "v1"}, | |
537 | Map2: map[string]string{"k2": "v2"}, | |
538 | Map3: map[string]string{"k3": "v3"}, | |
539 | Map4: map[string]string{"k4": "v4"}, | |
540 | Map5: map[string]string{"k5": "v5"}, | |
541 | Map6: map[string]string{"k6": "v6"}, | |
542 | }, | |
543 | }, { | |
544 | val: TjsontagsMap{}, | |
545 | exp: `{"map1":{},"-":{},"Map5":{}}`, | |
546 | }, { | |
547 | val: Tembedstruct{}, | |
548 | }, { | |
549 | val: Tembednonstruct{}, | |
550 | exp: `{"Tinnerint":0,"Tinnermap":{},"Tinnerslice":[]}`, | |
551 | }, { | |
552 | val: Tembedjsontags{}, | |
553 | }, { | |
554 | val: PseudoStruct(makeKV("f1", 1, "f2", true, "f3", []int{})), | |
555 | exp: `{"f1":1,"f2":true,"f3":[]}`, | |
556 | }, { | |
557 | val: map[TjsontagsString]int{ | |
558 | {String1: `"quoted"`, String4: `unquoted`}: 1, | |
559 | }, | |
560 | exp: `{"{\"string1\":\"\\\"quoted\\\"\",\"-\":\"\",\"string4\":\"unquoted\",\"String5\":\"\"}":1}`, | |
561 | }, { | |
562 | val: map[TjsontagsInt]int{ | |
563 | {Int1: 1, Int2: 2}: 3, | |
564 | }, | |
565 | exp: `{"{\"int1\":1,\"-\":0,\"Int5\":0}":3}`, | |
566 | }, { | |
567 | val: map[[2]struct{ S string }]int{ | |
568 | {{S: `"quoted"`}, {S: "unquoted"}}: 1, | |
569 | }, | |
570 | exp: `{"[{\"S\":\"\\\"quoted\\\"\"},{\"S\":\"unquoted\"}]":1}`, | |
497 | 571 | }, { |
498 | 572 | val: TjsontagsComplex{}, |
499 | 573 | exp: `{"complex1":"(0+0i)","-":"(0+0i)","Complex5":"(0+0i)"}`, |