MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestNewPolybius

Function TestNewPolybius

cipher/polybius/polybius_test.go:39–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestNewPolybius(t *testing.T) {
40 t.Parallel()
41 cases := []struct {
42 name string
43 size int
44 characters string
45 key string
46 wantErr string
47 }{
48 {
49 name: "correct initialization", size: 5, characters: "HogeF", key: "abcdefghijklmnopqrstuvwxy", wantErr: "",
50 },
51 {
52 name: "truncate characters", size: 5, characters: "HogeFuga", key: "abcdefghijklmnopqrstuvwxy", wantErr: "",
53 },
54 {
55 name: "invalid key", size: 5, characters: "HogeFuga", key: "abcdefghi", wantErr: "len(key): 9 must be as long as size squared: 25",
56 },
57 {
58 name: "invalid characters", size: 5, characters: "HogeH", key: "abcdefghijklmnopqrstuvwxy", wantErr: "\"OGEH\" contains same character 'H'",
59 },
60 }
61
62 for _, tc := range cases {
63 t.Run(tc.name, func(t *testing.T) {
64 _, err := NewPolybius(tc.key, tc.size, tc.characters)
65 if err != nil && err.Error() != tc.wantErr {
66 t.Errorf("failed NewPolybius: %v", err)
67 }
68 })
69 }
70}
71
72func TestPolybiusEncrypt(t *testing.T) {
73 t.Parallel()

Callers

nothing calls this directly

Calls 1

NewPolybiusFunction · 0.85

Tested by

no test coverage detected