37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package lexer_test
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestKeyWithoutAssignment(t *testing.T) {
|
|
err := "unexpected end of file"
|
|
runStatesTs(t, []statesT{
|
|
{"bare with whitespace", " a ", "[a]", err},
|
|
{"bare lower", "abcdefghijklmnopqrstuvwxyz", "[abcdefghijklmnopqrstuvwxyz]", err},
|
|
{"bare upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]", err},
|
|
{"bare numbers", "0123456789", "[0123456789]", err},
|
|
{"bare underscore", "_", "[_]", err},
|
|
{"bare dash", "-", "[-]", err},
|
|
{"bare big mix", "-hey_good_Lookin123-", "[-hey_good_Lookin123-]", err},
|
|
})
|
|
}
|
|
|
|
func TestDottedKey(t *testing.T) {
|
|
err := "unexpected end of file"
|
|
runStatesTs(t, []statesT{
|
|
{"bare dotted", "a._.c", "[a].[_].[c]", err},
|
|
{"bare dotted with whitespace", " a .\t\t b\t ", "[a].[b]", err},
|
|
})
|
|
}
|
|
|
|
func TestKeyWithAssignmentButNoValue(t *testing.T) {
|
|
err := "unexpected end of file"
|
|
runStatesTs(t, []statesT{
|
|
{"bare", "a=", "[a]=", err},
|
|
{"double equal sign", "a==", "[a]=", "unexpected character '=' (expected a value)"},
|
|
{"bare dotted", "a.b=", "[a].[b]=", err},
|
|
{"bare dotted with whitespace", " a .\tb\t = ", "[a].[b]=", err},
|
|
})
|
|
}
|