forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathElGamalEncryptionTest.java
More file actions
34 lines (29 loc) · 1.01 KB
/
ElGamalEncryptionTest.java
File metadata and controls
34 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.thealgorithms.ciphers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link ElGamalEncryption}.
*/
public class ElGamalEncryptionTest {
@Test
void testEncryptionDecryption() {
// Basic functional test (simulated output check)
// Since ElGamal uses randomization, we only verify successful execution
try {
ElGamalEncryption.runElGamal("Hello", 64);
} catch (Exception e) {
throw new AssertionError("ElGamalEncryption failed with exception: " + e.getMessage());
}
}
@Test
void testUtilityConstructor() {
// Ensures the utility class constructor is private
try {
var constructor = ElGamalEncryption.class.getDeclaredConstructor();
constructor.setAccessible(true);
constructor.newInstance();
} catch (Exception e) {
assertEquals("Utility class", e.getCause().getMessage());
}
}
}