MoreThanText proxy server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
522 B

// morethantext/proxy/genid_test.go
package proxy
import (
"testing"
)
func TestIDLength(t *testing.T) {
idLen := len(newID())
if idLen != idLength {
t.Errorf("ID length was %d, but expected %d", idLen, idLength)
}
}
func TestForRandomID(t *testing.T) {
holder := make(map[string]bool)
for i := 0; i < 1000; i++ {
id := newID()
if holder[id] {
t.Errorf("ID '%s' was repeated.", id)
} else {
holder[id] = true
}
}
}
func BenchmarkNewID(b *testing.B) {
for n := 0; n < b.N; n++ {
newID()
}
}