Examples of ArrayListOfShorts


Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

    assertEquals(1, c.size());
  }

  @Test
  public void testIntersection4() {
    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add((short) 3);

    ArrayListOfShorts b = new ArrayListOfShorts();
    b.add((short) 0);

    ArrayListOfShorts c = a.intersection(b);

    assertEquals(0, c.size());
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

 
  @Test
  public void testMerge1() {
    //CASE: interleaved

    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add((short) 3);
    a.add((short) 7);
    a.add((short) 10);

    ArrayListOfShorts b = new ArrayListOfShorts();
    b.add((short) 0);
    b.add((short) 4);
    b.add((short) 9);

    ArrayListOfShorts c = a.merge(b);

    assertEquals(6, c.size());
    assertEquals(0, c.get(0));
    assertEquals(3, c.get(1));
    assertEquals(4, c.get(2));
    assertEquals(7, c.get(3));
    assertEquals(9, c.get(4));
    assertEquals(10, c.get(5));

    // c should be same as c2
    ArrayListOfShorts c2 = b.merge(a);
    assertEquals(c, c2);
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

  @Test
  public void testMerge2() {
    //CASE: append

    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add((short) 3);
    a.add((short) 7);
    a.add((short) 10);

    ArrayListOfShorts b = new ArrayListOfShorts();
    b.add((short) 11);
    b.add((short) 19);
    b.add((short) 21);

    ArrayListOfShorts c = a.merge(b);

    assertEquals(6, c.size());
    assertEquals(3, c.get(0));
    assertEquals(7, c.get(1));
    assertEquals(10, c.get(2));
    assertEquals(11, c.get(3));
    assertEquals(19, c.get(4));
    assertEquals(21, c.get(5));

    ArrayListOfShorts c2 = b.merge(a);
    assertEquals(c, c2);
}
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

  @Test
  public void testMerge3() {
    //CASE: one of the lists are empty
   
    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add((short) 3);
    a.add((short) 7);
    a.add((short) 10);
   
    ArrayListOfShorts b = new ArrayListOfShorts();

    ArrayListOfShorts c = a.merge(b);
    assertEquals(c, a);
   
    ArrayListOfShorts c2 = b.merge(a);
    assertEquals(c, c2);  
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

    assertEquals(c, c2);  
  }

  @Test
  public void testSubList() {
    ArrayListOfShorts a = new ArrayListOfShorts(new short[] {1, 2, 3, 4, 5, 6, 7});
    ArrayListOfShorts b = a.subList(1, 5);
    assertEquals(5, b.size());
    assertEquals(2, b.get(0));
    assertEquals(3, b.get(1));
    assertEquals(4, b.get(2));
    assertEquals(5, b.get(3));
    assertEquals(6, b.get(4));

    a.clear();
    // Make sure b is a new object.
    assertEquals(5, b.size());
    assertEquals(2, b.get(0));
    assertEquals(3, b.get(1));
    assertEquals(4, b.get(2));
    assertEquals(5, b.get(3));
    assertEquals(6, b.get(4));
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

    assertEquals(6, b.get(4));
  }

  @Test
  public void testAddUnique() {
    ArrayListOfShorts a = new ArrayListOfShorts(new short[] {1, 2, 3, 4, 5, 6, 7});
    a.addUnique(new short[] {8, 0, 2, 5, -1, 11, 9});
    assertEquals(12, a.size());
    assertEquals(0, a.get(8));
    assertEquals(-1, a.get(9));
    assertEquals(11, a.get(10));
    assertEquals(9, a.get(11));
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

public class ArrayListOfShortsTest {
  short neg_one=-1, zero=0, one=1, two=2, three=3, four=4, five=5, six=6, seven=7, nine=9;

  @Test
  public void testRemoveWithinBounds(){
    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add(one).add(three).add(five).add(seven);
   
    assertTrue(one == a.remove(0));

    assertTrue(three == a.get(0));
    assertTrue(five == a.get(1));
   
    assertTrue(five == a.remove(1));
    assertTrue(seven == a.get(2));
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

    assertTrue(seven == a.get(2));
  }
 
  @Test (expected=ArrayIndexOutOfBoundsException.class)
  public void testRemoveOutOfBounds(){
    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add(one).add(three).add(five).add(seven);

    a.remove(4);
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

    a.remove(4);
  }

  @Test (expected=ArrayIndexOutOfBoundsException.class)
  public void testRemoveOutOfBounds2(){
    ArrayListOfShorts a = new ArrayListOfShorts();
    a.add(neg_one);
    a.remove(-1);
  }
View Full Code Here

Examples of edu.umd.cloud9.util.array.ArrayListOfShorts

  public void testBasic1() {
    int size = 10000;
    Random r = new Random();
    short[] shorts = new short[size];

    ArrayListOfShorts list = new ArrayListOfShorts();
    for (int i = 0; i < size; i++) {
      short k = (short) r.nextInt(size);
      list.add(k);
      shorts[i] = k;
    }

    for (int i = 0; i < size; i++) {
      int v = list.get(i);

      assertEquals(shorts[i], v);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.