From d103ed6ca97ca5a2669f6cf5fe4b3d2a9c945f26 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 17 May 2017 16:51:25 -0400 Subject: Upgrading server dependancies (#6431) --- vendor/github.com/hashicorp/hcl/decoder_test.go | 93 ++++++++++++++++--------- 1 file changed, 61 insertions(+), 32 deletions(-) (limited to 'vendor/github.com/hashicorp/hcl/decoder_test.go') diff --git a/vendor/github.com/hashicorp/hcl/decoder_test.go b/vendor/github.com/hashicorp/hcl/decoder_test.go index 480be4fa6..38363ad1b 100644 --- a/vendor/github.com/hashicorp/hcl/decoder_test.go +++ b/vendor/github.com/hashicorp/hcl/decoder_test.go @@ -9,7 +9,6 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/hashicorp/hcl/hcl/ast" - "github.com/hashicorp/hcl/testhelper" ) func TestDecode_interface(t *testing.T) { @@ -89,8 +88,7 @@ func TestDecode_interface(t *testing.T) { { "multiline_literal_with_hil.hcl", false, - map[string]interface{}{"multiline_literal_with_hil": testhelper.Unix2dos(`${hello - world}`)}, + map[string]interface{}{"multiline_literal_with_hil": "${hello\n world}"}, }, { "multiline_no_marker.hcl", @@ -100,22 +98,22 @@ func TestDecode_interface(t *testing.T) { { "multiline.hcl", false, - map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n")}, + map[string]interface{}{"foo": "bar\nbaz\n"}, }, { "multiline_indented.hcl", false, - map[string]interface{}{"foo": testhelper.Unix2dos(" bar\n baz\n")}, + map[string]interface{}{"foo": " bar\n baz\n"}, }, { "multiline_no_hanging_indent.hcl", false, - map[string]interface{}{"foo": testhelper.Unix2dos(" baz\n bar\n foo\n")}, + map[string]interface{}{"foo": " baz\n bar\n foo\n"}, }, { "multiline_no_eof.hcl", false, - map[string]interface{}{"foo": testhelper.Unix2dos("bar\nbaz\n"), "key": "value"}, + map[string]interface{}{"foo": "bar\nbaz\n", "key": "value"}, }, { "multiline.json", @@ -421,31 +419,32 @@ func TestDecode_interface(t *testing.T) { } for _, tc := range cases { - t.Logf("Testing: %s", tc.File) - d, err := ioutil.ReadFile(filepath.Join(fixtureDir, tc.File)) - if err != nil { - t.Fatalf("err: %s", err) - } - - var out interface{} - err = Decode(&out, string(d)) - if (err != nil) != tc.Err { - t.Fatalf("Input: %s\n\nError: %s", tc.File, err) - } - - if !reflect.DeepEqual(out, tc.Out) { - t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out) - } - - var v interface{} - err = Unmarshal(d, &v) - if (err != nil) != tc.Err { - t.Fatalf("Input: %s\n\nError: %s", tc.File, err) - } - - if !reflect.DeepEqual(v, tc.Out) { - t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out) - } + t.Run(tc.File, func(t *testing.T) { + d, err := ioutil.ReadFile(filepath.Join(fixtureDir, tc.File)) + if err != nil { + t.Fatalf("err: %s", err) + } + + var out interface{} + err = Decode(&out, string(d)) + if (err != nil) != tc.Err { + t.Fatalf("Input: %s\n\nError: %s", tc.File, err) + } + + if !reflect.DeepEqual(out, tc.Out) { + t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out) + } + + var v interface{} + err = Unmarshal(d, &v) + if (err != nil) != tc.Err { + t.Fatalf("Input: %s\n\nError: %s", tc.File, err) + } + + if !reflect.DeepEqual(v, tc.Out) { + t.Fatalf("Input: %s. Actual, Expected.\n\n%#v\n\n%#v", tc.File, out, tc.Out) + } + }) } } @@ -809,6 +808,36 @@ func TestDecode_intString(t *testing.T) { } } +func TestDecode_float32(t *testing.T) { + var value struct { + A float32 `hcl:"a"` + } + + err := Decode(&value, testReadFile(t, "float.hcl")) + if err != nil { + t.Fatalf("err: %s", err) + } + + if got, want := value.A, float32(1.02); got != want { + t.Fatalf("wrong result %#v; want %#v", got, want) + } +} + +func TestDecode_float64(t *testing.T) { + var value struct { + A float64 `hcl:"a"` + } + + err := Decode(&value, testReadFile(t, "float.hcl")) + if err != nil { + t.Fatalf("err: %s", err) + } + + if got, want := value.A, float64(1.02); got != want { + t.Fatalf("wrong result %#v; want %#v", got, want) + } +} + func TestDecode_intStringAliased(t *testing.T) { var value struct { Count time.Duration -- cgit v1.2.3-1-g7c22