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.qrcode.decoder;
19 import junit.framework.TestCase;
22 * @author srowen@google.com (Sean Owen)
24 public final class BitSourceTestCase extends TestCase {
26 public void testSource() {
27 byte[] bytes = new byte[]{(byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5};
28 BitSource source = new BitSource(bytes);
29 assertEquals(40, source.available());
30 assertEquals(0, source.readBits(1));
31 assertEquals(39, source.available());
32 assertEquals(0, source.readBits(6));
33 assertEquals(33, source.available());
34 assertEquals(1, source.readBits(1));
35 assertEquals(32, source.available());
36 assertEquals(2, source.readBits(8));
37 assertEquals(24, source.available());
38 assertEquals(12, source.readBits(10));
39 assertEquals(14, source.available());
40 assertEquals(16, source.readBits(8));
41 assertEquals(6, source.available());
42 assertEquals(5, source.readBits(6));
43 assertEquals(0, source.available());