Commit 16134060 authored by Shawn Smith's avatar Shawn Smith Committed by Brad Fitzpatrick

time: add tests for Tick, NewTicker with negative duration

R=golang-codereviews, gobot, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/37660044
parent 232a4e89
......@@ -48,6 +48,24 @@ func TestTeardown(t *testing.T) {
}
}
// Test the Tick convenience wrapper.
func TestTick(t *testing.T) {
// Test that giving a negative duration returns nil.
if got := Tick(-1); got != nil {
t.Errorf("Tick(-1) = %v; want nil", got)
}
}
// Test that NewTicker panics when given a duration less than zero.
func TestNewTickerLtZeroDuration(t *testing.T) {
defer func() {
if err := recover(); err == nil {
t.Errorf("NewTicker(-1) should have panicked")
}
}()
NewTicker(-1)
}
func BenchmarkTicker(b *testing.B) {
ticker := NewTicker(1)
b.ResetTimer()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment