Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package p20190916;
- import junit.framework.TestCase;
- import java.util.TreeSet;
- public class StrongTest extends TestCase {
- public void testKnownStrongNumbersBetween0and999() {
- final TreeSet<Integer> strongNumbers = new TreeSet<>();
- assertIsStrongNumber(strongNumbers, 0);
- assertIsStrongNumber(strongNumbers, 1);
- assertIsStrongNumber(strongNumbers, 2);
- assertIsStrongNumber(strongNumbers, 145);
- assertIsStrongNumber(strongNumbers, 40585);
- for (int otherNumber = 0; otherNumber <= 99999; ++otherNumber) {
- if (!strongNumbers.contains(otherNumber)) {
- assertFalse(otherNumber + " should *NOT* be an Strong number", NumberFinder.isStrong(otherNumber));
- }
- }
- }
- private static void assertIsStrongNumber(TreeSet<Integer> strongNumbers, int strongNumber) {
- assertTrue(strongNumber + " should be Strong number", NumberFinder.isStrong(strongNumber));
- strongNumbers.add(strongNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement