MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestDecrypt

Function TestDecrypt

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

Source from the content-addressed store, hash-verified

48}
49
50func TestDecrypt(t *testing.T) {
51 var railFenceTestData = []struct {
52 description string
53 input string
54 rails int
55 expected string
56 }{
57 {
58 "Decrypt with 2 rails",
59 "hloel",
60 2,
61 "hello",
62 },
63 {
64 "Decrypt with 3 rails",
65 "ho l lewrdlo",
66 3,
67 "hld olle wor",
68 },
69 {
70 "Decrypt with edge case: 1 rail",
71 "hello",
72 1,
73 "hello",
74 },
75 {
76 "Decrypt with more rails than letters",
77 "hi",
78 100,
79 "hi",
80 },
81 }
82
83 for _, test := range railFenceTestData {
84 t.Run(test.description, func(t *testing.T) {
85 actual := Decrypt(test.input, test.rails)
86 if actual != test.expected {
87 t.Errorf("FAIL: %s - Decrypt(%s, %d) = %s, want %s", test.description, test.input, test.rails, actual, test.expected)
88 }
89 })
90 }
91}

Callers

nothing calls this directly

Calls 1

DecryptFunction · 0.70

Tested by

no test coverage detected