[cvs] / jsr166 / src / test / tck / VectorTest.java Repository:
ViewVC logotype

View of /jsr166/src/test/tck/VectorTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (download) (annotate)
Sat Mar 11 17:33:32 2017 UTC (3 months, 1 week ago) by jsr166
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -2 lines
fix unused imports reported by errorprone [RemoveUnusedImports]
/*
 * Written by Doug Lea and Martin Buchholz with assistance from
 * members of JCP JSR-166 Expert Group and released to the public
 * domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

import java.util.Vector;
import java.util.List;

import junit.framework.Test;

public class VectorTest extends JSR166TestCase {
    public static void main(String[] args) {
        main(suite(), args);
    }

    public static Test suite() {
        class Implementation implements CollectionImplementation {
            public Class<?> klazz() { return Vector.class; }
            public List emptyCollection() { return new Vector(); }
            public Object makeElement(int i) { return i; }
            public boolean isConcurrent() { return false; }
            public boolean permitsNulls() { return true; }
        }
        class SubListImplementation extends Implementation {
            public List emptyCollection() {
                return super.emptyCollection().subList(0, 0);
            }
        }
        return newTestSuite(
                VectorTest.class,
                CollectionTest.testSuite(new Implementation()),
                CollectionTest.testSuite(new SubListImplementation()));
    }

    /**
     * tests for setSize()
     */
    public void testSetSize() {
        final Vector v = new Vector();
        for (int n : new int[] { 100, 5, 50 }) {
            v.setSize(n);
            assertEquals(n, v.size());
            assertNull(v.get(0));
            assertNull(v.get(n - 1));
            assertThrows(
                    ArrayIndexOutOfBoundsException.class,
                    new Runnable() { public void run() { v.setSize(-1); }});
            assertEquals(n, v.size());
            assertNull(v.get(0));
            assertNull(v.get(n - 1));
        }
    }

}

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8