(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestRSA(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | message string |
| 13 | }{ |
| 14 | { |
| 15 | name: "Encrypt letter 'a' and decrypt it back", |
| 16 | message: "a", |
| 17 | }, |
| 18 | { |
| 19 | name: "Encrypt 'Hello, World!' and decrypt it back", |
| 20 | message: "Hello, World!", |
| 21 | }, |
| 22 | } |
| 23 | |
| 24 | for _, tt := range tests { |
| 25 | t.Run(tt.name, func(t *testing.T) { |
| 26 | rsa := rsa.New() |
| 27 | encrypted := rsa.EncryptString(tt.message) |
| 28 | decrypted := rsa.DecryptString(encrypted) |
| 29 | if decrypted != tt.message { |
| 30 | t.Errorf("expected %s, got %s", tt.message, decrypted) |
| 31 | } |
| 32 | }) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func BenchmarkRSAEncryption(b *testing.B) { |
| 37 | rsa := rsa.New() |
nothing calls this directly
no test coverage detected