Files
eval/tokenKind_test.go
zeekay 011df15db5 eval: expression evaluator forked from casbin/govaluate v1.3.0
Module path renamed to github.com/hanzoai/eval and the Go package
renamed from govaluate to eval. Evaluation, parsing, lexing, and
operator behavior are unchanged; MIT license and George Lester
attribution retained. See NOTICE for lineage.
2026-07-18 00:27:32 -07:00

48 lines
857 B
Go

package eval
import (
"testing"
)
/*
Tests to make sure that all the different token kinds have different string representations
Gotta get that 95% code coverage yall. That's why tests like this get written; over-reliance on bad metrics.
*/
func TestTokenKindStrings(test *testing.T) {
var kindStrings []string
var kindString string
kinds := []TokenKind{
UNKNOWN,
PREFIX,
NUMERIC,
BOOLEAN,
STRING,
PATTERN,
TIME,
VARIABLE,
COMPARATOR,
LOGICALOP,
MODIFIER,
CLAUSE,
CLAUSE_CLOSE,
TERNARY,
}
for _, kind := range kinds {
kindString = kind.String()
for _, extantKind := range kindStrings {
if extantKind == kindString {
test.Logf("Token kind test found duplicate string for token kind %v ('%v')\n", kind, kindString)
test.Fail()
return
}
}
kindStrings = append(kindStrings, kindString)
}
}