static bool testActive() { // Object created (should be active) jumpPrime j = new jumpPrime(4999); if (!j.isActive()) { return(false); } testMsg("Active constructor test passed!"); // Object created with invalid number (should be inactive) jumpPrime j2 = new jumpPrime(5); if (j2.isActive()) { return(false); } testMsg("Inactive constructor test passed!"); // Creating and jumping until inactive jumpPrime j3 = new jumpPrime(1607); for (int i = 0; i < 20; i++) { j3.up(); } if (j3.isActive()) { return(false); } testMsg("Jump to inactive isActive test passed!"); // If no tests fail, return true return(true); }
static bool testResetRevive() { // Causing jump and then testing reset() jumpPrime j = new jumpPrime(2354); if (j.up() != 2357 || j.down() != 2351) { return(false); } for (int i = 0; i < 4; i++) { j.up(); } if (j.up() != 2371 || j.down() != 2357) { return(false); } j.reset(); if (j.up() != 2357 || j.down() != 2351) { return(false); } testMsg("Jump and reset test passed!"); // Creating invalid jumpPrime (made inactive immediately) and attempting to revive jumpPrime j2 = new jumpPrime(5); j2.revive(); if (j2.isActive()) { return(false); } testMsg("Invalid revive test passed!"); // Creating valid jumpPrime and then causing it to be inactive, then reviving jumpPrime j3 = new jumpPrime(1787); for (int i = 0; i < 20; i++) { j3.up(); } if (j3.isActive()) { return(false); } j3.revive(); if (!j3.isActive()) { return(false); } testMsg("Valid to inactive revive test passed!"); // Reviving active jumpPrime, causing it to be permanently disabled jumpPrime j4 = new jumpPrime(2284); if (!j4.isActive()) { return(false); } j4.revive(); if (j4.isActive()) { return(false); } testMsg("Active object revive test passed!"); // If no tests fail, return true return(true); }