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 {
|
2016-03-01 04:44:10 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|