aboutsummaryrefslogtreecommitdiff
path: root/spec/test/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-05-29 15:55:53 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-05-29 15:55:53 +0900
commit1ebed922b8c642b6ff4cec71820f24ceeb331c18 (patch)
tree08b71e6330b418d3d263264193262f489bba29b5 /spec/test/parser_test.go
parentAdd vartan-test command (diff)
downloadcotia-1ebed922b8c642b6ff4cec71820f24ceeb331c18.tar.gz
cotia-1ebed922b8c642b6ff4cec71820f24ceeb331c18.tar.xz
Support testable tree output in vartan-parse command
Diffstat (limited to 'spec/test/parser_test.go')
-rw-r--r--spec/test/parser_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/test/parser_test.go b/spec/test/parser_test.go
index 6e77f6d..41b7189 100644
--- a/spec/test/parser_test.go
+++ b/spec/test/parser_test.go
@@ -7,6 +7,25 @@ import (
"testing"
)
+func TestTree_Format(t *testing.T) {
+ expected := `(a
+ (b
+ (c))
+ (d)
+ (e))`
+ tree := NewTree("a",
+ NewTree("b",
+ NewTree("c"),
+ ),
+ NewTree("d"),
+ NewTree("e"),
+ )
+ actual := string(tree.Format())
+ if actual != expected {
+ t.Fatalf("unexpected format:\n%v", actual)
+ }
+}
+
func TestDiffTree(t *testing.T) {
tests := []struct {
t1 *Tree