-
Notifications
You must be signed in to change notification settings - Fork 189
/
password_test.go
51 lines (42 loc) · 920 Bytes
/
password_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package hc
import (
"testing"
)
func TestPin(t *testing.T) {
pwd, err := ValidatePin("00011222")
if err != nil {
t.Fatal(err)
}
if pwd != "000-11-222" {
t.Fatal(pwd)
}
}
func TestShortPin(t *testing.T) {
if _, err := ValidatePin("0001122"); err == nil {
t.Fatal("expected error")
}
}
func TestLongPin(t *testing.T) {
if _, err := ValidatePin("000112221"); err == nil {
t.Fatal("expected error")
}
}
func TestNonNumberPin(t *testing.T) {
if _, err := ValidatePin("0001122a"); err == nil {
t.Fatal("expected error")
}
}
func TestInvalidPins(t *testing.T) {
if _, err := ValidatePin("12345678"); err == nil {
t.Fatal("expected error")
}
if _, err := ValidatePin("87654321"); err == nil {
t.Fatal("expected error")
}
if _, err := ValidatePin("11111111"); err == nil {
t.Fatal("expected error")
}
if _, err := ValidatePin("99999999"); err == nil {
t.Fatal("expected error")
}
}