func TestLargeStringWrites(t *testing.T) {
var buf Buffer
- for i := 3; i < 30; i += 3 {
+ limit := 30
+ if testing.Short() {
+ limit = 9
+ }
+ for i := 3; i < limit; i += 3 {
s := fillString(t, "TestLargeWrites (1)", &buf, "", 5, data)
empty(t, "TestLargeStringWrites (2)", &buf, s, make([]byte, len(data)/i))
}
func TestLargeByteWrites(t *testing.T) {
var buf Buffer
- for i := 3; i < 30; i += 3 {
+ limit := 30
+ if testing.Short() {
+ limit = 9
+ }
+ for i := 3; i < limit; i += 3 {
s := fillBytes(t, "TestLargeWrites (1)", &buf, "", 5, bytes)
empty(t, "TestLargeByteWrites (2)", &buf, s, make([]byte, len(data)/i))
}
// test a larger buffer with different sizes and alignments
func TestIndexByteBig(t *testing.T) {
- const n = 1024
+ var n = 1024
+ if testing.Short() {
+ n = 128
+ }
b := make([]byte, n)
for i := 0; i < n; i++ {
// different start alignments
if !bytes.Equal(out, expected) {
t.Errorf("%d: output got: %x want: %x", i, out, expected)
}
+ if testing.Short() {
+ break
+ }
}
}
)
func TestRead(t *testing.T) {
- b := make([]byte, 4e6)
+ var n int = 4e6
+ if testing.Short() {
+ n = 1e5
+ }
+ b := make([]byte, n)
n, err := Read(b)
if n != len(b) || err != nil {
t.Fatalf("Read(buf) = %d, %s", n, err)
return true
}
- quick.Check(tryEncryptDecrypt, nil)
+ config := new(quick.Config)
+ if testing.Short() {
+ config.MaxCount = 10
+ }
+ quick.Check(tryEncryptDecrypt, config)
}
// These test vectors were generated with `openssl rsautl -pkcs -encrypt`
func TestKeyGeneration(t *testing.T) {
random := rand.Reader
- priv, err := GenerateKey(random, 1024)
+ size := 1024
+ if testing.Short() {
+ size = 128
+ }
+ priv, err := GenerateKey(random, size)
if err != nil {
t.Errorf("failed to generate key")
}
t.Errorf("#%d,%d (blind) bad result: %#v (want %#v)", i, j, out, message.in)
}
}
+ if testing.Short() {
+ break
+ }
}
}
}
func TestSortLarge_Random(t *testing.T) {
- data := make([]int, 1000000)
+ n := 1000000
+ if testing.Short() {
+ n /= 100
+ }
+ data := make([]int, n)
for i := 0; i < len(data); i++ {
data[i] = rand.Intn(100)
}
func TestBentleyMcIlroy(t *testing.T) {
sizes := []int{100, 1023, 1024, 1025}
+ if testing.Short() {
+ sizes = []int{100, 127, 128, 129}
+ }
dists := []string{"sawtooth", "rand", "stagger", "plateau", "shuffle"}
modes := []string{"copy", "reverse", "reverse1", "reverse2", "sort", "dither"}
var tmp1, tmp2 [1025]int
func TestCaseConsistency(t *testing.T) {
// Make a string of all the runes.
- a := make([]int, unicode.MaxRune+1)
+ numRunes := unicode.MaxRune + 1
+ if testing.Short() {
+ numRunes = 1000
+ }
+ a := make([]int, numRunes)
for i := range a {
a[i] = i
}
lower := ToLower(s)
// Consistency checks
- if n := utf8.RuneCountInString(upper); n != unicode.MaxRune+1 {
+ if n := utf8.RuneCountInString(upper); n != numRunes {
t.Error("rune count wrong in upper:", n)
}
- if n := utf8.RuneCountInString(lower); n != unicode.MaxRune+1 {
+ if n := utf8.RuneCountInString(lower); n != numRunes {
t.Error("rune count wrong in lower:", n)
}
if !equal("ToUpper(upper)", ToUpper(upper), upper, t) {
}
func TestHammer32(t *testing.T) {
- const (
- n = 100000
- p = 4
- )
+ const p = 4
+ n := 100000
+ if testing.Short() {
+ n = 1000
+ }
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p))
for _, tt := range hammer32 {
for i := 0; i < p; i++ {
<-c
}
- if val != n*p {
+ if val != uint32(n)*p {
t.Errorf("%s: val=%d want %d", tt.name, val, n*p)
}
}
}
func TestHammer64(t *testing.T) {
- const (
- n = 100000
- p = 4
- )
+ const p = 4
+ n := 100000
+ if testing.Short() {
+ n = 1000
+ }
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p))
for _, tt := range hammer64 {
for i := 0; i < p; i++ {
<-c
}
- if val != n*p {
+ if val != uint64(n)*p {
t.Errorf("%s: val=%d want %d", tt.name, val, n*p)
}
}
}
func TestRWMutex(t *testing.T) {
- HammerRWMutex(1, 1, 1000)
- HammerRWMutex(1, 3, 1000)
- HammerRWMutex(1, 10, 1000)
- HammerRWMutex(4, 1, 1000)
- HammerRWMutex(4, 3, 1000)
- HammerRWMutex(4, 10, 1000)
- HammerRWMutex(10, 1, 1000)
- HammerRWMutex(10, 3, 1000)
- HammerRWMutex(10, 10, 1000)
- HammerRWMutex(10, 5, 10000)
+ n := 1000
+ if testing.Short() {
+ n = 5
+ }
+ HammerRWMutex(1, 1, n)
+ HammerRWMutex(1, 3, n)
+ HammerRWMutex(1, 10, n)
+ HammerRWMutex(4, 1, n)
+ HammerRWMutex(4, 3, n)
+ HammerRWMutex(4, 10, n)
+ HammerRWMutex(10, 1, n)
+ HammerRWMutex(10, 3, n)
+ HammerRWMutex(10, 10, n)
+ HammerRWMutex(10, 5, n)
}
func TestRLocker(t *testing.T) {
go tRunner(t, &tests[i])
<-t.ch
ns += time.Nanoseconds()
- tstr := fmt.Sprintf("(%.1f seconds)", float64(ns)/1e9)
+ tstr := fmt.Sprintf("(%.2f seconds)", float64(ns)/1e9)
if t.failed {
println("--- FAIL:", tests[i].Name, tstr)
print(t.errors)