Package java.util

Examples of java.util.BitSet.flip()


        }
        assertTrue("Shouldn't have flipped bit 64", !bs.get(64));

        // more boundary testing
        bs = new BitSet(32);
        bs.flip(0, 64);
        for (int i = 0; i < 64; i++) {
            assertTrue("Failed to flip bit " + i, bs.get(i));
        }
        assertTrue("Shouldn't have flipped bit 64", !bs.get(64));
View Full Code Here


            assertTrue("Failed to flip bit " + i, bs.get(i));
        }
        assertTrue("Shouldn't have flipped bit 64", !bs.get(64));

        bs = new BitSet(32);
        bs.flip(0, 65);
        for (int i = 0; i < 65; i++) {
            assertTrue("Failed to flip bit " + i, bs.get(i));
        }
        assertTrue("Shouldn't have flipped bit 65", !bs.get(65));
View Full Code Here

        bs = new BitSet(128);
        bs.set(7);
        bs.set(10);
        bs.set(72);
        bs.set(110);
        bs.flip(9, 74);
        for (int i = 0; i < 7; i++) {
            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
        }
        assertTrue("Shouldn't have flipped bit 7", bs.get(7));
        assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
View Full Code Here

        bs.set(10);
        bs.set(72);
        bs.set(110);
        bs.set(181);
        bs.set(220);
        bs.flip(9, 219);
        for (int i = 0; i < 7; i++) {
            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
        }
        assertTrue("Shouldn't have flipped bit 7", bs.get(7));
        assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
View Full Code Here

        }

        // test illegal args
        bs = new BitSet(10);
        try {
            bs.flip(-1, 3);
            fail("Test1: Attempt to flip with  negative index failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
        }

        try {
View Full Code Here

            fail("Test1: Attempt to flip with  negative index failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
        }

        try {
            bs.flip(2, -1);
            fail("Test2: Attempt to flip with negative index failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
        }

        try {
View Full Code Here

            fail("Test2: Attempt to flip with negative index failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
        }

        try {
            bs.flip(4, 2);
            fail("Test4: Attempt to flip with illegal args failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
        }
    }
View Full Code Here

        // Test for method void java.util.BitSet.flip(int)
        BitSet bs = new BitSet();
        bs.clear(8);
        bs.clear(9);
        bs.set(10);
        bs.flip(9);
        assertTrue("Failed to flip bit", !bs.get(8));
        assertTrue("Failed to flip bit", bs.get(9));
        assertTrue("Failed to flip bit", bs.get(10));

        bs.set(8);
View Full Code Here

        assertTrue("Failed to flip bit", bs.get(10));

        bs.set(8);
        bs.set(9);
        bs.clear(10);
        bs.flip(9);
        assertTrue("Failed to flip bit", bs.get(8));
        assertTrue("Failed to flip bit", !bs.get(9));
        assertTrue("Failed to flip bit", !bs.get(10));

        try {
View Full Code Here

        assertTrue("Failed to flip bit", bs.get(8));
        assertTrue("Failed to flip bit", !bs.get(9));
        assertTrue("Failed to flip bit", !bs.get(10));

        try {
            bs.flip(-1);
            fail("Attempt to flip at negative index failed to generate exception");
        } catch (IndexOutOfBoundsException e) {
            // Correct behaviour
        }
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.