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

Function TestDecrypt

cipher/caesar/caesar_test.go:78–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestDecrypt(t *testing.T) {
79 var caesarTestData = []struct {
80 description string
81 input string
82 key int
83 expected string
84 }{
85 {
86 "Basic caesar decryption with letter 'a'",
87 "a",
88 3,
89 "x",
90 },
91 {
92 "Basic caesar decryption wrap around alphabet on letter 'z'",
93 "z",
94 3,
95 "w",
96 },
97 {
98 "Decrypt a simple string with caesar encryiption",
99 "hello",
100 3,
101 "ebiil",
102 },
103 {
104 "Decrypt a simple string with key 13",
105 "hello",
106 13,
107 "uryyb",
108 },
109 {
110 "Decrypt a simple string with key -13",
111 "hello",
112 -13,
113 "uryyb",
114 },
115 {
116 "With key of 26 output should be the same as the input",
117 "no change",
118 26,
119 "no change",
120 },
121 {
122 "Decrypt sentence with key 10",
123 "Dro Aesmu Lbygx Pyh Tewzc yfob dro Vkji Nyq.",
124 10,
125 "The Quick Brown Fox Jumps over the Lazy Dog.",
126 },
127 }
128
129 for _, test := range caesarTestData {
130 t.Run(test.description, func(t *testing.T) {
131 actual := Decrypt(test.input, test.key)
132 if actual != test.expected {
133 t.Logf("FAIL: %s", test.description)
134 t.Fatalf("With input string '%s' and key '%d' was expecting '%s' but actual was '%s'",
135 test.input, test.key, test.expected, actual)

Callers

nothing calls this directly

Calls 1

DecryptFunction · 0.70

Tested by

no test coverage detected