summaryrefslogtreecommitdiff
path: root/bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java')
-rw-r--r--bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java67
1 files changed, 54 insertions, 13 deletions
diff --git a/bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java b/bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java
index 27e89f00..0c43b5a1 100644
--- a/bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java
+++ b/bcprov/src/test/java/org/bouncycastle/math/ec/test/ECAlgorithmsTest.java
@@ -1,5 +1,8 @@
package org.bouncycastle.math.ec.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
@@ -14,18 +17,49 @@ import org.bouncycastle.crypto.ec.CustomNamedCurves;
import org.bouncycastle.math.ec.ECAlgorithms;
import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.math.ec.ECPoint;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import android.platform.test.annotations.LargeTest;
-
-public class ECAlgorithmsTest extends TestCase
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+// Android-changed: parameterized the test.
+@RunWith(Parameterized.class)
+public class ECAlgorithmsTest
{
private static final int SCALE = 4;
private static final SecureRandom RND = new SecureRandom();
+
+ // BEGIN Android-added: parameterized the test.
+ @Parameterized.Parameters(name = "{0}")
+ public static String[] getAllX9ECParameters() {
+ Set<String> names = new HashSet<>(AllTests.enumToList(ECNamedCurveTable.getNames()));
+ names.addAll(AllTests.enumToList(CustomNamedCurves.getNames()));
+ return names.toArray(new String[0]);
+ }
+
+ @Parameterized.Parameter(0)
+ public String name;
+
+ private ArrayList getX9s(String name) {
+ ArrayList<X9ECParameters> x9s = new ArrayList<>();
+
+ X9ECParameters x9 = ECNamedCurveTable.getByName(name);
+ if (x9 != null)
+ {
+ addTestCurves(x9s, x9);
+ }
+
+ x9 = CustomNamedCurves.getByName(name);
+ if (x9 != null)
+ {
+ addTestCurves(x9s, x9);
+ }
+ return x9s;
+ }
+ // END Android-added: parameterized the test.
+
+ @Ignore("secp256r1 is covered by testSumOfMultipliesComplete")
public void testSumOfMultiplies()
{
X9ECParameters x9 = CustomNamedCurves.getByName("secp256r1");
@@ -34,10 +68,12 @@ public class ECAlgorithmsTest extends TestCase
}
// TODO Ideally, mark this test not to run by default
- @LargeTest
+ @Test
public void testSumOfMultipliesComplete()
{
- ArrayList x9s = getTestCurves();
+ // Android-changed: parameterized the test.
+ // ArrayList x9s = getTestCurves();
+ ArrayList<X9ECParameters> x9s = getX9s(name);
Iterator it = x9s.iterator();
while (it.hasNext())
{
@@ -46,6 +82,7 @@ public class ECAlgorithmsTest extends TestCase
}
}
+ @Ignore("secp256r1 is covered by testSumOfTwoMultipliesComplete")
public void testSumOfTwoMultiplies()
{
X9ECParameters x9 = CustomNamedCurves.getByName("secp256r1");
@@ -54,10 +91,12 @@ public class ECAlgorithmsTest extends TestCase
}
// TODO Ideally, mark this test not to run by default
- @LargeTest
+ @Test
public void testSumOfTwoMultipliesComplete()
{
- ArrayList x9s = getTestCurves();
+ // Android-changed: parameterized the test.
+ // ArrayList x9s = getTestCurves();
+ ArrayList<X9ECParameters> x9s = getX9s(name);
Iterator it = x9s.iterator();
while (it.hasNext())
{
@@ -190,9 +229,11 @@ public class ECAlgorithmsTest extends TestCase
}
}
+ // Android-changed: Use JUnit4.
+ /*
public static Test suite()
{
return new TestSuite(ECAlgorithmsTest.class);
}
-
+ */
}