forked from codacy-badger/randgoart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
randgoart_test.go
93 lines (89 loc) · 1.8 KB
/
randgoart_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package randgoart_test
import (
"encoding/hex"
"fmt"
"testing"
u "github.com/johnsonjh/leaktestfe"
"github.com/johnsonjh/randgoart"
)
func TestGenerate(
t *testing.T,
) {
u.Leakplug(t)
tests := []struct {
input string
output string
}{
{
"f5f8a4b7ac83b0b9aa9ad4306269e738",
"" +
"+-----------------+\n" +
"| |\n" +
"| |\n" +
"| . |\n" +
"| . . o |\n" +
"|.* . S . o |\n" +
"|+ B . + |\n" +
"| E o + .. o |\n" +
"|... o . .o . |\n" +
"|o....... .oo |\n" +
"+-----------------+",
},
{
"5a46a29f198bdb5a988ccef224acafbf",
"" +
"+-----------------+\n" +
"| |\n" +
"| |\n" +
"| . . |\n" +
"| . o |\n" +
"| . . S |\n" +
"|. o = O |\n" +
"|..o = B |\n" +
"|o= + |\n" +
"|o*E.o.. |\n" +
"+-----------------+",
},
{
"fc94b0c1e5b0987c5843997697ee9fb7",
"" +
"+-----------------+\n" +
"| .=o. . |\n" +
"| . *+*. o |\n" +
"| =.*..o |\n" +
"| o + .. |\n" +
"| S o. |\n" +
"| o . |\n" +
"| . . . |\n" +
"| o .|\n" +
"| E.|\n" +
"+-----------------+",
},
}
for _, tt := range tests {
data, _ := hex.DecodeString(
tt.input,
)
var err error
sshhash := randgoart.NewSSH()
_, err = sshhash.Write(
data,
)
if err != nil {
t.Fatal(
fmt.Sprintf(
"\nrandgoart.sshhash.Write failed: %v",
err,
),
)
}
s := sshhash.String()
if s != tt.output {
t.Errorf(
"ssh visual hash test failed: got:\n%v\nwanted:\n%v",
s,
tt.output,
)
}
}
}