1 16 package net.sf.cglib.core; 17 18 import net.sf.cglib.CodeGenTestCase; 19 import junit.framework.*; 20 21 public class TestTinyBitSet extends TestCase { 22 public void testGetSetClear() { 23 TinyBitSet b = new TinyBitSet(); 24 assertTrue(!b.get(5)); 25 b.set(5); 26 assertTrue(b.get(5)); 27 b.clear(5); 28 assertTrue(!b.get(5)); 29 } 30 31 public void testLength() { 32 TinyBitSet b = new TinyBitSet(); 33 b.set(10); 34 assertTrue(b.length() == 11); 35 b.set(15); 36 assertTrue(b.length() == 16); 37 b.set(14); 38 assertTrue(b.length() == 16); 39 } 40 41 public void testCardinality() { 42 TinyBitSet b = new TinyBitSet(); 43 assertTrue(b.cardinality() == 0); 44 b.set(1); 45 assertTrue(b.cardinality() == 1); 46 b.set(4); 47 assertTrue(b.cardinality() == 2); 48 b.set(10); 49 assertTrue(b.cardinality() == 3); 50 b.set(10); 51 assertTrue(b.cardinality() == 3); 52 b.clear(10); 53 assertTrue(b.cardinality() == 2); 54 } 55 56 public TestTinyBitSet(String testName) { 57 super(testName); 58 } 59 60 public static void main(String [] args) { 61 junit.textui.TestRunner.run(suite()); 62 } 63 64 public static Test suite() { 65 return new TestSuite(TestTinyBitSet.class); 66 } 67 } 68 | Popular Tags |