Skip to content

Commit be18410

Browse files
committed
test: add test for ast.go
1 parent ec09190 commit be18410

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ast_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package excelformulaparser
2+
3+
import "testing"
4+
5+
func TestPos(t *testing.T) {
6+
var p = Pos{Line: 1, Column: 2}
7+
if p.String() != "(1,2)" {
8+
t.Errorf("Expected '(1,2)', got '%s'", p.String())
9+
}
10+
p.nextLine()
11+
if p.String() != "(2,1)" {
12+
t.Errorf("Expected '(2,1)', got '%s'", p.String())
13+
}
14+
p.nextColumn()
15+
if p.String() != "(2,2)" {
16+
t.Errorf("Expected '(2,2)', got '%s'", p.String())
17+
}
18+
}
19+
20+
func TestIdent(t *testing.T) {
21+
var ident = IdentExpr{
22+
baseNode: newBaseNode(Pos{Line: 1, Column: 1}, Pos{Line: 1, Column: 4}),
23+
Name: newToken(Pos{Line: 1, Column: 1}, Pos{Line: 1, Column: 4}, Ident, "NAME"),
24+
}
25+
if ident.String() != "IdentExpr(Name: NAME)" {
26+
t.Errorf("Expected 'IdentExpr(Name: NAME)', got '%s'", ident.String())
27+
}
28+
}

0 commit comments

Comments
 (0)