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

Function TestEncrypt

cipher/railfence/railfence_test.go:7–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestEncrypt(t *testing.T) {
8 var railFenceTestData = []struct {
9 description string
10 input string
11 rails int
12 expected string
13 }{
14 {
15 "Encrypt with 2 rails",
16 "hello",
17 2,
18 "hloel",
19 },
20 {
21 "Encrypt with 3 rails",
22 "hello world",
23 3,
24 "horel ollwd",
25 },
26 {
27 "Encrypt with edge case: 1 rail",
28 "hello",
29 1,
30 "hello",
31 },
32 {
33 "Encrypt with more rails than letters",
34 "hi",
35 100,
36 "hi",
37 },
38 }
39
40 for _, test := range railFenceTestData {
41 t.Run(test.description, func(t *testing.T) {
42 actual := Encrypt(test.input, test.rails)
43 if actual != test.expected {
44 t.Errorf("FAIL: %s - Encrypt(%s, %d) = %s, want %s", test.description, test.input, test.rails, actual, test.expected)
45 }
46 })
47 }
48}
49
50func TestDecrypt(t *testing.T) {
51 var railFenceTestData = []struct {

Callers

nothing calls this directly

Calls 1

EncryptFunction · 0.70

Tested by

no test coverage detected