Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode string booleans #277

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
decoder test string decode
  • Loading branch information
langmartin committed Jun 10, 2019
commit 1804807358d86424faacbb42f50f0c04303cef11
22 changes: 22 additions & 0 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test-fixtures/string.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a = "s"
b = 2
c = 2.718
d = true
e = false