]> Cypherpunks.ru repositories - gostls13.git/commitdiff
context: add test for WithDeadline in the past
authorJack Lindamood <jlindamo@justin.tv>
Fri, 15 Jul 2016 20:28:27 +0000 (13:28 -0700)
committerSameer Ajmani <sameer@golang.org>
Tue, 26 Jul 2016 14:53:38 +0000 (14:53 +0000)
Adds a test case for calling context.WithDeadline() where the deadline
exists in the past.  This change increases the code coverage of the
context package.

Change-Id: Ib486bf6157e779fafd9dab2b7364cdb5a06be36e
Reviewed-on: https://go-review.googlesource.com/25007
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Run-TryBot: Sameer Ajmani <sameer@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/context/context_test.go

index 90e78e57ecc42e83623587c5c8dc9a2204ea3df0..cf182110fbdf9b7409b40cfa2efdfe1660c4f248 100644 (file)
@@ -255,6 +255,12 @@ func TestDeadline(t *testing.T) {
        o = otherContext{c}
        c, _ = WithDeadline(o, time.Now().Add(4*time.Second))
        testDeadline(c, "WithDeadline+otherContext+WithDeadline", 2*time.Second, t)
+
+       c, _ = WithDeadline(Background(), time.Now().Add(-time.Millisecond))
+       testDeadline(c, "WithDeadline+inthepast", time.Second, t)
+
+       c, _ = WithDeadline(Background(), time.Now())
+       testDeadline(c, "WithDeadline+now", time.Second, t)
 }
 
 func TestTimeout(t *testing.T) {