Skip to content

Commit 6c83fc8

Browse files
committed
Fix incorrect BSGS test cases
1 parent 1539125 commit 6c83fc8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/test/java/com/thealgorithms/maths/DiscreteLogarithmBSGSTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ public void testSmallValues() {
1414

1515
@Test
1616
public void testNoSolution() {
17-
assertEquals(-1, DiscreteLogarithmBSGS.discreteLog(10, 5, 17));
17+
// choose a true NO-SOLUTION example:
18+
// modulo 15, base 4 generates only {1,4}
19+
assertEquals(-1, DiscreteLogarithmBSGS.discreteLog(4, 2, 15));
1820
}
1921

2022
@Test
2123
public void testLargeMod() {
22-
long x = DiscreteLogarithmBSGS.discreteLog(5, 243, 1000003);
23-
assertEquals(5, x);
24+
// use a valid solvable case
25+
long x = DiscreteLogarithmBSGS.discreteLog(5, 5, 1000003);
26+
assertEquals(1, x);
2427
}
2528
}

0 commit comments

Comments
 (0)