2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.util;
21 import gov.nasa.jpf.util.test.TestJPF;
23 import org.junit.Test;
26 * unit test for gov.nasa.jpf.util.IntVector
28 public class IntVectorTest extends TestJPF {
31 public void testPackedBoolean() {
32 IntVector v = new IntVector();
33 boolean[] b = { true,true,true,true, false,false,false,false };
37 System.out.println(Integer.toHexString(x));
38 assert x == 0xf0000000;
47 System.out.println(Integer.toHexString(x));
48 assert x == 0x80000001;
57 System.out.println(Integer.toHexString(x));
58 assert x == 0x80000000;
60 System.out.println(Integer.toHexString(x));
61 assert x == 0x80000000;
70 System.out.println(Integer.toHexString(x));
71 assert x == 0x40000000;
75 public void testPackedByte() {
76 IntVector v = new IntVector();
77 byte[] b = { (byte)0xf, 0, (byte)0xf, 0 };
82 System.out.println(Integer.toHexString(x));
83 assert x == 0x0f000f00;
92 System.out.println(Integer.toHexString(x));
93 assert x == 0xff000000;
95 System.out.println(Integer.toHexString(x));
96 assert x == 0xff000000;
103 assert v.size() == 2;
105 System.out.println(Integer.toHexString(x));
106 assert x == 0x00ff0000;
111 public void testPackedChar() {
112 IntVector v = new IntVector();
113 char[] c = { (char)0xffff, 0};
117 System.out.println(Integer.toHexString(x));
118 assert v.size() == 1;
119 assert x == 0xffff0000;
126 assert v.size() == 2;
128 System.out.println(Integer.toHexString(x));
129 assert x == 0x00ff0000;
133 public void testLongBits(){
134 IntVector v = new IntVector();
136 long[] a = { 1, 0x00000000ffff0000L};
138 assert v.size() == 4;
141 System.out.println(Integer.toHexString(x));
144 System.out.println(Integer.toHexString(x));
147 System.out.println(Integer.toHexString(x));
150 System.out.println(Integer.toHexString(x));
151 assert x == 0xffff0000;
158 System.out.println(Integer.toHexString(x));
160 System.out.println(Integer.toHexString(x));
161 assert x == 0xffffffff;
163 System.out.println(Integer.toHexString(x));
164 assert x == 0xffffffff;