github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/dump/test/level_2_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 "github.com/v2pro/plz/test" 6 "github.com/v2pro/plz/countlog" 7 "github.com/v2pro/plz/test/must" 8 "github.com/v2pro/plz/dump" 9 ) 10 11 func Test_level2(t *testing.T) { 12 t.Run("slice of string", test.Case(func(ctx *countlog.Context) { 13 must.JsonEqual(`{ 14 "__root__": { 15 "type": "[]string", 16 "data": { 17 "__ptr__": "{ptr1}" 18 } 19 }, 20 "{ptr1}": { 21 "data": { 22 "__ptr__": "{ptr2}" 23 }, 24 "len": 2, 25 "cap": 2 26 }, 27 "{ptr2}": [ 28 { 29 "data": { 30 "__ptr__": "{ptr3}" 31 }, 32 "len": 5 33 }, 34 { 35 "data": { 36 "__ptr__": "{ptr4}" 37 }, 38 "len": 5 39 } 40 ], 41 "{ptr3}": "hello", 42 "{ptr4}": "world"}`, dump.Var{[]string{ 43 "hello", 44 "world", 45 }}.String()) 46 })) 47 }