Просмотр исходного кода

Add time.Time encoding/decoding test.

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.
Gustavo Niemeyer 11 лет назад
Родитель
Сommit
50f7813e6b
2 измененных файлов с 8 добавлено и 0 удалено
  1. 4 0
      decode_test.go
  2. 4 0
      encode_test.go

+ 4 - 0
decode_test.go

@@ -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.
 	{

+ 4 - 0
encode_test.go

@@ -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).
 	{