Ejemplo n.º 1
0
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)
		}
	}
}
Ejemplo n.º 2
0
func BenchmarkEmptyTime(b *testing.B) {
	for n := 0; n < b.N; n++ {
		t := toki.NullTime{}
		t.UnmarshalJSON([]byte{'"', '"'})
	}
}
Ejemplo n.º 3
0
func BenchmarkNormalTime(b *testing.B) {
	for n := 0; n < b.N; n++ {
		t := toki.NullTime{}
		t.UnmarshalJSON([]byte{'1', '2', ':', '3', '0'})
	}
}
Ejemplo n.º 4
0
func BenchmarkNull(b *testing.B) {
	for n := 0; n < b.N; n++ {
		t := toki.NullTime{}
		t.UnmarshalJSON([]byte{'n', 'u', 'l', 'l'})
	}
}