At last update to JUnit 4.x
[zxing.git] / core / test / src / com / google / zxing / common / BitSourceTestCase.java
1 /*
2  * Copyright 2007 ZXing authors
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 org.junit.Assert;
20 import org.junit.Test;
21
22 /**
23  * @author Sean Owen
24  */
25 public final class BitSourceTestCase extends Assert {
26
27   @Test
28   public void testSource() {
29     byte[] bytes = {(byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5};
30     BitSource source = new BitSource(bytes);
31     assertEquals(40, source.available());
32     assertEquals(0, source.readBits(1));
33     assertEquals(39, source.available());
34     assertEquals(0, source.readBits(6));
35     assertEquals(33, source.available());
36     assertEquals(1, source.readBits(1));
37     assertEquals(32, source.available());
38     assertEquals(2, source.readBits(8));
39     assertEquals(24, source.available());
40     assertEquals(12, source.readBits(10));
41     assertEquals(14, source.available());
42     assertEquals(16, source.readBits(8));
43     assertEquals(6, source.available());
44     assertEquals(5, source.readBits(6));
45     assertEquals(0, source.available());
46   }
47
48 }