func TestMarshalNullJSON(t *testing.T) { for given, expected := range jsonTable { time := toki.NullTime{} time.UnmarshalJSON([]byte(given)) data, err := json.Marshal(time) if err != nil { t.Errorf("MarshalJSON: error: %s", err) } result := string(data) if result != expected { t.Errorf("MarshalJSON: %s ≠ %s (%#v)", result, expected, time) } } }
func BenchmarkEmptyTime(b *testing.B) { for n := 0; n < b.N; n++ { t := toki.NullTime{} t.UnmarshalJSON([]byte{'"', '"'}) } }
func BenchmarkNormalTime(b *testing.B) { for n := 0; n < b.N; n++ { t := toki.NullTime{} t.UnmarshalJSON([]byte{'1', '2', ':', '3', '0'}) } }
func BenchmarkNull(b *testing.B) { for n := 0; n < b.N; n++ { t := toki.NullTime{} t.UnmarshalJSON([]byte{'n', 'u', 'l', 'l'}) } }