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