2 * Copyright 2007 Google Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.google.zxing.common;
19 import junit.framework.TestCase;
22 * @author srowen@google.com (Sean Owen)
24 public final class BitMatrixTestCase extends TestCase {
26 public void testGetSet() {
27 BitMatrix matrix = new BitMatrix(33);
28 assertEquals(33, matrix.getDimension());
29 for (int i = 0; i < 33; i++) {
30 for (int j = 0; j < 33; j++) {
36 for (int i = 0; i < 33; i++) {
37 for (int j = 0; j < 33; j++) {
38 assertEquals(i * j % 3 == 0, matrix.get(i, j));
43 public void testSetRegion() {
44 BitMatrix matrix = new BitMatrix(5);
45 matrix.setRegion(1, 1, 3, 3);
46 for (int i = 0; i < 5; i++) {
47 for (int j = 0; j < 5; j++) {
48 assertEquals(i >= 1 && i <= 3 && j >= 1 && j <= 3, matrix.get(i, j));
53 public void testGetBits() {
54 BitMatrix matrix = new BitMatrix(6);
57 int[] bits = matrix.getBits();
58 assertEquals(1, bits[0]);
59 assertEquals(8, bits[1]);