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;
22 import org.junit.Test;
26 * regression test for SortedArrayObjectSet
28 public class SortedArrayObjectSetTest extends TestJPF {
30 static class X implements Comparable<X> {
40 public int compareTo (X other){
45 public String toString(){
50 public boolean equals(Object o){
54 if (id.equals(other.id)){
65 public void testBasic(){
66 SortedArrayObjectSet<X> s = new SortedArrayObjectSet<X>();
69 X o2 = new X("20",20);
74 System.out.println(s);
76 System.out.println(s);
78 System.out.println(s);
80 System.out.println(s);
82 System.out.println(s);
84 assertTrue(s.size() == 4);
85 assertTrue(s.contains(o1));
86 assertTrue(s.contains(o2));
87 assertTrue(s.contains(o3));
88 assertTrue(s.contains(o4));
90 X o3a = new X("5a", 5);
92 System.out.println(s);
93 assertTrue(s.size() == 5);
94 assertTrue(s.contains(o3a));
97 System.out.println(s);
98 assertTrue(s.size() == 4);
99 assertFalse(s.contains(o3a));
100 assertTrue(s.contains(o3));