Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
7f9acb53
Commit
7f9acb53
authored
Mar 26, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: shorten some more tests
R=rsc CC=golang-dev
https://golang.org/cl/4314044
parent
d607cb28
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
89 additions
and
18 deletions
+89
-18
src/pkg/archive/tar/writer_test.go
src/pkg/archive/tar/writer_test.go
+3
-0
src/pkg/big/int_test.go
src/pkg/big/int_test.go
+9
-2
src/pkg/container/vector/numbers_test.go
src/pkg/container/vector/numbers_test.go
+9
-0
src/pkg/crypto/elliptic/elliptic_test.go
src/pkg/crypto/elliptic/elliptic_test.go
+3
-0
src/pkg/crypto/tls/handshake_messages_test.go
src/pkg/crypto/tls/handshake_messages_test.go
+5
-1
src/pkg/exp/eval/eval_test.go
src/pkg/exp/eval/eval_test.go
+6
-2
src/pkg/fmt/fmt_test.go
src/pkg/fmt/fmt_test.go
+3
-0
src/pkg/go/printer/printer_test.go
src/pkg/go/printer/printer_test.go
+5
-2
src/pkg/image/png/reader_test.go
src/pkg/image/png/reader_test.go
+11
-1
src/pkg/image/png/writer_test.go
src/pkg/image/png/writer_test.go
+5
-1
src/pkg/json/decode_test.go
src/pkg/json/decode_test.go
+1
-0
src/pkg/json/scanner_test.go
src/pkg/json/scanner_test.go
+20
-5
src/pkg/netchan/netchan_test.go
src/pkg/netchan/netchan_test.go
+1
-1
src/pkg/utf8/string_test.go
src/pkg/utf8/string_test.go
+8
-3
No files found.
src/pkg/archive/tar/writer_test.go
View file @
7f9acb53
...
@@ -150,5 +150,8 @@ testLoop:
...
@@ -150,5 +150,8 @@ testLoop:
t
.
Errorf
(
"test %d: Incorrect result: (-=expected, +=actual)
\n
%v"
,
t
.
Errorf
(
"test %d: Incorrect result: (-=expected, +=actual)
\n
%v"
,
i
,
bytediff
(
expected
,
actual
))
i
,
bytediff
(
expected
,
actual
))
}
}
if
testing
.
Short
()
{
// The second test is expensive.
break
}
}
}
}
}
src/pkg/big/int_test.go
View file @
7f9acb53
...
@@ -716,18 +716,25 @@ var composites = []string{
...
@@ -716,18 +716,25 @@ var composites = []string{
func
TestProbablyPrime
(
t
*
testing
.
T
)
{
func
TestProbablyPrime
(
t
*
testing
.
T
)
{
nreps
:=
20
if
testing
.
Short
()
{
nreps
=
1
}
for
i
,
s
:=
range
primes
{
for
i
,
s
:=
range
primes
{
p
,
_
:=
new
(
Int
)
.
SetString
(
s
,
10
)
p
,
_
:=
new
(
Int
)
.
SetString
(
s
,
10
)
if
!
ProbablyPrime
(
p
,
20
)
{
if
!
ProbablyPrime
(
p
,
nreps
)
{
t
.
Errorf
(
"#%d prime found to be non-prime (%s)"
,
i
,
s
)
t
.
Errorf
(
"#%d prime found to be non-prime (%s)"
,
i
,
s
)
}
}
}
}
for
i
,
s
:=
range
composites
{
for
i
,
s
:=
range
composites
{
c
,
_
:=
new
(
Int
)
.
SetString
(
s
,
10
)
c
,
_
:=
new
(
Int
)
.
SetString
(
s
,
10
)
if
ProbablyPrime
(
c
,
20
)
{
if
ProbablyPrime
(
c
,
nreps
)
{
t
.
Errorf
(
"#%d composite found to be prime (%s)"
,
i
,
s
)
t
.
Errorf
(
"#%d composite found to be prime (%s)"
,
i
,
s
)
}
}
if
testing
.
Short
()
{
break
}
}
}
}
}
...
...
src/pkg/container/vector/numbers_test.go
View file @
7f9acb53
...
@@ -33,6 +33,9 @@ func s(n uint64) string {
...
@@ -33,6 +33,9 @@ func s(n uint64) string {
func
TestVectorNums
(
t
*
testing
.
T
)
{
func
TestVectorNums
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
return
}
var
v
Vector
var
v
Vector
c
:=
int
(
0
)
c
:=
int
(
0
)
runtime
.
GC
()
runtime
.
GC
()
...
@@ -51,6 +54,9 @@ func TestVectorNums(t *testing.T) {
...
@@ -51,6 +54,9 @@ func TestVectorNums(t *testing.T) {
func
TestIntVectorNums
(
t
*
testing
.
T
)
{
func
TestIntVectorNums
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
return
}
var
v
IntVector
var
v
IntVector
c
:=
int
(
0
)
c
:=
int
(
0
)
runtime
.
GC
()
runtime
.
GC
()
...
@@ -69,6 +75,9 @@ func TestIntVectorNums(t *testing.T) {
...
@@ -69,6 +75,9 @@ func TestIntVectorNums(t *testing.T) {
func
TestStringVectorNums
(
t
*
testing
.
T
)
{
func
TestStringVectorNums
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
return
}
var
v
StringVector
var
v
StringVector
c
:=
""
c
:=
""
runtime
.
GC
()
runtime
.
GC
()
...
...
src/pkg/crypto/elliptic/elliptic_test.go
View file @
7f9acb53
...
@@ -297,6 +297,9 @@ func TestBaseMult(t *testing.T) {
...
@@ -297,6 +297,9 @@ func TestBaseMult(t *testing.T) {
if
fmt
.
Sprintf
(
"%x"
,
x
)
!=
e
.
x
||
fmt
.
Sprintf
(
"%x"
,
y
)
!=
e
.
y
{
if
fmt
.
Sprintf
(
"%x"
,
x
)
!=
e
.
x
||
fmt
.
Sprintf
(
"%x"
,
y
)
!=
e
.
y
{
t
.
Errorf
(
"%d: bad output for k=%s: got (%x, %s), want (%s, %s)"
,
i
,
e
.
k
,
x
,
y
,
e
.
x
,
e
.
y
)
t
.
Errorf
(
"%d: bad output for k=%s: got (%x, %s), want (%s, %s)"
,
i
,
e
.
k
,
x
,
y
,
e
.
x
,
e
.
y
)
}
}
if
testing
.
Short
()
&&
i
>
5
{
break
}
}
}
}
}
...
...
src/pkg/crypto/tls/handshake_messages_test.go
View file @
7f9acb53
...
@@ -34,7 +34,11 @@ func TestMarshalUnmarshal(t *testing.T) {
...
@@ -34,7 +34,11 @@ func TestMarshalUnmarshal(t *testing.T) {
for
i
,
iface
:=
range
tests
{
for
i
,
iface
:=
range
tests
{
ty
:=
reflect
.
NewValue
(
iface
)
.
Type
()
ty
:=
reflect
.
NewValue
(
iface
)
.
Type
()
for
j
:=
0
;
j
<
100
;
j
++
{
n
:=
100
if
testing
.
Short
()
{
n
=
5
}
for
j
:=
0
;
j
<
n
;
j
++
{
v
,
ok
:=
quick
.
Value
(
ty
,
rand
)
v
,
ok
:=
quick
.
Value
(
ty
,
rand
)
if
!
ok
{
if
!
ok
{
t
.
Errorf
(
"#%d: failed to create value"
,
i
)
t
.
Errorf
(
"#%d: failed to create value"
,
i
)
...
...
src/pkg/exp/eval/eval_test.go
View file @
7f9acb53
...
@@ -39,9 +39,13 @@ type job struct {
...
@@ -39,9 +39,13 @@ type job struct {
}
}
func
runTests
(
t
*
testing
.
T
,
baseName
string
,
tests
[]
test
)
{
func
runTests
(
t
*
testing
.
T
,
baseName
string
,
tests
[]
test
)
{
for
i
,
test
:=
range
tests
{
delta
:=
1
if
testing
.
Short
()
{
delta
=
16
}
for
i
:=
0
;
i
<
len
(
tests
);
i
+=
delta
{
name
:=
fmt
.
Sprintf
(
"%s[%d]"
,
baseName
,
i
)
name
:=
fmt
.
Sprintf
(
"%s[%d]"
,
baseName
,
i
)
test
.
run
(
t
,
name
)
test
s
[
i
]
.
run
(
t
,
name
)
}
}
}
}
...
...
src/pkg/fmt/fmt_test.go
View file @
7f9acb53
...
@@ -442,6 +442,9 @@ func BenchmarkSprintfPrefixedInt(b *testing.B) {
...
@@ -442,6 +442,9 @@ func BenchmarkSprintfPrefixedInt(b *testing.B) {
}
}
func
TestCountMallocs
(
t
*
testing
.
T
)
{
func
TestCountMallocs
(
t
*
testing
.
T
)
{
if
testing
.
Short
()
{
return
}
mallocs
:=
0
-
runtime
.
MemStats
.
Mallocs
mallocs
:=
0
-
runtime
.
MemStats
.
Mallocs
for
i
:=
0
;
i
<
100
;
i
++
{
for
i
:=
0
;
i
<
100
;
i
++
{
Sprintf
(
""
)
Sprintf
(
""
)
...
...
src/pkg/go/printer/printer_test.go
View file @
7f9acb53
...
@@ -156,12 +156,15 @@ var data = []entry{
...
@@ -156,12 +156,15 @@ var data = []entry{
func
TestFiles
(
t
*
testing
.
T
)
{
func
TestFiles
(
t
*
testing
.
T
)
{
for
_
,
e
:=
range
data
{
for
i
,
e
:=
range
data
{
source
:=
filepath
.
Join
(
dataDir
,
e
.
source
)
source
:=
filepath
.
Join
(
dataDir
,
e
.
source
)
golden
:=
filepath
.
Join
(
dataDir
,
e
.
golden
)
golden
:=
filepath
.
Join
(
dataDir
,
e
.
golden
)
check
(
t
,
source
,
golden
,
e
.
mode
)
check
(
t
,
source
,
golden
,
e
.
mode
)
// TODO(gri) check that golden is idempotent
// TODO(gri) check that golden is idempotent
//check(t, golden, golden, e.mode);
//check(t, golden, golden, e.mode)
if
testing
.
Short
()
&&
i
>=
3
{
break
}
}
}
}
}
...
...
src/pkg/image/png/reader_test.go
View file @
7f9acb53
...
@@ -34,6 +34,12 @@ var filenames = []string{
...
@@ -34,6 +34,12 @@ var filenames = []string{
"basn6a16"
,
"basn6a16"
,
}
}
var
filenamesShort
=
[]
string
{
"basn0g01"
,
"basn0g04-31"
,
"basn6a16"
,
}
func
readPng
(
filename
string
)
(
image
.
Image
,
os
.
Error
)
{
func
readPng
(
filename
string
)
(
image
.
Image
,
os
.
Error
)
{
f
,
err
:=
os
.
Open
(
filename
,
os
.
O_RDONLY
,
0444
)
f
,
err
:=
os
.
Open
(
filename
,
os
.
O_RDONLY
,
0444
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -157,7 +163,11 @@ func sng(w io.WriteCloser, filename string, png image.Image) {
...
@@ -157,7 +163,11 @@ func sng(w io.WriteCloser, filename string, png image.Image) {
}
}
func
TestReader
(
t
*
testing
.
T
)
{
func
TestReader
(
t
*
testing
.
T
)
{
for
_
,
fn
:=
range
filenames
{
names
:=
filenames
if
testing
.
Short
()
{
names
=
filenamesShort
}
for
_
,
fn
:=
range
names
{
// Read the .png file.
// Read the .png file.
img
,
err
:=
readPng
(
"testdata/pngsuite/"
+
fn
+
".png"
)
img
,
err
:=
readPng
(
"testdata/pngsuite/"
+
fn
+
".png"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
src/pkg/image/png/writer_test.go
View file @
7f9acb53
...
@@ -32,7 +32,11 @@ func diff(m0, m1 image.Image) os.Error {
...
@@ -32,7 +32,11 @@ func diff(m0, m1 image.Image) os.Error {
func
TestWriter
(
t
*
testing
.
T
)
{
func
TestWriter
(
t
*
testing
.
T
)
{
// The filenames variable is declared in reader_test.go.
// The filenames variable is declared in reader_test.go.
for
_
,
fn
:=
range
filenames
{
names
:=
filenames
if
testing
.
Short
()
{
names
=
filenamesShort
}
for
_
,
fn
:=
range
names
{
qfn
:=
"testdata/pngsuite/"
+
fn
+
".png"
qfn
:=
"testdata/pngsuite/"
+
fn
+
".png"
// Read the image.
// Read the image.
m0
,
err
:=
readPng
(
qfn
)
m0
,
err
:=
readPng
(
qfn
)
...
...
src/pkg/json/decode_test.go
View file @
7f9acb53
...
@@ -157,6 +157,7 @@ func TestUnmarshal(t *testing.T) {
...
@@ -157,6 +157,7 @@ func TestUnmarshal(t *testing.T) {
}
}
func
TestUnmarshalMarshal
(
t
*
testing
.
T
)
{
func
TestUnmarshalMarshal
(
t
*
testing
.
T
)
{
initBig
()
var
v
interface
{}
var
v
interface
{}
if
err
:=
Unmarshal
(
jsonBig
,
&
v
);
err
!=
nil
{
if
err
:=
Unmarshal
(
jsonBig
,
&
v
);
err
!=
nil
{
t
.
Fatalf
(
"Unmarshal: %v"
,
err
)
t
.
Fatalf
(
"Unmarshal: %v"
,
err
)
...
...
src/pkg/json/scanner_test.go
View file @
7f9acb53
...
@@ -85,6 +85,7 @@ func TestIndent(t *testing.T) {
...
@@ -85,6 +85,7 @@ func TestIndent(t *testing.T) {
// Tests of a large random structure.
// Tests of a large random structure.
func
TestCompactBig
(
t
*
testing
.
T
)
{
func
TestCompactBig
(
t
*
testing
.
T
)
{
initBig
()
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
if
err
:=
Compact
(
&
buf
,
jsonBig
);
err
!=
nil
{
if
err
:=
Compact
(
&
buf
,
jsonBig
);
err
!=
nil
{
t
.
Fatalf
(
"Compact: %v"
,
err
)
t
.
Fatalf
(
"Compact: %v"
,
err
)
...
@@ -98,6 +99,7 @@ func TestCompactBig(t *testing.T) {
...
@@ -98,6 +99,7 @@ func TestCompactBig(t *testing.T) {
}
}
func
TestIndentBig
(
t
*
testing
.
T
)
{
func
TestIndentBig
(
t
*
testing
.
T
)
{
initBig
()
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
if
err
:=
Indent
(
&
buf
,
jsonBig
,
""
,
"
\t
"
);
err
!=
nil
{
if
err
:=
Indent
(
&
buf
,
jsonBig
,
""
,
"
\t
"
);
err
!=
nil
{
t
.
Fatalf
(
"Indent1: %v"
,
err
)
t
.
Fatalf
(
"Indent1: %v"
,
err
)
...
@@ -135,6 +137,7 @@ func TestIndentBig(t *testing.T) {
...
@@ -135,6 +137,7 @@ func TestIndentBig(t *testing.T) {
}
}
func
TestNextValueBig
(
t
*
testing
.
T
)
{
func
TestNextValueBig
(
t
*
testing
.
T
)
{
initBig
()
var
scan
scanner
var
scan
scanner
item
,
rest
,
err
:=
nextValue
(
jsonBig
,
&
scan
)
item
,
rest
,
err
:=
nextValue
(
jsonBig
,
&
scan
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -160,6 +163,7 @@ func TestNextValueBig(t *testing.T) {
...
@@ -160,6 +163,7 @@ func TestNextValueBig(t *testing.T) {
}
}
func
BenchmarkSkipValue
(
b
*
testing
.
B
)
{
func
BenchmarkSkipValue
(
b
*
testing
.
B
)
{
initBig
()
var
scan
scanner
var
scan
scanner
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
nextValue
(
jsonBig
,
&
scan
)
nextValue
(
jsonBig
,
&
scan
)
...
@@ -191,12 +195,23 @@ func trim(b []byte) []byte {
...
@@ -191,12 +195,23 @@ func trim(b []byte) []byte {
var
jsonBig
[]
byte
var
jsonBig
[]
byte
func
init
()
{
const
(
b
,
err
:=
Marshal
(
genValue
(
10000
))
big
=
10000
if
err
!=
nil
{
small
=
100
panic
(
err
)
)
func
initBig
()
{
n
:=
big
if
testing
.
Short
()
{
n
=
small
}
if
len
(
jsonBig
)
!=
n
{
b
,
err
:=
Marshal
(
genValue
(
n
))
if
err
!=
nil
{
panic
(
err
)
}
jsonBig
=
b
}
}
jsonBig
=
b
}
}
func
genValue
(
n
int
)
interface
{}
{
func
genValue
(
n
int
)
interface
{}
{
...
...
src/pkg/netchan/netchan_test.go
View file @
7f9acb53
...
@@ -399,7 +399,7 @@ func TestImportFlowControl(t *testing.T) {
...
@@ -399,7 +399,7 @@ func TestImportFlowControl(t *testing.T) {
func
testFlow
(
sendDone
chan
bool
,
ch
<-
chan
int
,
N
int
,
t
*
testing
.
T
)
{
func
testFlow
(
sendDone
chan
bool
,
ch
<-
chan
int
,
N
int
,
t
*
testing
.
T
)
{
go
func
()
{
go
func
()
{
time
.
Sleep
(
1
e9
)
time
.
Sleep
(
0.5
e9
)
sendDone
<-
false
sendDone
<-
false
}()
}()
...
...
src/pkg/utf8/string_test.go
View file @
7f9acb53
...
@@ -45,7 +45,12 @@ func TestScanBackwards(t *testing.T) {
...
@@ -45,7 +45,12 @@ func TestScanBackwards(t *testing.T) {
}
}
}
}
const
randCount
=
100000
func
randCount
()
int
{
if
testing
.
Short
()
{
return
100
}
return
100000
}
func
TestRandomAccess
(
t
*
testing
.
T
)
{
func
TestRandomAccess
(
t
*
testing
.
T
)
{
for
_
,
s
:=
range
testStrings
{
for
_
,
s
:=
range
testStrings
{
...
@@ -58,7 +63,7 @@ func TestRandomAccess(t *testing.T) {
...
@@ -58,7 +63,7 @@ func TestRandomAccess(t *testing.T) {
t
.
Errorf
(
"%s: expected %d runes; got %d"
,
s
,
len
(
runes
),
str
.
RuneCount
())
t
.
Errorf
(
"%s: expected %d runes; got %d"
,
s
,
len
(
runes
),
str
.
RuneCount
())
break
break
}
}
for
j
:=
0
;
j
<
randCount
;
j
++
{
for
j
:=
0
;
j
<
randCount
()
;
j
++
{
i
:=
rand
.
Intn
(
len
(
runes
))
i
:=
rand
.
Intn
(
len
(
runes
))
expect
:=
runes
[
i
]
expect
:=
runes
[
i
]
got
:=
str
.
At
(
i
)
got
:=
str
.
At
(
i
)
...
@@ -80,7 +85,7 @@ func TestRandomSliceAccess(t *testing.T) {
...
@@ -80,7 +85,7 @@ func TestRandomSliceAccess(t *testing.T) {
t
.
Errorf
(
"%s: expected %d runes; got %d"
,
s
,
len
(
runes
),
str
.
RuneCount
())
t
.
Errorf
(
"%s: expected %d runes; got %d"
,
s
,
len
(
runes
),
str
.
RuneCount
())
break
break
}
}
for
k
:=
0
;
k
<
randCount
;
k
++
{
for
k
:=
0
;
k
<
randCount
()
;
k
++
{
i
:=
rand
.
Intn
(
len
(
runes
))
i
:=
rand
.
Intn
(
len
(
runes
))
j
:=
rand
.
Intn
(
len
(
runes
)
+
1
)
j
:=
rand
.
Intn
(
len
(
runes
)
+
1
)
if
i
>
j
{
// include empty strings
if
i
>
j
{
// include empty strings
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment