KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > core > TestTinyBitSet


1 /*
2  * Copyright 2003 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc testName) {
57         super(testName);
58     }
59     
60     public static void main(String JavaDoc[] 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