示例#1
0
 /** Prueba unitaria para {@link Pila#esVacia}. */
 @Test
 public void testEsVacia() {
   Assert.assertTrue(pila.esVacia());
   pila.mete(1);
   Assert.assertFalse(pila.esVacia());
   pila.saca();
   Assert.assertTrue(pila.esVacia());
 }
示例#2
0
 /** Prueba unitaria para {@link MeteSaca#mira}. */
 @Test
 public void testMira() {
   try {
     pila.mira();
     Assert.fail();
   } catch (NoSuchElementException nsee) {
   }
   for (int i = 0; i < total; i++) {
     pila.mete(i);
     Assert.assertTrue(pila.mira() == i);
   }
 }
示例#3
0
 /** Prueba unitaria para {@link Pila#saca}. */
 @Test
 public void testSaca() {
   try {
     pila.saca();
     Assert.fail();
   } catch (NoSuchElementException nsee) {
   }
   int[] a = new int[total];
   for (int i = 0; i < total; i++) {
     a[i] = i;
     pila.mete(a[i]);
   }
   int c = 0;
   while (!pila.esVacia()) Assert.assertTrue(pila.saca() == a[total - ++c]);
 }
示例#4
0
 /** Prueba unitaria para {@link Pila#mete}. */
 @Test
 public void testMete() {
   try {
     pila.mete(null);
     Assert.fail();
   } catch (IllegalArgumentException iae) {
   }
   for (int i = 0; i < total; i++) pila.mete(i);
   int c = total - 1;
   int t = 0;
   while (!pila.esVacia()) {
     Assert.assertTrue(pila.saca() == c--);
     t++;
   }
   Assert.assertTrue(t == total);
 }
示例#5
0
 /** Prueba unitaria para {@link Pila#equals}. */
 @Test
 public void testEquals() {
   Assert.assertFalse(pila.equals(null));
   Assert.assertFalse(pila.equals(""));
   Assert.assertFalse(pila.equals(new Cola<Integer>()));
   Pila<Integer> pila2 = new Pila<Integer>();
   Assert.assertTrue(pila.equals(pila2));
   for (int i = 0; i < total; i++) {
     pila.mete(i);
     Assert.assertFalse(pila.equals(pila2));
     pila2.mete(i);
     Assert.assertTrue(pila.equals(pila2));
   }
 }