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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « go/util/util.go ('k') | webtry/go/webtry/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package util 1 package util
2 2
3 import ( 3 import (
4 "bytes"
5 "io"
4 "regexp" 6 "regexp"
5 "sort" 7 "sort"
6 "testing" 8 "testing"
7 9
8 assert "github.com/stretchr/testify/require" 10 assert "github.com/stretchr/testify/require"
9 ) 11 )
10 12
11 func TestAtMost(t *testing.T) { 13 func TestAtMost(t *testing.T) {
12 a := AtMost([]string{"a", "b"}, 3) 14 a := AtMost([]string{"a", "b"}, 3)
13 if got, want := len(a), 2; got != want { 15 if got, want := len(a), 2; got != want {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 "abcdefgh": false, 206 "abcdefgh": false,
205 "defg1234": true, 207 "defg1234": true,
206 "cdefg123": false, 208 "cdefg123": false,
207 "abc.xyz": true, 209 "abc.xyz": true,
208 "abcqxyz": false, 210 "abcqxyz": false,
209 } 211 }
210 for s, e := range tc { 212 for s, e := range tc {
211 assert.Equal(t, e, AnyMatch(slice, s)) 213 assert.Equal(t, e, AnyMatch(slice, s))
212 } 214 }
213 } 215 }
216
217 func TestIsNil(t *testing.T) {
218 assert.True(t, IsNil(nil))
219 assert.False(t, IsNil(false))
220 assert.False(t, IsNil(0))
221 assert.False(t, IsNil(""))
222 assert.False(t, IsNil([0]int{}))
223 type Empty struct{}
224 assert.False(t, IsNil(Empty{}))
225 assert.True(t, IsNil(chan interface{}(nil)))
226 assert.False(t, IsNil(make(chan interface{})))
227 var f func()
228 assert.True(t, IsNil(f))
229 assert.False(t, IsNil(func() {}))
230 assert.True(t, IsNil(map[bool]bool(nil)))
231 assert.False(t, IsNil(make(map[bool]bool)))
232 assert.True(t, IsNil([]int(nil)))
233 assert.False(t, IsNil([][]int{nil}))
234 assert.True(t, IsNil((*int)(nil)))
235 var i int
236 assert.False(t, IsNil(&i))
237 var pi *int
238 assert.True(t, IsNil(pi))
239 assert.True(t, IsNil(&pi))
240 var ppi **int
241 assert.True(t, IsNil(&ppi))
242 var c chan interface{}
243 assert.True(t, IsNil(&c))
244 var w io.Writer
245 assert.True(t, IsNil(w))
246 w = (*bytes.Buffer)(nil)
247 assert.True(t, IsNil(w))
248 w = &bytes.Buffer{}
249 assert.False(t, IsNil(w))
250 assert.False(t, IsNil(&w))
251 var ii interface{}
252 ii = &pi
253 assert.True(t, IsNil(ii))
254 }
OLDNEW
« 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