Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Add test for inline c-style comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Jan 4, 2018
1 parent fdeb2dd commit 27c0909
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,38 @@ func TestParseCStyleOneLineComment(t *testing.T) {
}
}

func TestParseCStyleInlineComment(t *testing.T) {
proto := `message Foo {
int64 hello = 1; /*
comment 1
*/
}`
p := newParserOn(proto)
def := new(Proto)
err := def.parse(p)
if err != nil {
t.Fatal(err)
}
m := def.Elements[0].(*Message)
if len(m.Elements) != 1 {
t.Fatal("expected one element", m.Elements)
}
f := m.Elements[0].(*NormalField)
comment := f.InlineComment
if comment == nil {
t.Fatal("no inline comment")
}
if got, want := len(comment.Lines), 3; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
if got, want := comment.Lines[0], "/*"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := comment.Cstyle, true; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
}

func TestParseCommentWithTripleSlash(t *testing.T) {
proto := `
/// comment 1
Expand Down

0 comments on commit 27c0909

Please sign in to comment.