Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.40 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import junit.framework.TestCase;
  2. import foodManagement.*;
  3.  
  4. public class PublicTests extends TestCase {
  5.  
  6.         private static final Food BACON = Food.FOOD_OBJECTS[0];
  7.         private static final Food WAFFLE = Food.FOOD_OBJECTS[1];
  8.         private static final Food EGG = Food.FOOD_OBJECTS[2];
  9.         private static final Food OJ = Food.FOOD_OBJECTS[3];
  10.         private static final Food MILK = Food.FOOD_OBJECTS[4];
  11.        
  12.         public void testDefaultConstructorAndGetSize() {
  13.                 SortedListOfImmutables list = new SortedListOfImmutables();
  14.                 assertTrue(list.getSize() == 0);
  15.                 assertEquals("[  ]", list.toString());
  16.         }
  17.        
  18.         public void testListSimpleAdd() {
  19.                 SortedListOfImmutables list = new SortedListOfImmutables();
  20.                 for (int i = Food.FOOD_OBJECTS.length - 1; i >= 0; i--) {
  21.                         list.add(Food.FOOD_OBJECTS[i]);
  22.                 }
  23.                 assertEquals(Food.FOOD_OBJECTS.length, list.getSize()); ****THIS IS THE ONE THATS FAILING***
  24.                 assertEquals("[ Bacon, Cereal, Coffee, Croissant, Donut, Egg, Hashbrowns, Melon, Milk, Orange Juice, Pancakes, Pie, Toast, Waffle ]",
  25.                                 list.toString());
  26.                
  27.                 list.add(BACON);
  28.                 list.add(WAFFLE);
  29.                 list.add(EGG);
  30.                 list.add(MILK);
  31.                 list.add(EGG);
  32.                 list.add(OJ);
  33.                 assertEquals(20, list.getSize());
  34.                 assertEquals("[ Bacon, Bacon, Cereal, Coffee, Croissant, Donut, Egg, Egg, Egg, Hashbrowns, Melon, Milk, Milk, " +
  35.                                 "Orange Juice, Orange Juice, Pancakes, Pie, Toast, Waffle, Waffle ]" , list.toString());
  36.         }      
  37.        
  38.        
  39. }