* gcc.dg/guality/guality.exp: Skip on AIX.
[official-gcc.git] / libgo / go / net / fd_posix_test.go
blob8be0335d61ce228bc9384c3fceeab60cc2883a04
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
7 package net
9 import (
10 "testing"
11 "time"
14 var deadlineSetTimeTests = []struct {
15 input time.Time
16 expected int64
18 {time.Time{}, 0},
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 {
24 var d deadline
25 d.setTime(tt.input)
26 actual := d.value()
27 expected := int64(0)
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 {
38 deadline time.Time
39 expired bool
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 {
50 var d deadline
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)