This commit is contained in:
2026-09-13 00:33:39 +07:00
parent bd6b0ea8f2
commit 9f818c6aad
7 changed files with 30 additions and 6 deletions
@@ -6,7 +6,7 @@ import (
)
const (
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
charset = "abcdefghijklmnopqrstuvwxyz"
)
type generator struct {
@@ -0,0 +1,21 @@
package password_generator
import "testing"
func TestGenerate(t *testing.T) {
g := NewGenerator(8)
for range 100 {
password, err := g.Generate()
if err != nil {
t.Fatal(err)
}
if len(password) != 8 {
t.Fatalf("password length = %d, want 8", len(password))
}
for _, char := range password {
if char < 'a' || char > 'z' {
t.Fatal("password contains a character outside a-z")
}
}
}
}