decoder test string decode

This commit is contained in:
Lang Martin 2019-06-10 12:16:27 -04:00
parent 1f63d5ffd6
commit 1804807358
2 changed files with 27 additions and 0 deletions

View File

@ -951,6 +951,28 @@ func TestDecode_float64(t *testing.T) {
}
}
func TestDecode_string(t *testing.T) {
type value struct {
A string `hcl:"a"`
B string `hcl:"b"`
C string `hcl:"c"`
D string `hcl:"d"`
E string `hcl:"e"`
}
got := value{}
err := Decode(&got, testReadFile(t, "string.hcl"))
if err != nil {
t.Fatal(err)
}
want := value{"s", "2", "2.718", "true", "false"}
if !reflect.DeepEqual(want, got) {
t.Fatalf("expected %#v; got %#v", want, got)
}
}
func TestDecode_intStringAliased(t *testing.T) {
var value struct {
Count time.Duration

5
test-fixtures/string.hcl Normal file
View File

@ -0,0 +1,5 @@
a = "s"
b = 2
c = 2.718
d = true
e = false