Skip to content

Commit

Permalink
Add time.Time encoding/decoding test.
Browse files Browse the repository at this point in the history
It's not clear this is actually the best way to handle time.Time,
since there is a standard yaml format that may not match time.Time's,
but having tests ensuring the current behavior is basically sane
is a good idea nevertheless.
  • Loading branch information
niemeyer committed Feb 24, 2015
1 parent a1c4bcb commit 50f7813
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ var unmarshalTests = []struct {
"a: 1.2.3.4\n",
map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)},
},
{
"a: 2015-02-24T15:19:39-03:00\n",
map[string]time.Time{"a": time.Unix(1424801979, 0)},
},

// Encode empty lists as zero-length slices.
{
Expand Down
4 changes: 4 additions & 0 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ var marshalTests = []struct {
map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)},
"a: 1.2.3.4\n",
},
{
map[string]time.Time{"a": time.Unix(1424801979, 0)},
"a: 2015-02-24T15:19:39-03:00\n",
},

// Ensure strings containing ": " are quoted (reported as PR #43, but not reproducible).
{
Expand Down

0 comments on commit 50f7813

Please sign in to comment.