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