Files
superherohub/pkg/deesee/codec_test.go

30 lines
793 B
Go

package deesee
import "testing"
// TestEncrypt tests the Encrypt and Decrypt function.
func TestCryptDecrypt(t *testing.T) {
// Run the test cases.
for _, tc := range []struct {
name, A, B string
key int
}{
{"Test encrypt-decrypt: Simple text",
"clark", "hqfwp", 5},
{"Test encrypt-decrypt: Text with shifted outbounds chars",
"cherry blossom", "fkhuub eorvvrp", 3},
{"Test encrypt-decrypt: Text with shifted outbounds chars and non-letter chars",
"cherry123 blossom!", "fkhuub123 eorvvrp!", 3},
} {
t.Run(tc.name, func(t *testing.T) {
if enc := Encrypt(tc.A, tc.key); enc != tc.B {
t.Errorf("Encrypt() = %v, want %v", enc, tc.B)
}
if dec := Decrypt(tc.B, tc.key); dec != tc.A {
t.Errorf("Decrypt() = %v, want %v", dec, tc.A)
}
})
}
}