// test the updateStats method
 void testUpdateStats(Tester t) {
   player.updateStats(avocado);
   t.checkExpect(player, new Player(751f, 7.7f, 600, new Posn(0, CollectTheFruit.height - 30)));
   resetPlayer();
   player.updateStats(twinkie);
   t.checkExpect(player, new Player(630f, 3.9f, 0, new Posn(0, CollectTheFruit.height - 30)));
 }
 // Test the hasWon() method
 void testHasWon(Tester t) {
   resetPlayer();
   t.checkExpect(player.hasWon(), false);
   resetPlayer();
   player.score = 100000;
   t.checkExpect(player.hasWon(), true);
 }
 // test the changeSpeed method
 void testChangeSpeed(Tester t) {
   resetPlayer();
   player.changeSpeed(0.1f);
   t.checkExpect(player.speed, 6.4f);
   resetPlayer();
   player.changeSpeed(-0.1f);
   t.checkExpect(player.speed, 5.4f);
 }
예제 #4
0
 // tests for method reverse()
 boolean testReverse(Tester t) {
   ILoI mt = new MT();
   ILoI l1 = new Cons(1, mt);
   ILoI l2 = new Cons(2, l1);
   ILoI l3 = new Cons(2, mt);
   ILoI l4 = new Cons(1, l3);
   return t.checkExpect(mt.reverse(), mt) && t.checkExpect(l2.reverse(), l4);
 }
예제 #5
0
 boolean testAllSuch(Tester t) {
   return t.checkExpect(imglistshortnames.allSuchImageFile(this.FourFiles), true)
       &&
       /*t.checkExpect(imglistjpgs.allSuchImageFile(this.givenFiles),
                     true) &&
       t.checkExpect(imglistgif.allSuchImageFile(this.givenFiles),
                     true); */
       t.checkExpect(img1.kind.equals(img7.kind), true);
 }
 // test the method reverse for the lists of Strings
 boolean testReverse(Tester t) {
   return t.checkExpect(this.mtLoString.reverse(), this.mtLoString)
       && t.checkExpect(this.palindrome.reverse(), this.palindrome)
       && t.checkExpect(
           this.sorted.reverse(),
           new ConsLoString(
               "g",
               new ConsLoString(
                   "d", new ConsLoString("c", new ConsLoString("a", this.mtLoString)))));
 }
예제 #7
0
 // tests for class BSTIterator
 void testBSTIterator(Tester t) {
   reset();
   for (int i = 0; i < nodes.length; i++) {
     t.checkExpect(itr.hasNext(), true);
     int val = itr.next();
     t.checkExpect(val == i + 1, true, "iterate on node" + val);
   }
   t.checkExpect(itr.hasNext(), false);
   reset();
 }
 // Test the IsDead() method
 void testIsDead(Tester t) {
   resetPlayer();
   t.checkExpect(player.isDead(), false);
   resetPlayer();
   player.speed = 0;
   t.checkExpect(player.isDead(), true);
   resetPlayer();
   player.hunger = 0;
   t.checkExpect(player.isDead(), true);
 }
예제 #9
0
 // tests for method append()
 boolean testAppend(Tester t) {
   ILoI mt = new MT();
   ILoI l1 = new Cons(1, mt);
   ILoI l2 = new Cons(2, l1);
   ILoI l3 = new Cons(2, mt);
   ILoI l4 = new Cons(1, l3);
   return t.checkExpect(l1.append(mt), l1)
       && t.checkExpect(l2.append(mt), l2)
       && t.checkExpect(l1.append(l3), l4);
 }
예제 #10
0
 // test the method sort for the lists of Strings
 boolean testSort(Tester t) {
   return t.checkExpect(this.mtLoString.sort(), this.mtLoString)
       && t.checkExpect(
           this.unsorted.sort(),
           new ConsLoString(
               "and ",
               new ConsLoString(
                   "Book ",
                   new ConsLoString("Pen ", new ConsLoString("Water ", this.mtLoString)))));
 }
예제 #11
0
 // test the method insert for the lists of Strings
 boolean testInsert(Tester t) {
   return t.checkExpect(this.mtLoString.insert("a"), new ConsLoString("a", this.mtLoString))
       && t.checkExpect(
           this.sorted.insert("b"),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "b",
                   new ConsLoString(
                       "c", new ConsLoString("d", new ConsLoString("g", this.mtLoString))))));
 }
 // test the worldEnd method
 void testWorldEnd(Tester t) {
   t.checkExpect(ctf.worldEnds().worldEnds, false);
   resetCTF();
   ctf.player.score = 300000;
   t.checkExpect(ctf.worldEnds().worldEnds, true);
   resetCTF();
   ctf.player.hunger = 0;
   t.checkExpect(ctf.worldEnds().worldEnds, true);
   resetCTF();
   ctf.player.speed = 0;
   t.checkExpect(ctf.worldEnds().worldEnds, true);
 }
예제 #13
0
 // test the method merge for the lists of Strings
 boolean testMerge(Tester t) {
   return t.checkExpect(
           this.mtLoString.merge(this.sorted),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "c", new ConsLoString("d", new ConsLoString("g", this.mtLoString)))))
       // an example when merge and interleave produce different results
       && t.checkExpect(
           this.sorted.merge(this.sorted2),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "a",
                   new ConsLoString(
                       "c",
                       new ConsLoString(
                           "d",
                           new ConsLoString(
                               "f",
                               new ConsLoString(
                                   "g",
                                   new ConsLoString(
                                       "g", new ConsLoString("h", this.mtLoString)))))))))
       // an example when merge and interleave produce the same results
       && t.checkExpect(
           this.sorted.merge(this.sorted3),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "b",
                   new ConsLoString(
                       "c",
                       new ConsLoString(
                           "d",
                           new ConsLoString(
                               "d",
                               new ConsLoString(
                                   "f",
                                   new ConsLoString(
                                       "g", new ConsLoString("h", this.mtLoString)))))))));
 }
예제 #14
0
 // test the method interleave for the lists of Strings
 boolean testInterleave(Tester t) {
   return t.checkExpect(this.mtLoString.interleave(this.mtLoString), this.mtLoString)
       && t.checkExpect(this.mtLoString.interleave(this.sorted), this.sorted)
       && t.checkExpect(
           this.sorted.interleave(this.unsorted),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "Book ",
                   new ConsLoString(
                       "c",
                       new ConsLoString(
                           "and ",
                           new ConsLoString(
                               "d",
                               new ConsLoString(
                                   "Pen ",
                                   new ConsLoString(
                                       "g", new ConsLoString("Water ", this.mtLoString)))))))))
       && t.checkExpect(
           this.sorted.interleave(this.color),
           new ConsLoString(
               "a",
               new ConsLoString(
                   "black",
                   new ConsLoString(
                       "c",
                       new ConsLoString(
                           "white",
                           new ConsLoString(
                               "d",
                               new ConsLoString(
                                   "yellow",
                                   new ConsLoString(
                                       "g",
                                       new ConsLoString(
                                           "grey",
                                           new ConsLoString(
                                               "red",
                                               new ConsLoString(
                                                   "purple", this.mtLoString)))))))))));
 }
예제 #15
0
 // test the method isDoubledList for the lists of Strings
 boolean testIsDoubledList(Tester t) {
   return t.checkExpect(this.mtLoString.isDoubledList(), true)
       && t.checkExpect(this.sorted.isDoubledList(), false)
       && t.checkExpect(this.oneString.isDoubledList(), false)
       && t.checkExpect(this.notDoubleList.isDoubledList(), false)
       && t.checkExpect(this.doubleList.isDoubledList(), false)
       && t.checkExpect(this.notDoubleList2.isDoubledList(), false);
 }
 // test the generatePowerups method
 void testGeneratePowerups(Tester t) {
   resetField();
   field.generatePowerups(0);
   t.checkExpect(field.pUps, new ArrayList<Powerup>());
   resetField();
   /*
    * field.generatePowerups(1); t.checkOneOf(field, new Field(new
    * ArrayList<Powerup>(Arrays.asList(avocado))), new Field(new
    * ArrayList<Powerup>(Arrays.asList(twinkie))));
    */
   /*
    * resetField(); field.generatePowerups(2); t.checkOneOf(field.pUps,new
    * Field(new ArrayList<Powerup>( Arrays.asList(avocado, avocado))), new
    * Field(new ArrayList<Powerup>( Arrays.asList(avocado, twinkie))), new
    * Field(new ArrayList<Powerup>( Arrays.asList(twinkie, avocado))), new
    * Field(new ArrayList<Powerup>( Arrays.asList(twinkie, twinkie))));
    */
 }
 // test the changeHunger(int) and changeHunger(float) methods
 void testChangeHunger(Tester t) {
   resetPlayer();
   player.changeHunger(0.1f);
   t.checkExpect(player.hunger, 730f);
   resetPlayer();
   player.changeHunger(-0.1f);
   t.checkExpect(player.hunger, 630f);
   resetPlayer();
   player.changeHunger(1);
   t.checkExpect(player.hunger, 701f);
   resetPlayer();
   player.changeHunger(-1);
   t.checkExpect(player.hunger, 699f);
   player.changeHunger(-1000);
   t.checkExpect(player.hunger, 0f);
   player.changeHunger(-1000f);
   t.checkExpect(player.hunger, 0f);
 }
 // test the onKeyEvent method
 void testOnKeyEvent(Tester t) {
   ctf.onKeyEvent(" ");
   t.checkExpect(ctf.isJumping, true);
 }
 // test the move method
 void testMove(Tester t) {
   player.move(500, 30);
   t.checkExpect(player.loc, new Posn(500, 350));
 }
예제 #20
0
 // tests for method sum()
 boolean testSum(Tester t) {
   ILoI mt = new MT();
   ILoI l1 = new Cons(1, mt);
   ILoI l2 = new Cons(2, l1);
   return t.checkExpect(mt.sum(), 0) && t.checkExpect(l1.sum(), 1) && t.checkExpect(l2.sum(), 3);
 }
예제 #21
0
 // tests for method partyCount()
 boolean testPartyCount(Tester t) {
   return t.checkExpect(this.ann.partyCount(), 8) && t.checkExpect(this.jan.partyCount(), 3);
 }
예제 #22
0
 // tests for method hasDistantBuddy()
 boolean testHasDistantBuddy(Tester t) {
   return t.checkExpect(this.ann.hasDistantBuddy(this.fay), true)
       && t.checkExpect(this.ann.hasDistantBuddy(this.kim), false);
 }
예제 #23
0
 // tests for method countCommonBuddies()
 boolean testCountCommonBuddies(Tester t) {
   return t.checkExpect(this.kim.countCommonBuddies(this.len), 1)
       && t.checkExpect(this.hank.countCommonBuddies(this.len), 0);
 }
예제 #24
0
 // test for method hasDirectBuddy()
 boolean testHasDirectBuddy(Tester t) {
   return t.checkExpect(this.ann.hasDirectBuddy(this.cole), true)
       && t.checkExpect(this.hank.hasDirectBuddy(this.ann), false);
 }
 // test the changeScore method
 void testChangeScore(Tester t) {
   player.changeScore(100);
   t.checkExpect(player.score, 100);
   player.changeScore(-100);
   t.checkExpect(player.score, 0);
 }
예제 #26
0
 // test the method isSorted for the lists of Strings
 boolean testIsSorted(Tester t) {
   return t.checkExpect(this.mtLoString.isSorted(), true)
       && t.checkExpect(this.sorted.isSorted(), true)
       && t.checkExpect(this.unsorted.isSorted(), false)
       && t.checkExpect(this.unsorted2.isSorted(), false);
 }
예제 #27
0
 // test the method isPalindromeList for the lists of Strings
 boolean testIsPalindromeList(Tester t) {
   return t.checkExpect(this.mtLoString.isPalindromeList(), true)
       && t.checkExpect(this.sorted.isPalindromeList(), false)
       && t.checkExpect(this.palindrome.isPalindromeList(), true);
 }
 // test the hitPowerup method
 void testHitPowerup(Tester t) {
   t.checkExpect(ctf.hitPowerup(), -1);
   ctf.field.addPowerup(0, CollectTheFruit.height - 30);
   t.checkExpect(ctf.hitPowerup(), 0);
 }
 // test the removePowerups method
 void removePowerups(Tester t) {
   ctf.removePups(0);
   t.checkExpect(ctf.field.pUps, new ArrayList<Powerup>());
 }
 // test the onTick method
 void testOnTick(Tester t) {
   resetCTF();
   ctf.onTick();
   t.checkExpect(ctf.player.loc, new Posn(6, CollectTheFruit.height - 30));
 }