FileDocCategorySizeDatePackage
_IntList.javaAPI DocAndroid 1.5 API2066Wed May 06 22:41:02 BST 2009com.android.dx.util._tests

_IntList

public class _IntList extends TestCase
Test the class com.android.dx.util.IntList.

Fields Summary
Constructors Summary
Methods Summary
private static java.lang.Stringlabel(int n, int m)

        return "(" + n + "/" + m + ")";
    
public voidtest_addSorted()

        IntList list = new IntList(2);

        list.add(9);
        list.add(12);

        assertTrue(list.contains(9));
        assertTrue(list.contains(12));
    
public voidtest_addUnsorted()

        IntList list = new IntList(2);

        list.add(12);
        list.add(9);

        assertTrue(list.contains(12));
        assertTrue(list.contains(9));
    
public voidtest_contains()

        for (int sz = 0; sz < 100; sz++) {
            IntList list = new IntList(sz);
            for (int i = 0; i < sz; i++) {
                list.add(i * 2);
            }
            for (int i = (sz * 2) - 1; i >= 0; i--) {
                boolean contains = list.contains(i);
                if ((i & 1) == 0) {
                    assertTrue(label(sz, i), contains);
                } else {
                    assertFalse(label(sz, i), contains);
                }
            }
            assertFalse(label(sz, -1), list.contains(-1));
            assertFalse(label(sz, sz * 2), list.contains(sz * 2));
        }