hcl/lex_test.go

38 lines
404 B
Go
Raw Normal View History

2014-07-31 20:56:51 +00:00
package hcl
import (
"testing"
)
2014-08-01 19:54:53 +00:00
func TestLexMode(t *testing.T) {
2014-07-31 20:56:51 +00:00
cases := []struct {
2014-08-01 19:54:53 +00:00
Input string
Mode lexModeValue
2014-07-31 20:56:51 +00:00
}{
2014-09-15 16:40:47 +00:00
{
"",
lexModeHcl,
},
2014-07-31 20:56:51 +00:00
{
2014-08-01 19:54:53 +00:00
"foo",
lexModeHcl,
2014-07-31 20:56:51 +00:00
},
2014-08-01 01:44:21 +00:00
{
2014-08-01 19:54:53 +00:00
"{}",
lexModeJson,
2014-08-01 01:44:21 +00:00
},
{
2014-08-01 19:54:53 +00:00
" {}",
lexModeJson,
2014-07-31 20:56:51 +00:00
},
}
2014-08-01 19:54:53 +00:00
for i, tc := range cases {
actual := lexMode([]byte(tc.Input))
2014-07-31 20:56:51 +00:00
2014-08-01 19:54:53 +00:00
if actual != tc.Mode {
t.Fatalf("%d: %#v", i, actual)
2014-07-31 20:56:51 +00:00
}
}
}