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

Function TestEncryptDecrypt

cipher/rsa/rsa_test.go:56–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestEncryptDecrypt(t *testing.T) {
57 for _, test := range rsaTestData {
58 t.Run(test.description, func(t *testing.T) {
59 e, d, n := testPrecondition(t)
60 message := []rune(test.input)
61 encrypted, err := Encrypt(message, e, n)
62 if err != nil {
63 t.Fatalf("Failed to Encrypt test string:\n\tDescription: %v\n\tErrMessage: %v", test.description, err)
64 }
65
66 decrypted, err := Decrypt(encrypted, d, n)
67 if err != nil {
68 t.Fatalf("Failed to Decrypt test message:\n\tDescription: %v\n\tErrMessage: %v", test.description, err)
69 }
70
71 if actual := test.input; actual != decrypted {
72 t.Logf("FAIL: %s", test.description)
73 t.Fatalf("Expecting %v, actual %v", decrypted, actual)
74 }
75 })
76 }
77}
78
79func FuzzRsa(f *testing.F) {
80 for _, rsaTestInput := range rsaTestData {

Callers

nothing calls this directly

Calls 3

testPreconditionFunction · 0.85
EncryptFunction · 0.70
DecryptFunction · 0.70

Tested by

no test coverage detected