Skip to content

Commit

Permalink
Cleanup, and fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
phliar committed Dec 14, 2017
1 parent 39532e9 commit 483d6c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions entity_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ func parensBalanced(s string) bool {
var ssize uint
for i := 0; i < len(s); i++ {
if s[i] == '(' {
ssize += 1
ssize++
} else if s[i] == ')' {
if ssize == 0 {
// Extra right paren
return false
}
ssize -= 1
ssize--
}
}
// Stack must be empty
Expand Down
12 changes: 6 additions & 6 deletions entity_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,12 @@ func TestParensBalanced(t *testing.T) {
assert.True(t, parensBalanced(""))
assert.True(t, parensBalanced("()(()(()(()()))())()()"))

assert.True(t, !parensBalanced("("))
assert.True(t, !parensBalanced(")"))
assert.True(t, !parensBalanced("(()"))
assert.True(t, !parensBalanced(")("))
assert.True(t, !parensBalanced("(()))"))
assert.True(t, !parensBalanced("((()())"))
assert.False(t, parensBalanced("("))
assert.False(t, parensBalanced(")"))
assert.False(t, parensBalanced("(()"))
assert.False(t, parensBalanced(")("))
assert.False(t, parensBalanced("(()))"))
assert.False(t, parensBalanced("((()())"))
}

/*
Expand Down
2 changes: 1 addition & 1 deletion finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestParser(t *testing.T) {

assert.Equal(t, len(expectedEntities)+len(entitiesExcludedForTest), len(entities), fmt.Sprintf("%s", entities))
// TODO(jzhan): remove the hard-coded number of errors.
assert.Equal(t, 21, len(errs), fmt.Sprintf("%v", errs))
assert.Equal(t, 22, len(errs), fmt.Sprintf("%v", errs))
assert.Nil(t, err)

for _, entity := range entities {
Expand Down

0 comments on commit 483d6c9

Please sign in to comment.