Added more test cases
[zxing.git] / core / test / src / com / google / zxing / common / BitArrayTestCase.java
1 /*
2  * Copyright 2007 Google Inc.
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
17 package com.google.zxing.common;
18
19 import junit.framework.TestCase;
20
21 /**
22  * @author srowen@google.com (Sean Owen)
23  */
24 public final class BitArrayTestCase extends TestCase {
25
26   public void testGetSet() {
27     BitArray array = new BitArray(33);
28     for (int i = 0; i < 33; i++) {
29       assertFalse(array.get(i));
30       array.set(i);
31       assertTrue(array.get(i));
32     }
33   }
34
35   public void testSetBulk() {
36     BitArray array = new BitArray(64);
37     array.setBulk(32, 0xFFFF0000);
38     for (int i = 0; i < 48; i++) {
39       assertFalse(array.get(i));
40     }
41     for (int i = 48; i < 64; i++) {
42       assertTrue(array.get(i));
43     }
44   }
45
46   public void testClear() {
47     BitArray array = new BitArray(32);
48     for (int i = 0; i < 32; i++) {
49       array.set(i);
50     }
51     array.clear();
52     for (int i = 0; i < 32; i++) {
53       assertFalse(array.get(i));
54     }
55   }
56
57   public void testGetArray() {
58     BitArray array = new BitArray(64);
59     array.set(0);
60     array.set(63);
61     int[] ints = array.getBitArray();
62     assertEquals(1, ints[0]);
63     assertEquals(Integer.MIN_VALUE, ints[1]);
64   }
65
66 }