github.com/songzhibin97/gkit@v1.2.13/parser/parse_go/model_test.go (about)

     1  package parse_go
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestGoParsePB_GeneratePB(t *testing.T) {
     8  	rr, err := ParseGo(
     9  		"/Users/songzhibin/go/src/Songzhibin/gkit/parse/demo/demo.api", AddParseFunc(parseDoc), AddParseStruct(parseTag))
    10  	if err != nil {
    11  		panic(err)
    12  	}
    13  	r := rr.(*GoParsePB)
    14  	for _, note := range r.Note {
    15  		t.Log(note.Text, note.Pos(), note.End())
    16  	}
    17  	t.Log(r.Generate())
    18  }
    19  
    20  func TestGoParsePB_PileDriving(t *testing.T) {
    21  	rr, err := ParseGo("/Users/songzhibin/go/src/Songzhibin/gkit/parse/demo/demo.api")
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	r := rr.(*GoParsePB)
    26  	t.Log(r.PileDismantle("var _ = 1"))
    27  }
    28  
    29  func Test_checkRepeat(t *testing.T) {
    30  	test := `type Demo struct {
    31      MapField        map[string]int
    32      SliceField      []int
    33  	StringField     string
    34  	Uint32Field     uint32 
    35  	// 注释1
    36      // 注释1.1
    37  
    38      // 注释1.2
    39  	InterfaceField  interface{}
    40  	InterField      Inter
    41  	EmptyField
    42  }`
    43  	t.Log(checkRepeat("// 注释1", test))
    44  }