2799afc14b
The std encoding format is Unmarshal([]byte, interface{}) error. This naturally lends itself well to being passed readfile or exhausted reader/buffer.
38 lines
404 B
Go
38 lines
404 B
Go
package hcl
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestLexMode(t *testing.T) {
|
|
cases := []struct {
|
|
Input string
|
|
Mode lexModeValue
|
|
}{
|
|
{
|
|
"",
|
|
lexModeHcl,
|
|
},
|
|
{
|
|
"foo",
|
|
lexModeHcl,
|
|
},
|
|
{
|
|
"{}",
|
|
lexModeJson,
|
|
},
|
|
{
|
|
" {}",
|
|
lexModeJson,
|
|
},
|
|
}
|
|
|
|
for i, tc := range cases {
|
|
actual := lexMode([]byte(tc.Input))
|
|
|
|
if actual != tc.Mode {
|
|
t.Fatalf("%d: %#v", i, actual)
|
|
}
|
|
}
|
|
}
|