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

Commit

Permalink
Test indentation on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Jan 3, 2018
1 parent 7dc50a3 commit 1a09f23
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func TestTakeLastComment(t *testing.T) {
}
}

func TestParseCommentWithEmptyLinesAndTripleSlash(t *testing.T) {
func TestParseCommentWithEmptyLinesIndentAndTripleSlash(t *testing.T) {
proto := `
// comment 1
// comment 2
//
// comment 3
/// comment 4`
// comment 1
// comment 2
//
// comment 3
/// comment 4`
p := newParserOn(proto)
def, err := p.Parse()
if err != nil {
Expand Down Expand Up @@ -111,6 +111,38 @@ comment 3
if got, want := len(def.Elements[0].(*Comment).Lines), 6; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
if got, want := def.Elements[0].(*Comment).Lines[3], "comment 3"; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
if got, want := def.Elements[0].(*Comment).Lines[4], " comment 4"; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
}

func TestParseCStyleCommentWithIndent(t *testing.T) {
t.Skip("See https://github.com/emicklei/proto/issues/53")
proto := `
/*comment 1
comment 2
comment 3
comment 4
*/`
p := newParserOn(proto)
def, err := p.Parse()
if err != nil {
t.Fatal(err)
}
if got, want := len(def.Elements), 1; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}

if got, want := len(def.Elements[0].(*Comment).Lines), 6; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
if got, want := def.Elements[0].(*Comment).Lines[3], "comment 3"; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
if got, want := def.Elements[0].(*Comment).Lines[4], " comment 4"; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
Expand Down

0 comments on commit 1a09f23

Please sign in to comment.