package base62 import ( "testing" ) func TestRandom(t *testing.T) { strings := make(map[string]struct{}) for i := 0; i < 100000; i++ { c, err := Random(16) if err != nil { t.Fatal(err) } if _, ok := strings[c]; ok { t.Fatalf("Unexpected duplicate string: %s", c) } strings[c] = struct{}{} } for i := 0; i < 3000; i++ { c, err := Random(i) if err != nil { t.Fatal(err) } if len(c) != i { t.Fatalf("Expected length %d, got: %d", i, len(c)) } } }