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

Function TestEncryptDecrypt

cipher/transposition/transposition_test.go:82–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestEncryptDecrypt(t *testing.T) {
83 text := []rune("Test text for checking the algorithm")
84 key1 := "testKey"
85 key2 := "Test Key2"
86 encrypt, errEncrypt := Encrypt(text, key1)
87 if errEncrypt != nil {
88 t.Error(errEncrypt)
89 }
90 decrypt, errDecrypt := Decrypt(encrypt, key1)
91 if errDecrypt != nil {
92 t.Error(errDecrypt)
93 }
94 if !reflect.DeepEqual(decrypt, text) {
95 t.Errorf("The string was not decrypted correctly %q %q", decrypt, text)
96 }
97 decrypt, _ = Decrypt([]rune(encrypt), key2)
98 if reflect.DeepEqual(decrypt, text) {
99 t.Errorf("The string was decrypted with a different key: %q %q", decrypt, text)
100 }
101}
102
103func FuzzTransposition(f *testing.F) {
104 for _, transpositionTestInput := range texts {

Callers

nothing calls this directly

Calls 2

EncryptFunction · 0.70
DecryptFunction · 0.70

Tested by

no test coverage detected