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

Commit

Permalink
Add c-style comment testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Jan 3, 2018
1 parent ecc9dd0 commit d1aad87
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ package proto
import (
"testing"
"text/scanner"

"github.com/davecgh/go-spew/spew"
)

var startPosition = scanner.Position{Line: 1, Column: 1}
Expand Down Expand Up @@ -91,6 +93,32 @@ func TestParseCommentWithEmptyLinesAndTripleSlash(t *testing.T) {
}
}

func TestParseCStyleComment(t *testing.T) {
proto := `
/*comment 1
comment 2
comment 3
comment 4
*/`
p := newParserOn(proto)
def, err := p.Parse()
if err != nil {
t.Fatal(err)
}
spew.Dump(def)
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[4], " comment 4"; got != want {
t.Fatalf("got [%v] want [%v]", got, want)
}
}

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

0 comments on commit d1aad87

Please sign in to comment.