| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestTicker(t *testing.T) { |
| ticker := NewTicker(Delta) |
| for i := 0; i < Count; i++ { |
| target := int64(Delta * Count) |
| if ns < target-slop || ns > target+slop { |
| t.Fatalf("%d ticks of %g ns took %g ns, expected %g", Count, float64(Delta), float64(ns), float64(target)) |
| // Now test that the ticker stopped |
| _, received := <-ticker.C |
| t.Fatalf("Ticker did not shut down") |
| // Test that a bug tearing down a ticker has been fixed. This routine should not deadlock. |
| func TestTeardown(t *testing.T) { |