1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin freebsd linux netbsd openbsd windows
14 var deadlineSetTimeTests
= []struct {
19 {time
.Date(2009, 11, 10, 23, 00, 00, 00, time
.UTC
), 1257894000000000000}, // 2009-11-10 23:00:00 +0000 UTC
22 func TestDeadlineSetTime(t
*testing
.T
) {
23 for _
, tt
:= range deadlineSetTimeTests
{
28 if !tt
.input
.IsZero() {
29 expected
= tt
.input
.UnixNano()
31 if actual
!= expected
{
32 t
.Errorf("set/value failed: expected %v, actual %v", expected
, actual
)
37 var deadlineExpiredTests
= []struct {
41 // note, times are relative to the start of the test run, not
42 // the start of TestDeadlineExpired
43 {time
.Now().Add(5 * time
.Minute
), false},
44 {time
.Now().Add(-5 * time
.Minute
), true},
45 {time
.Time
{}, false}, // no deadline set
48 func TestDeadlineExpired(t
*testing
.T
) {
49 for _
, tt
:= range deadlineExpiredTests
{
51 d
.set(tt
.deadline
.UnixNano())
52 expired
:= d
.expired()
53 if expired
!= tt
.expired
{
54 t
.Errorf("expire failed: expected %v, actual %v", tt
.expired
, expired
)