Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: go/util/util_test.go

Issue 1300273002: Reland of Add a library for running external commands, providing timeouts and test injection. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Fix squashWriters for struct arguments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/util/util.go ('k') | webtry/go/webtry/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/util/util_test.go
diff --git a/go/util/util_test.go b/go/util/util_test.go
index bdf3007d10bc144caac55d97ab48ee9947d03255..8706c54cff30287058b80eafe2ace220913dd9eb 100644
--- a/go/util/util_test.go
+++ b/go/util/util_test.go
@@ -1,6 +1,8 @@
package util
import (
+ "bytes"
+ "io"
"regexp"
"sort"
"testing"
@@ -211,3 +213,42 @@ func TestAnyMatch(t *testing.T) {
assert.Equal(t, e, AnyMatch(slice, s))
}
}
+
+func TestIsNil(t *testing.T) {
+ assert.True(t, IsNil(nil))
+ assert.False(t, IsNil(false))
+ assert.False(t, IsNil(0))
+ assert.False(t, IsNil(""))
+ assert.False(t, IsNil([0]int{}))
+ type Empty struct{}
+ assert.False(t, IsNil(Empty{}))
+ assert.True(t, IsNil(chan interface{}(nil)))
+ assert.False(t, IsNil(make(chan interface{})))
+ var f func()
+ assert.True(t, IsNil(f))
+ assert.False(t, IsNil(func() {}))
+ assert.True(t, IsNil(map[bool]bool(nil)))
+ assert.False(t, IsNil(make(map[bool]bool)))
+ assert.True(t, IsNil([]int(nil)))
+ assert.False(t, IsNil([][]int{nil}))
+ assert.True(t, IsNil((*int)(nil)))
+ var i int
+ assert.False(t, IsNil(&i))
+ var pi *int
+ assert.True(t, IsNil(pi))
+ assert.True(t, IsNil(&pi))
+ var ppi **int
+ assert.True(t, IsNil(&ppi))
+ var c chan interface{}
+ assert.True(t, IsNil(&c))
+ var w io.Writer
+ assert.True(t, IsNil(w))
+ w = (*bytes.Buffer)(nil)
+ assert.True(t, IsNil(w))
+ w = &bytes.Buffer{}
+ assert.False(t, IsNil(w))
+ assert.False(t, IsNil(&w))
+ var ii interface{}
+ ii = &pi
+ assert.True(t, IsNil(ii))
+}
« no previous file with comments | « go/util/util.go ('k') | webtry/go/webtry/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698