// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// t_term_test.go
package expr

import (
	"testing"
)

func TestString(t *testing.T) {
	tk1 := NewValueToken(0, 0, SymInteger, "100", 100)
	tk2 := NewToken(0, 0, SymPlus, "+")
	tk3 := NewValueToken(0, 0, SymInteger, "50", 500)

	tree := NewAst()
	if gotErr := tree.addTokens(tk1, tk2, tk3); gotErr == nil {
		t.Log("Tree:", tree)
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}

func TestGetRoom(t *testing.T) {
	tk1 := NewValueToken(0, 0, SymInteger, "100", 100)

	tree := NewAst()
	if gotErr := tree.addTokens(tk1); gotErr == nil {
		t.Log("Tree-root room:", tree.root.getRoom())
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}

func TestGetChildrenCount(t *testing.T) {
	tk1 := NewValueToken(0, 0, SymInteger, "100", 100)

	tree := NewAst()
	if gotErr := tree.addTokens(tk1); gotErr == nil {
		t.Log("Tree-root children count:", tree.root.getChildrenCount())
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}
