blob: 4fc994e398e02ced51e40942f6e7d0c127602f46 [file] [log] [blame]
Jian Li47671902016-08-11 01:18:18 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
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 */
16package org.onlab.util;
17
18import org.junit.Test;
19
20import static org.hamcrest.Matchers.is;
21import static org.junit.Assert.assertThat;
22
23/**
24 * Unit tests for ByteOperator.
25 */
26public class ByteOperatorTest {
27
28 @Test
29 public void testGetBit() {
Jian Li0a439d22017-02-06 01:05:41 +090030 final byte[] number = new byte[] {1, 2, 4, 8, 16, 32, 64, -128};
Jian Li47671902016-08-11 01:18:18 +090031
Jian Li0a439d22017-02-06 01:05:41 +090032 for (int i = 0; i < number.length; i++) {
33 for (int j = 0; j < 8; j++) {
34 assertThat(ByteOperator.getBit(number[i], j), is(i == j));
35 }
36 }
Jian Li47671902016-08-11 01:18:18 +090037 }
38}