github.com/goshafaq/sonic@v0.0.0-20231026082336-871835fb94c6/internal/resolver/resolver_test.go (about) 1 /* 2 * Copyright 2021 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package resolver 18 19 import ( 20 "reflect" 21 "testing" 22 ) 23 24 type bas struct { 25 Y int `json:"Y"` 26 } 27 28 type bat struct { 29 bas 30 } 31 32 type bau struct { 33 Y int 34 } 35 36 type bay struct { 37 Y int `json:"Y"` 38 } 39 40 type baz struct { 41 Y int `json:"W"` 42 } 43 44 type bar struct { 45 bat 46 bau 47 *bay 48 baz 49 } 50 51 type PackageError struct { 52 ImportStack []string 53 Pos string 54 Err error 55 IsImportCycle bool 56 Hard bool 57 alwaysPrintStack bool 58 Y *int 59 } 60 61 type Foo struct { 62 X int 63 *PackageError 64 bar 65 } 66 67 func TestResolver_ResolveStruct(t *testing.T) { 68 for _, fv := range ResolveStruct(reflect.TypeOf(Foo{})) { 69 println(fv.String()) 70 } 71 }