001    package daikon.test;
002    
003    import daikon.*;
004    import junit.framework.*;
005    import java.util.*;
006    import java.io.*;
007    import plume.*;
008    
009    @SuppressWarnings("nullness")   // testing code
010    public final class TestQuant extends TestCase {
011    
012      public static void main(String[] args) {
013        junit.textui.TestRunner.run(new TestSuite(TestPlume.class));
014      }
015    
016      public TestQuant(String name) {
017        super(name);
018      }
019    
020      public static final void assert_arrays_equals(int[] a1, int[] a2) {
021        TestPlume.assert_arrays_equals(a1, a2);
022      }
023    
024      private static int[] removeAdjacentDups(int[] a) {
025        if (a.length == 0) { return new int[]{}; }
026        int[] intermediate = new int[a.length];
027        int length = 0;
028        for (int i = 0 ; i < a.length-1 ; i++) {
029          if (a[i] != a[i+1]) {
030            intermediate[length++] = a[i];
031          }
032        }
033        intermediate[length++] = a[a.length-1];
034        int[] retval = new int[length];
035        for (int i = 0 ; i < length ; i++) {
036          retval[i] = intermediate[i];
037        }
038        return retval;
039      }
040    
041    // These methods aren't used to express any invariants; no need for them.
042    //   public static void test_min() {
043    //     assert Quant.min(new int[] { 1,2,3 }) == 1;
044    //     assert Quant.min(new int[] { 2,33,1 }) == 1;
045    //     assert Quant.min(new int[] { 3,-2,1 }) == -2;
046    //     assert Quant.min(new int[] { 3 }) == 3;
047    //   }
048    
049    //   public static void test_max() {
050    //     assert Quant.max(new int[] { 1,2,3 }) == 3;
051    //     assert Quant.max(new int[] { 2,33,1 }) == 33;
052    //     assert Quant.max(new int[] { 3,-2,1 }) == 3;
053    //     assert Quant.max(new int[] { 3 }) == 3;
054    //   }
055    
056      public static void test_concat() {
057        assert_arrays_equals(Quant.concat(new int[] {}, new int[] {}), new int[] {});
058        assert_arrays_equals(Quant.concat(new int[] { 1 }, new int[] {}), new int[] { 1 });
059        assert_arrays_equals(Quant.concat(new int[] { }, new int[] { 1 }), new int[] { 1 });
060        assert_arrays_equals(Quant.concat(new int[] { 1 }, new int[] { 1 }), new int[] { 1, 1 });
061        assert_arrays_equals(Quant.concat(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }), new int[] { 1, 2, 3, 3, 4, 5 });
062        assert_arrays_equals(Quant.concat(new int[] { -1, }, new int[] { 2, 3, 4, 5 }), new int[] { -1, 2, 3, 4, 5 });
063        assert_arrays_equals(Quant.concat(new int[] { -1, 2, 3, 4 }, new int[] { 5 }), new int[] { -1, 2, 3, 4, 5 });
064      }
065    
066      public static void test_union() {
067        { int[] u = Quant.union(new int[] {}, new int[] {}); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] {}); }
068        { int[] u = Quant.union(new int[] { 1 }, new int[] {}); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1 }); }
069        { int[] u = Quant.union(new int[] { }, new int[] { 1 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1 }); }
070        { int[] u = Quant.union(new int[] { 1 }, new int[] { 1 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1 }); }
071        { int[] u = Quant.union(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1, 2, 3, 4, 5 }); }
072        { int[] u = Quant.union(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1, 2, 3 }); }
073        { int[] u = Quant.union(new int[] { -1 }, new int[] { 2, 3, 4, 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { -1, 2, 3, 4, 5 }); }
074        { int[] u = Quant.union(new int[] { -1, 2, 3, 4 }, new int[] { 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { -1, 2, 3, 4, 5 }); }
075      }
076    
077      public static void test_intersection() {
078        { int[] u = Quant.intersection(new int[] {}, new int[] {}); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] {}); }
079        { int[] u = Quant.intersection(new int[] { 1 }, new int[] {}); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { }); }
080        { int[] u = Quant.intersection(new int[] { }, new int[] { 1 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { }); }
081        { int[] u = Quant.intersection(new int[] { 1 }, new int[] { 1 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1 }); }
082        { int[] u = Quant.intersection(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 1, 2, 3 }); }
083        { int[] u = Quant.intersection(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { 3 }); }
084        { int[] u = Quant.intersection(new int[] { -1 }, new int[] { 2, 3, 4, 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { }); }
085        { int[] u = Quant.intersection(new int[] { -1, 2, 3, 4 }, new int[] { 5 }); Arrays.sort(u); assert_arrays_equals(removeAdjacentDups(u), new int[] { }); }
086      }
087    
088      public static void test_setDiff() {
089        assert_arrays_equals(Quant.setDiff(new int[] {}, new int[] {}), new int[] {});
090        assert_arrays_equals(Quant.setDiff(new int[] { 1 }, new int[] {}), new int[] { 1 });
091        assert_arrays_equals(Quant.setDiff(new int[] { }, new int[] { 1 }), new int[] { });
092        assert_arrays_equals(Quant.setDiff(new int[] { 1 }, new int[] { 1 }), new int[] { });
093        assert_arrays_equals(Quant.setDiff(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }), new int[] { });
094        assert_arrays_equals(Quant.setDiff(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }), new int[] { 1, 2 });
095        assert_arrays_equals(Quant.setDiff(new int[] { -1, }, new int[] { 2, 3, 4, 5 }), new int[] { -1 });
096        assert_arrays_equals(Quant.setDiff(new int[] { -1, 2, 3, 4 }, new int[] { 5 }), new int[] { -1, 2, 3, 4 });
097      }
098    
099      public static void test_setEqual() {
100        assert Quant.setEqual(new int[] {}, new int[] {}) == true;
101        assert Quant.setEqual(new int[] { 1 }, new int[] {}) == false;
102        assert Quant.setEqual(new int[] { }, new int[] { 1 }) == false;
103        assert Quant.setEqual(new int[] { 1 }, new int[] { 1 }) == true;
104        assert Quant.setEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
105        assert Quant.setEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
106        assert Quant.setEqual(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
107        assert Quant.setEqual(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }) == false;
108        assert Quant.setEqual(new int[] { -1, }, new int[] { 2, 3, 4, 5 }) == false;
109        assert Quant.setEqual(new int[] { -1, 2, 3, 4 }, new int[] { 5 }) == false;
110      }
111    
112      public static void test_subsetOf() {
113        assert Quant.subsetOf(new int[] { -1 }, new int[] { -1, 1 }) == true;
114        assert Quant.subsetOf(new int[] { -1, 0, 1 }, new int[] { -1, 1 }) == false;
115        assert Quant.subsetOf(new int[] { -1, 1 }, new int[] { -1, 1 }) == true;
116        assert Quant.subsetOf(new int[] { -1, 2, 3, 4 }, new int[] { 5 }) == false;
117        assert Quant.subsetOf(new int[] { -1, }, new int[] { 2, 3, 4, 5 }) == false;
118        assert Quant.subsetOf(new int[] { 1 }, new int[] { -1, 1 }) == true;
119        assert Quant.subsetOf(new int[] { 1 }, new int[] { 1 }) == true;
120        assert Quant.subsetOf(new int[] { 1 }, new int[] { 1, 2, 3 }) == true;
121        assert Quant.subsetOf(new int[] { 1 }, new int[] {}) == false;
122        assert Quant.subsetOf(new int[] { 1, 2 }, new int[] { 1 }) == false;
123        assert Quant.subsetOf(new int[] { 1, 2 }, new int[] { 1, 2, 3}) == true;
124        assert Quant.subsetOf(new int[] { 1, 2 }, new int[] {}) == false;
125        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
126        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 2 }) == false;
127        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 2, 3 }) == false;
128        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
129        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
130        assert Quant.subsetOf(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }) == false;
131        assert Quant.subsetOf(new int[] { 2, 1 }, new int[] { 1, 2, 3 }) == true;
132        assert Quant.subsetOf(new int[] { 2, 3 }, new int[] { 3, 3, 3, 3}) == false;
133        assert Quant.subsetOf(new int[] { 3, 1 }, new int[] { 1, 2, 3 }) == true;
134        assert Quant.subsetOf(new int[] { 3, 3 }, new int[] { 3, 3, 3, 3}) == true;
135        assert Quant.subsetOf(new int[] { }, new int[] { -1, 1 }) == true;
136        assert Quant.subsetOf(new int[] { }, new int[] { 1 }) == true;
137        assert Quant.subsetOf(new int[] { }, new int[] { 2, 3, 1}) == true;
138        assert Quant.subsetOf(new int[] { }, new int[] { }) == true;
139      }
140    
141      public static void test_subsetOf_different_types() {
142        assert Quant.subsetOf(new byte[] {}, new int[] {}) == true;
143        assert Quant.subsetOf(new long[] {}, new long[] {}) == true;
144        assert Quant.subsetOf(new byte[] { 1 }, new long[] {}) == false;
145        assert Quant.subsetOf(new short[] { 1, 2 }, new short[] {}) == false;
146        assert Quant.subsetOf(new long[] { }, new short[] { 1 }) == true;
147        assert Quant.subsetOf(new int[] { 1 }, new short[] { 1 }) == true;
148        assert Quant.subsetOf(new float[] { 1, 2 }, new double[] { 1 }) == false;
149        assert Quant.subsetOf(new double[] { }, new double[] { -1, 1 }) == true;
150        assert Quant.subsetOf(new float[] { 1 }, new float[] { -1, 1 }) == true;
151        assert Quant.subsetOf(new double[] { -1 }, new float[] { -1, 1 }) == true;
152        assert Quant.subsetOf(new byte[] { -1, 1 }, new short[] { -1, 1 }) == true;
153        assert Quant.subsetOf(new short[] { -1, 0, 1 }, new byte[] { -1, 1 }) == false;
154        assert Quant.subsetOf(new int[] { 1, 2 }, new byte[] { 1, 2, 3}) == true;
155        assert Quant.subsetOf(new long[] { }, new short[] { 2, 3, 1}) == true;
156      }
157    
158      public static void test_isReverse() {
159        assert Quant.isReverse(new int[] {}, new int[] {}) == true;
160        assert Quant.isReverse(new int[] { 1 }, new int[] {}) == false;
161        assert Quant.isReverse(new int[] { }, new int[] { 1 }) == false;
162        assert Quant.isReverse(new int[] { 1 }, new int[] { 1 }) == true;
163        assert Quant.isReverse(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
164        assert Quant.isReverse(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
165        assert Quant.isReverse(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
166        assert Quant.isReverse(new int[] { 1, 2, 3 }, new int[] { 3, 4, 5 }) == false;
167        assert Quant.isReverse(new int[] { -1, }, new int[] { 2, 3, 4, 5 }) == false;
168        assert Quant.isReverse(new int[] { -1, 2, 3, 4 }, new int[] { 5 }) == false;
169      }
170    
171      public static void test_noDups() {
172        assert Quant.noDups(new int[] {}) == true;
173        assert Quant.noDups(new int[] { 1 }) == true;
174        assert Quant.noDups(new int[] { -1 }) == true;
175        assert Quant.noDups(new int[] { -1, 1 }) == true;
176        assert Quant.noDups(new int[] { 1, 2, 3}) == true;
177        assert Quant.noDups(new int[] { 2, 3, 1}) == true;
178        assert Quant.noDups(new int[] { 2, 3, 2, 3}) == false;
179        assert Quant.noDups(new int[] { 2, 3, 3, 2}) == false;
180        assert Quant.noDups(new int[] { 3, 3, 3, 3}) == false;
181        assert Quant.noDups(new int[] { 3, 3, 3, 2}) == false;
182        assert Quant.noDups(new int[] { 1, 1, 1, -1 }) == false;
183        assert Quant.noDups(new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
184      }
185    
186      public static void test_memberOf() {
187        assert Quant.memberOf(1, new int[] {}) == false;
188        assert Quant.memberOf(1, new int[] { 1 }) == true;
189        assert Quant.memberOf(-1, new int[] { 1 }) == false;
190        assert Quant.memberOf(1, new int[] { -1 }) == false;
191        assert Quant.memberOf(-1, new int[] { -1 }) == true;
192        assert Quant.memberOf(1, new int[] { -1, 1 }) == true;
193        assert Quant.memberOf(-1, new int[] { -1, 1 }) == true;
194        assert Quant.memberOf(2, new int[] { -1, 1 }) == false;
195        assert Quant.memberOf(1, new int[] { 1, 2, 3}) == true;
196        assert Quant.memberOf(2, new int[] { 1, 2, 3}) == true;
197        assert Quant.memberOf(3, new int[] { 1, 2, 3}) == true;
198        assert Quant.memberOf(4, new int[] { 1, 2, 3}) == false;
199        assert Quant.memberOf(1, new int[] { 2, 3, 1}) == true;
200        assert Quant.memberOf(2, new int[] { 2, 3, 1}) == true;
201        assert Quant.memberOf(3, new int[] { 2, 3, 1}) == true;
202        assert Quant.memberOf(4, new int[] { 2, 3, 1}) == false;
203        assert Quant.memberOf(3, new int[] { 3, 3, 3, 3}) == true;
204        assert Quant.memberOf(2, new int[] { 3, 3, 3, 3}) == false;
205        assert Quant.memberOf(-1, new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
206        assert Quant.memberOf(1, new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
207        assert Quant.memberOf(6, new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
208      }
209    
210      public static void test_slice() {
211        assert_arrays_equals(Quant.slice(new int[] {}, 0, 0), new int[] {});
212        assert_arrays_equals(Quant.slice(new int[] { 1 }, 0, 0), new int[] { 1 });
213        assert_arrays_equals(Quant.slice(new int[] { 1 }, 0, 1), new int[] { });
214        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 0, 0), new int[] { 1 });
215        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 0, 1), new int[] { 1, 2 });
216        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 0, 2), new int[] { 1, 2, 3 });
217        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 0, 3), new int[] { });
218        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 1, 1), new int[] { 2 });
219        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 1, 2), new int[] { 2, 3 });
220        assert_arrays_equals(Quant.slice(new int[] { 1, 2, 3 }, 2, 2), new int[] { 3 });
221      }
222    
223      public static void test_eltsEqual() {
224        assert Quant.eltsEqual(new int[] {}, 0) == true;
225        assert Quant.eltsEqual(new int[] { 1 }, -1) == false;
226        assert Quant.eltsEqual(new int[] { 1 }, 1) == true;
227        assert Quant.eltsEqual(new int[] { -1 }, 1) == false;
228        assert Quant.eltsEqual(new int[] { -1 }, -1) == true;
229        assert Quant.eltsEqual(new int[] { -1, 1 }, 1) == false;
230        assert Quant.eltsEqual(new int[] { -1, 1 }, -1) == false;
231        assert Quant.eltsEqual(new int[] { 1, 2, 3}, 1) == false;
232        assert Quant.eltsEqual(new int[] { 1, 2, 3}, 2) == false;
233        assert Quant.eltsEqual(new int[] { 1, 2, 3}, 3) == false;
234        assert Quant.eltsEqual(new int[] { 2, 3, 2, 3}, 2) == false;
235        assert Quant.eltsEqual(new int[] { 2, 3, 2, 3}, 3) == false;
236        assert Quant.eltsEqual(new int[] { 3, 3, 3, 3}, 3) == true;
237        assert Quant.eltsEqual(new int[] { 1, 1, 1, -1 }, 1) == false;
238        assert Quant.eltsEqual(new int[] { 1, 1, 1, 1 }, 1) == true;
239      }
240    
241      public static void test_eltsNotEqual() {
242        assert Quant.eltsNotEqual(new int[] {}, 0) == true;
243        assert Quant.eltsNotEqual(new int[] { 1 }, -1) == true;
244        assert Quant.eltsNotEqual(new int[] { 1 }, 1) == false;
245        assert Quant.eltsNotEqual(new int[] { -1 }, 1) == true;
246        assert Quant.eltsNotEqual(new int[] { -1 }, -1) == false;
247        assert Quant.eltsNotEqual(new int[] { -1, 1 }, 1) == false;
248        assert Quant.eltsNotEqual(new int[] { -1, 1 }, -1) == false;
249        assert Quant.eltsNotEqual(new int[] { 1, 2, 3}, 1) == false;
250        assert Quant.eltsNotEqual(new int[] { 1, 2, 3}, 2) == false;
251        assert Quant.eltsNotEqual(new int[] { 1, 2, 3}, 3) == false;
252        assert Quant.eltsNotEqual(new int[] { 2, 3, 2, 3}, 2) == false;
253        assert Quant.eltsNotEqual(new int[] { 2, 3, 2, 3}, 3) == false;
254        assert Quant.eltsNotEqual(new int[] { 3, 3, 3, 3}, 3) == false;
255        assert Quant.eltsNotEqual(new int[] { 1, 1, 1, -1 }, 1) == false;
256        assert Quant.eltsNotEqual(new int[] { -1, -1, -1, -1 }, 1) == true;
257        assert Quant.eltsNotEqual(new int[] { 1, 1, 1, 1 }, 1) == false;
258      }
259    
260      public static void test_eltsGT() {
261        assert Quant.eltsGT(new int[] {}, 0) == true;
262        assert Quant.eltsGT(new int[] { 1 }, -1) == true;
263        assert Quant.eltsGT(new int[] { 1 }, 1) == false;
264        assert Quant.eltsGT(new int[] { -1 }, 1) == false;
265        assert Quant.eltsGT(new int[] { -1 }, -1) == false;
266        assert Quant.eltsGT(new int[] { -1, 1 }, 1) == false;
267        assert Quant.eltsGT(new int[] { -1, 1 }, -1) == false;
268        assert Quant.eltsGT(new int[] { 1, 2, 3}, 0) == true;
269        assert Quant.eltsGT(new int[] { 1, 2, 3}, 1) == false;
270        assert Quant.eltsGT(new int[] { 1, 2, 3}, 2) == false;
271        assert Quant.eltsGT(new int[] { 1, 2, 3}, 3) == false;
272        assert Quant.eltsGT(new int[] { 1, 2, 3}, 4) == false;
273        assert Quant.eltsGT(new int[] { 2, 3, 2, 3}, 1) == true;
274        assert Quant.eltsGT(new int[] { 2, 3, 2, 3}, 2) == false;
275        assert Quant.eltsGT(new int[] { 2, 3, 2, 3}, 3) == false;
276        assert Quant.eltsGT(new int[] { 3, 3, 3, 3}, 2) == true;
277        assert Quant.eltsGT(new int[] { 3, 3, 3, 3}, 3) == false;
278      }
279    
280      public static void test_eltsGTE() {
281        assert Quant.eltsGTE(new int[] {}, 0) == true;
282        assert Quant.eltsGTE(new int[] { 1 }, -1) == true;
283        assert Quant.eltsGTE(new int[] { 1 }, 1) == true;
284        assert Quant.eltsGTE(new int[] { -1 }, 1) == false;
285        assert Quant.eltsGTE(new int[] { -1 }, -1) == true;
286        assert Quant.eltsGTE(new int[] { -1, 1 }, 1) == false;
287        assert Quant.eltsGTE(new int[] { -1, 1 }, -1) == true;
288        assert Quant.eltsGTE(new int[] { 1, 2, 3}, 0) == true;
289        assert Quant.eltsGTE(new int[] { 1, 2, 3}, 1) == true;
290        assert Quant.eltsGTE(new int[] { 1, 2, 3}, 2) == false;
291        assert Quant.eltsGTE(new int[] { 1, 2, 3}, 3) == false;
292        assert Quant.eltsGTE(new int[] { 1, 2, 3}, 4) == false;
293        assert Quant.eltsGTE(new int[] { 2, 3, 2, 3}, 1) == true;
294        assert Quant.eltsGTE(new int[] { 2, 3, 2, 3}, 2) == true;
295        assert Quant.eltsGTE(new int[] { 2, 3, 2, 3}, 3) == false;
296        assert Quant.eltsGTE(new int[] { 3, 3, 3, 3}, 2) == true;
297        assert Quant.eltsGTE(new int[] { 3, 3, 3, 3}, 3) == true;
298      }
299    
300      public static void test_eltsLT() {
301        assert Quant.eltsLT(new int[] {}, 0) == true;
302        assert Quant.eltsLT(new int[] { 1 }, -1) == false;
303        assert Quant.eltsLT(new int[] { 1 }, 1) == false;
304        assert Quant.eltsLT(new int[] { -1 }, 1) == true;
305        assert Quant.eltsLT(new int[] { -1 }, -1) == false;
306        assert Quant.eltsLT(new int[] { -1, 1 }, 1) == false;
307        assert Quant.eltsLT(new int[] { -1, 1 }, -1) == false;
308        assert Quant.eltsLT(new int[] { 1, 2, 3}, 0) == false;
309        assert Quant.eltsLT(new int[] { 1, 2, 3}, 1) == false;
310        assert Quant.eltsLT(new int[] { 1, 2, 3}, 2) == false;
311        assert Quant.eltsLT(new int[] { 1, 2, 3}, 3) == false;
312        assert Quant.eltsLT(new int[] { 1, 2, 3}, 4) == true;
313        assert Quant.eltsLT(new int[] { 2, 3, 2, 3}, 1) == false;
314        assert Quant.eltsLT(new int[] { 2, 3, 2, 3}, 2) == false;
315        assert Quant.eltsLT(new int[] { 2, 3, 2, 3}, 3) == false;
316        assert Quant.eltsLT(new int[] { 3, 3, 3, 3}, 2) == false;
317        assert Quant.eltsLT(new int[] { 3, 3, 3, 3}, 3) == false;
318     }
319    
320      public static void test_eltsLTE() {
321        assert Quant.eltsLTE(new int[] {}, 0) == true;
322        assert Quant.eltsLTE(new int[] { 1 }, -1) == false;
323        assert Quant.eltsLTE(new int[] { 1 }, 1) == true;
324        assert Quant.eltsLTE(new int[] { -1 }, 1) == true;
325        assert Quant.eltsLTE(new int[] { -1 }, -1) == true;
326        assert Quant.eltsLTE(new int[] { -1, 1 }, 1) == true;
327        assert Quant.eltsLTE(new int[] { -1, 1 }, -1) == false;
328        assert Quant.eltsLTE(new int[] { 1, 2, 3}, 0) == false;
329        assert Quant.eltsLTE(new int[] { 1, 2, 3}, 1) == false;
330        assert Quant.eltsLTE(new int[] { 1, 2, 3}, 2) == false;
331        assert Quant.eltsLTE(new int[] { 1, 2, 3}, 3) == true;
332        assert Quant.eltsLTE(new int[] { 1, 2, 3}, 4) == true;
333        assert Quant.eltsLTE(new int[] { 2, 3, 2, 3}, 1) == false;
334        assert Quant.eltsLTE(new int[] { 2, 3, 2, 3}, 2) == false;
335        assert Quant.eltsLTE(new int[] { 2, 3, 2, 3}, 3) == true;
336        assert Quant.eltsLTE(new int[] { 3, 3, 3, 3}, 2) == false;
337        assert Quant.eltsLTE(new int[] { 3, 3, 3, 3}, 3) == true;
338     }
339    
340      public static void test_pairwiseEqual() {
341        assert Quant.pairwiseEqual(new int[] {}, new int[] {}) == true;
342        assert Quant.pairwiseEqual(new int[] { 1 }, new int[] {}) == false;
343        assert Quant.pairwiseEqual(new int[] { }, new int[] { 1 }) == false;
344        assert Quant.pairwiseEqual(new int[] { 1 }, new int[] { 1 }) == true;
345        assert Quant.pairwiseEqual(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
346        assert Quant.pairwiseEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
347        assert Quant.pairwiseEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
348        assert Quant.pairwiseEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
349        assert Quant.pairwiseEqual(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
350      }
351    
352      public static void test_pairwiseNotEqual() {
353        assert Quant.pairwiseNotEqual(new int[] {}, new int[] {}) == true;
354        assert Quant.pairwiseNotEqual(new int[] { 1 }, new int[] {}) == false;
355        assert Quant.pairwiseNotEqual(new int[] { }, new int[] { 1 }) == false;
356        assert Quant.pairwiseNotEqual(new int[] { 1 }, new int[] { 1 }) == false;
357        assert Quant.pairwiseNotEqual(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
358        assert Quant.pairwiseNotEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
359        assert Quant.pairwiseNotEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
360        assert Quant.pairwiseNotEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
361        assert Quant.pairwiseNotEqual(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
362      }
363    
364      public static void test_pairwiseLT() {
365        assert Quant.pairwiseLT(new int[] {}, new int[] {}) == true;
366        assert Quant.pairwiseLT(new int[] { 1 }, new int[] {}) == false;
367        assert Quant.pairwiseLT(new int[] { }, new int[] { 1 }) == false;
368        assert Quant.pairwiseLT(new int[] { 1 }, new int[] { 1 }) == false;
369        assert Quant.pairwiseLT(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
370        assert Quant.pairwiseLT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
371        assert Quant.pairwiseLT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == true;
372        assert Quant.pairwiseLT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
373        assert Quant.pairwiseLT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
374        assert Quant.pairwiseLT(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
375      }
376    
377      public static void test_pairwiseLTE() {
378        assert Quant.pairwiseLTE(new int[] {}, new int[] {}) == true;
379        assert Quant.pairwiseLTE(new int[] { 1 }, new int[] {}) == false;
380        assert Quant.pairwiseLTE(new int[] { }, new int[] { 1 }) == false;
381        assert Quant.pairwiseLTE(new int[] { 1 }, new int[] { 1 }) == true;
382        assert Quant.pairwiseLTE(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
383        assert Quant.pairwiseLTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
384        assert Quant.pairwiseLTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == true;
385        assert Quant.pairwiseLTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
386        assert Quant.pairwiseLTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
387        assert Quant.pairwiseLTE(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
388      }
389    
390      public static void test_pairwiseGT() {
391        assert Quant.pairwiseGT(new int[] {}, new int[] {}) == true;
392        assert Quant.pairwiseGT(new int[] { 1 }, new int[] {}) == false;
393        assert Quant.pairwiseGT(new int[] { }, new int[] { 1 }) == false;
394        assert Quant.pairwiseGT(new int[] { 1 }, new int[] { 1 }) == false;
395        assert Quant.pairwiseGT(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
396        assert Quant.pairwiseGT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
397        assert Quant.pairwiseGT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == false;
398        assert Quant.pairwiseGT(new int[] { 2, 3, 4 }, new int[] { 1, 2, 3 }) == true;
399        assert Quant.pairwiseGT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
400        assert Quant.pairwiseGT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
401        assert Quant.pairwiseGT(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
402      }
403    
404      public static void test_pairwiseGTE() {
405        assert Quant.pairwiseGTE(new int[] {}, new int[] {}) == true;
406        assert Quant.pairwiseGTE(new int[] { 1 }, new int[] {}) == false;
407        assert Quant.pairwiseGTE(new int[] { }, new int[] { 1 }) == false;
408        assert Quant.pairwiseGTE(new int[] { 1 }, new int[] { 1 }) == true;
409        assert Quant.pairwiseGTE(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
410        assert Quant.pairwiseGTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
411        assert Quant.pairwiseGTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == false;
412        assert Quant.pairwiseGTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == true;
413        assert Quant.pairwiseGTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
414        assert Quant.pairwiseGTE(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
415      }
416    
417    
418      public static void test_eltwiseEqual() {
419        assert Quant.eltwiseEqual(new int[] {}) == true;
420        assert Quant.eltwiseEqual(new int[] { 1 }) == true;
421        assert Quant.eltwiseEqual(new int[] { -1 }) == true;
422        assert Quant.eltwiseEqual(new int[] { -1, 1 }) == false;
423        assert Quant.eltwiseEqual(new int[] { 1, 1 }) == true;
424        assert Quant.eltwiseEqual(new int[] { 1, 2, 3}) == false;
425        assert Quant.eltwiseEqual(new int[] { 2, 3, 1}) == false;
426        assert Quant.eltwiseEqual(new int[] { 3, 2, 1}) == false;
427        assert Quant.eltwiseEqual(new int[] { 2, 3, 3, 3}) == false;
428        assert Quant.eltwiseEqual(new int[] { 2, 3, 3, 4}) == false;
429        assert Quant.eltwiseEqual(new int[] { 3, 3, 3, 2}) == false;
430        assert Quant.eltwiseEqual(new int[] { 4, 3, 3, 2}) == false;
431        assert Quant.eltwiseEqual(new int[] { 3, 3, 3, 3}) == true;
432        assert Quant.eltwiseEqual(new int[] { 2, 3, 2, 3}) == false;
433        assert Quant.eltwiseEqual(new int[] { -1, 1, 2, 3, 4, 5, 6}) == false;
434      }
435    
436      public static void test_eltwiseNotEqual() {
437        assert Quant.eltwiseNotEqual(new int[] {}) == true;
438        assert Quant.eltwiseNotEqual(new int[] { 1 }) == true;
439        assert Quant.eltwiseNotEqual(new int[] { -1 }) == true;
440        assert Quant.eltwiseNotEqual(new int[] { -1, 1 }) == true;
441        assert Quant.eltwiseNotEqual(new int[] { 1, 1 }) == false;
442        assert Quant.eltwiseNotEqual(new int[] { 1, 2, 3}) == true;
443        assert Quant.eltwiseNotEqual(new int[] { 2, 3, 1}) == true;
444        assert Quant.eltwiseNotEqual(new int[] { 3, 2, 1}) == true;
445        assert Quant.eltwiseNotEqual(new int[] { 2, 3, 3, 3}) == false;
446        assert Quant.eltwiseNotEqual(new int[] { 2, 3, 3, 4}) == false;
447        assert Quant.eltwiseNotEqual(new int[] { 3, 3, 3, 2}) == false;
448        assert Quant.eltwiseNotEqual(new int[] { 4, 3, 3, 2}) == false;
449        assert Quant.eltwiseNotEqual(new int[] { 3, 3, 3, 3}) == false;
450        assert Quant.eltwiseNotEqual(new int[] { 2, 3, 2, 3}) == true;
451        assert Quant.eltwiseNotEqual(new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
452      }
453    
454      public static void test_eltwiseLT() {
455        assert Quant.eltwiseLT(new int[] {}) == true;
456        assert Quant.eltwiseLT(new int[] { 1 }) == true;
457        assert Quant.eltwiseLT(new int[] { -1 }) == true;
458        assert Quant.eltwiseLT(new int[] { -1, 1 }) == true;
459        assert Quant.eltwiseLT(new int[] { 1, 1 }) == false;
460        assert Quant.eltwiseLT(new int[] { 1, 2, 3}) == true;
461        assert Quant.eltwiseLT(new int[] { 2, 3, 1}) == false;
462        assert Quant.eltwiseLT(new int[] { 3, 2, 1}) == false;
463        assert Quant.eltwiseLT(new int[] { 2, 3, 3, 3}) == false;
464        assert Quant.eltwiseLT(new int[] { 2, 3, 3, 4}) == false;
465        assert Quant.eltwiseLT(new int[] { 3, 3, 3, 2}) == false;
466        assert Quant.eltwiseLT(new int[] { 4, 3, 3, 2}) == false;
467        assert Quant.eltwiseLT(new int[] { 3, 3, 3, 3}) == false;
468        assert Quant.eltwiseLT(new int[] { 2, 3, 2, 3}) == false;
469        assert Quant.eltwiseLT(new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
470      }
471    
472      public static void test_eltwiseLTE() {
473        assert Quant.eltwiseLTE(new int[] {}) == true;
474        assert Quant.eltwiseLTE(new int[] { 1 }) == true;
475        assert Quant.eltwiseLTE(new int[] { -1 }) == true;
476        assert Quant.eltwiseLTE(new int[] { -1, 1 }) == true;
477        assert Quant.eltwiseLTE(new int[] { 1, 1 }) == true;
478        assert Quant.eltwiseLTE(new int[] { 1, 2, 3}) == true;
479        assert Quant.eltwiseLTE(new int[] { 2, 3, 1}) == false;
480        assert Quant.eltwiseLTE(new int[] { 3, 2, 1}) == false;
481        assert Quant.eltwiseLTE(new int[] { 2, 3, 3, 3}) == true;
482        assert Quant.eltwiseLTE(new int[] { 2, 3, 3, 4}) == true;
483        assert Quant.eltwiseLTE(new int[] { 3, 3, 3, 2}) == false;
484        assert Quant.eltwiseLTE(new int[] { 4, 3, 3, 2}) == false;
485        assert Quant.eltwiseLTE(new int[] { 3, 3, 3, 3}) == true;
486        assert Quant.eltwiseLTE(new int[] { 2, 3, 2, 3}) == false;
487        assert Quant.eltwiseLTE(new int[] { -1, 1, 2, 3, 4, 5, 6}) == true;
488      }
489    
490      public static void test_eltwiseGT() {
491        assert Quant.eltwiseGT(new int[] {}) == true;
492        assert Quant.eltwiseGT(new int[] { 1 }) == true;
493        assert Quant.eltwiseGT(new int[] { -1 }) == true;
494        assert Quant.eltwiseGT(new int[] { -1, 1 }) == false;
495        assert Quant.eltwiseGT(new int[] { 1, 1 }) == false;
496        assert Quant.eltwiseGT(new int[] { 1, 2, 3}) == false;
497        assert Quant.eltwiseGT(new int[] { 2, 3, 1}) == false;
498        assert Quant.eltwiseGT(new int[] { 3, 2, 1}) == true;
499        assert Quant.eltwiseGT(new int[] { 2, 3, 3, 3}) == false;
500        assert Quant.eltwiseGT(new int[] { 2, 3, 3, 4}) == false;
501        assert Quant.eltwiseGT(new int[] { 3, 3, 3, 2}) == false;
502        assert Quant.eltwiseGT(new int[] { 4, 3, 3, 2}) == false;
503        assert Quant.eltwiseGT(new int[] { 3, 3, 3, 3}) == false;
504        assert Quant.eltwiseGT(new int[] { 2, 3, 2, 3}) == false;
505        assert Quant.eltwiseGT(new int[] { -1, 1, 2, 3, 4, 5, 6}) == false;
506      }
507    
508      public static void test_eltwiseGTE() {
509        assert Quant.eltwiseGTE(new int[] {}) == true;
510        assert Quant.eltwiseGTE(new int[] { 1 }) == true;
511        assert Quant.eltwiseGTE(new int[] { -1 }) == true;
512        assert Quant.eltwiseGTE(new int[] { -1, 1 }) == false;
513        assert Quant.eltwiseGTE(new int[] { 1, 1 }) == true;
514        assert Quant.eltwiseGTE(new int[] { 1, 2, 3}) == false;
515        assert Quant.eltwiseGTE(new int[] { 2, 3, 1}) == false;
516        assert Quant.eltwiseGTE(new int[] { 3, 2, 1}) == true;
517        assert Quant.eltwiseGTE(new int[] { 2, 3, 3, 3}) == false;
518        assert Quant.eltwiseGTE(new int[] { 2, 3, 3, 4}) == false;
519        assert Quant.eltwiseGTE(new int[] { 3, 3, 3, 2}) == true;
520        assert Quant.eltwiseGTE(new int[] { 4, 3, 3, 2}) == true;
521        assert Quant.eltwiseGTE(new int[] { 3, 3, 3, 3}) == true;
522        assert Quant.eltwiseGTE(new int[] { 2, 3, 2, 3}) == false;
523        assert Quant.eltwiseGTE(new int[] { -1, 1, 2, 3, 4, 5, 6}) == false;
524      }
525    
526      public static void test_eltsEqualIndex() {
527        assert Quant.eltsEqualIndex(new int[] {}) == true;
528        assert Quant.eltsEqualIndex(new int[] { 0 }) == true;
529        assert Quant.eltsEqualIndex(new int[] { 1 }) == false;
530        assert Quant.eltsEqualIndex(new int[] { -1 }) == false;
531        assert Quant.eltsEqualIndex(new int[] { -1, -1, 1 }) == false;
532        assert Quant.eltsEqualIndex(new int[] { -1, 0, 1 }) == false;
533        assert Quant.eltsEqualIndex(new int[] { -1, 1, 1 }) == false;
534        assert Quant.eltsEqualIndex(new int[] { 0, 0, 2 }) == false;
535        assert Quant.eltsEqualIndex(new int[] { 0, 1, 2 }) == true;
536        assert Quant.eltsEqualIndex(new int[] { 0, 2, 2 }) == false;
537        assert Quant.eltsEqualIndex(new int[] { 1, 1, 3 }) == false;
538        assert Quant.eltsEqualIndex(new int[] { 1, 2, 3 }) == false;
539        assert Quant.eltsEqualIndex(new int[] { 1, 3, 3 }) == false;
540      }
541    
542      public static void test_eltsNotEqualIndex() {
543        assert Quant.eltsNotEqualIndex(new int[] {}) == true;
544        assert Quant.eltsNotEqualIndex(new int[] { 0 }) == false;
545        assert Quant.eltsNotEqualIndex(new int[] { 1 }) == true;
546        assert Quant.eltsNotEqualIndex(new int[] { -1 }) == true;
547        assert Quant.eltsNotEqualIndex(new int[] { -1, -1, 1 }) == true;
548        assert Quant.eltsNotEqualIndex(new int[] { -1, 0, 1 }) == true;
549        assert Quant.eltsNotEqualIndex(new int[] { -1, 1, 1 }) == false;
550        assert Quant.eltsNotEqualIndex(new int[] { 0, 0, 2 }) == false;
551        assert Quant.eltsNotEqualIndex(new int[] { 0, 1, 2 }) == false;
552        assert Quant.eltsNotEqualIndex(new int[] { 0, 2, 2 }) == false;
553        assert Quant.eltsNotEqualIndex(new int[] { 1, 1, 3 }) == false;
554        assert Quant.eltsNotEqualIndex(new int[] { 1, 2, 3 }) == true;
555        assert Quant.eltsNotEqualIndex(new int[] { 1, 3, 3 }) == true;
556      }
557    
558      public static void test_eltsGteIndex() {
559        assert Quant.eltsGteIndex(new int[] {}) == true;
560        assert Quant.eltsGteIndex(new int[] { 0 }) == true;
561        assert Quant.eltsGteIndex(new int[] { 1 }) == true;
562        assert Quant.eltsGteIndex(new int[] { -1 }) == false;
563        assert Quant.eltsGteIndex(new int[] { -1, -1, 1 }) == false;
564        assert Quant.eltsGteIndex(new int[] { -1, 0, 1 }) == false;
565        assert Quant.eltsGteIndex(new int[] { -1, 1, 1 }) == false;
566        assert Quant.eltsGteIndex(new int[] { 0, 0, 2 }) == false;
567        assert Quant.eltsGteIndex(new int[] { 0, 1, 2 }) == true;
568        assert Quant.eltsGteIndex(new int[] { 0, 2, 2 }) == true;
569        assert Quant.eltsGteIndex(new int[] { 1, 1, 3 }) == true;
570        assert Quant.eltsGteIndex(new int[] { 1, 2, 3 }) == true;
571        assert Quant.eltsGteIndex(new int[] { 1, 3, 3 }) == true;
572      }
573    
574      public static void test_eltsGtIndex() {
575        assert Quant.eltsGtIndex(new int[] {}) == true;
576        assert Quant.eltsGtIndex(new int[] { 0 }) == false;
577        assert Quant.eltsGtIndex(new int[] { 1 }) == true;
578        assert Quant.eltsGtIndex(new int[] { -1 }) == false;
579        assert Quant.eltsGtIndex(new int[] { -1, -1, 1 }) == false;
580        assert Quant.eltsGtIndex(new int[] { -1, 0, 1 }) == false;
581        assert Quant.eltsGtIndex(new int[] { -1, 1, 1 }) == false;
582        assert Quant.eltsGtIndex(new int[] { 0, 0, 2 }) == false;
583        assert Quant.eltsGtIndex(new int[] { 0, 1, 2 }) == false;
584        assert Quant.eltsGtIndex(new int[] { 0, 2, 2 }) == false;
585        assert Quant.eltsGtIndex(new int[] { 1, 1, 3 }) == false;
586        assert Quant.eltsGtIndex(new int[] { 1, 2, 3 }) == true;
587        assert Quant.eltsGtIndex(new int[] { 1, 3, 3 }) == true;
588      }
589    
590      public static void test_eltsLteIndex() {
591        assert Quant.eltsLteIndex(new int[] {}) == true;
592        assert Quant.eltsLteIndex(new int[] { 0 }) == true;
593        assert Quant.eltsLteIndex(new int[] { 1 }) == false;
594        assert Quant.eltsLteIndex(new int[] { -1 }) == true;
595        assert Quant.eltsLteIndex(new int[] { -1, -1, 1 }) == true;
596        assert Quant.eltsLteIndex(new int[] { -1, 0, 1 }) == true;
597        assert Quant.eltsLteIndex(new int[] { -1, 1, 1 }) == true;
598        assert Quant.eltsLteIndex(new int[] { 0, 0, 2 }) == true;
599        assert Quant.eltsLteIndex(new int[] { 0, 1, 2 }) == true;
600        assert Quant.eltsLteIndex(new int[] { 0, 2, 2 }) == false;
601        assert Quant.eltsLteIndex(new int[] { 1, 1, 3 }) == false;
602        assert Quant.eltsLteIndex(new int[] { 1, 2, 3 }) == false;
603        assert Quant.eltsLteIndex(new int[] { 1, 3, 3 }) == false;
604      }
605    
606      public static void test_eltsLtIndex() {
607        assert Quant.eltsLtIndex(new int[] {}) == true;
608        assert Quant.eltsLtIndex(new int[] { 0 }) == false;
609        assert Quant.eltsLtIndex(new int[] { 1 }) == false;
610        assert Quant.eltsLtIndex(new int[] { -1 }) == true;
611        assert Quant.eltsLtIndex(new int[] { -1, -1, 1 }) == true;
612        assert Quant.eltsLtIndex(new int[] { -1, 0, 1 }) == true;
613        assert Quant.eltsLtIndex(new int[] { -1, 1, 1 }) == false;
614        assert Quant.eltsLtIndex(new int[] { 0, 0, 2 }) == false;
615        assert Quant.eltsLtIndex(new int[] { 0, 1, 2 }) == false;
616        assert Quant.eltsLtIndex(new int[] { 0, 2, 2 }) == false;
617        assert Quant.eltsLtIndex(new int[] { 1, 1, 3 }) == false;
618        assert Quant.eltsLtIndex(new int[] { 1, 2, 3 }) == false;
619        assert Quant.eltsLtIndex(new int[] { 1, 3, 3 }) == false;
620      }
621    
622      public static void test_lexEqual() {
623        assert Quant.lexEqual(new int[] {}, new int[] {}) == true;
624        assert Quant.lexEqual(new int[] { 1 }, new int[] {}) == false;
625        assert Quant.lexEqual(new int[] { }, new int[] { 1 }) == false;
626        assert Quant.lexEqual(new int[] { 1 }, new int[] { 1 }) == true;
627        assert Quant.lexEqual(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
628        assert Quant.lexEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
629        assert Quant.lexEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == false;
630        assert Quant.lexEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
631        assert Quant.lexEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
632        assert Quant.lexEqual(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
633      }
634    
635      public static void test_lexNotEqual() {
636        assert Quant.lexNotEqual(new int[] {}, new int[] {}) == false;
637        assert Quant.lexNotEqual(new int[] { 1 }, new int[] {}) == true;
638        assert Quant.lexNotEqual(new int[] { }, new int[] { 1 }) == true;
639        assert Quant.lexNotEqual(new int[] { 1 }, new int[] { 1 }) == false;
640        assert Quant.lexNotEqual(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == true;
641        assert Quant.lexNotEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
642        assert Quant.lexNotEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == true;
643        assert Quant.lexNotEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == true;
644        assert Quant.lexNotEqual(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
645        assert Quant.lexNotEqual(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
646      }
647    
648      public static void test_lexLT() {
649        assert Quant.lexLT(new int[] {}, new int[] {}) == false;
650        assert Quant.lexLT(new int[] { 1 }, new int[] {}) == false;
651        assert Quant.lexLT(new int[] { }, new int[] { 1 }) == true;
652        assert Quant.lexLT(new int[] { 1 }, new int[] { 1 }) == false;
653        assert Quant.lexLT(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == true;
654        assert Quant.lexLT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
655        assert Quant.lexLT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == true;
656        assert Quant.lexLT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
657        assert Quant.lexLT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
658        assert Quant.lexLT(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
659      }
660    
661      public static void test_lexLTE() {
662        assert Quant.lexLTE(new int[] {}, new int[] {}) == true;
663        assert Quant.lexLTE(new int[] { 1 }, new int[] {}) == false;
664        assert Quant.lexLTE(new int[] { }, new int[] { 1 }) == true;
665        assert Quant.lexLTE(new int[] { 1 }, new int[] { 1 }) == true;
666        assert Quant.lexLTE(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == true;
667        assert Quant.lexLTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
668        assert Quant.lexLTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == true;
669        assert Quant.lexLTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == false;
670        assert Quant.lexLTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == true;
671        assert Quant.lexLTE(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == true;
672      }
673    
674      public static void test_lexGT() {
675        assert Quant.lexGT(new int[] {}, new int[] {}) == false;
676        assert Quant.lexGT(new int[] { 1 }, new int[] {}) == true;
677        assert Quant.lexGT(new int[] { }, new int[] { 1 }) == false;
678        assert Quant.lexGT(new int[] { 1 }, new int[] { 1 }) == false;
679        assert Quant.lexGT(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
680        assert Quant.lexGT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == false;
681        assert Quant.lexGT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == false;
682        assert Quant.lexGT(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == true;
683        assert Quant.lexGT(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
684        assert Quant.lexGT(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
685      }
686    
687      public static void test_lexGTE() {
688        assert Quant.lexGTE(new int[] {}, new int[] {}) == true;
689        assert Quant.lexGTE(new int[] { 1 }, new int[] {}) == true;
690        assert Quant.lexGTE(new int[] { }, new int[] { 1 }) == false;
691        assert Quant.lexGTE(new int[] { 1 }, new int[] { 1 }) == true;
692        assert Quant.lexGTE(new int[] { 1, 2 }, new int[] { 1, 2, 3 }) == false;
693        assert Quant.lexGTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 }) == true;
694        assert Quant.lexGTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }) == false;
695        assert Quant.lexGTE(new int[] { 1, 2, 3 }, new int[] { 1, 2, 2 }) == true;
696        assert Quant.lexGTE(new int[] { 1, 2, 3 }, new int[] { 2, 3, 1 }) == false;
697        assert Quant.lexGTE(new int[] { 1, 2, 3 }, new int[] { 3, 2, 1 }) == false;
698      }
699    
700      public static void test_pairwiseDivides() {
701        assert Quant.pairwiseDivides(new int[] {}, new int[] {}) == true;
702        assert Quant.pairwiseDivides(new int[] {}, new int[] { 1 }) == false;
703        assert Quant.pairwiseDivides(new int[] { 1 }, new int[] { }) == false;
704        assert Quant.pairwiseDivides(new int[] { 1 }, new int[] { 1 }) == true;
705        assert Quant.pairwiseDivides(new int[] { 4 }, new int[] { 2 }) == true;
706        assert Quant.pairwiseDivides(new int[] { 27 }, new int[] { 3 }) == true;
707        assert Quant.pairwiseDivides(new int[] { 27 }, new int[] { 4 }) == false;
708        assert Quant.pairwiseDivides(new int[] { 1, 6, 6 }, new int[] { 1, 2, 3 }) == true;
709        assert Quant.pairwiseDivides(new int[] { 1, -6, 6 }, new int[] { 1, 2, 3 }) == true;
710        assert Quant.pairwiseDivides(new int[] { 1, 6, 7 }, new int[] { 1, 2, 3 }) == false;
711      }
712    
713      public static void test_pairwiseSquare() {
714        assert Quant.pairwiseSquare(new int[] {}, new int[] {}) == true;
715        assert Quant.pairwiseSquare(new int[] {}, new int[] { 1 }) == false;
716        assert Quant.pairwiseSquare(new int[] { 1 }, new int[] { }) == false;
717        assert Quant.pairwiseSquare(new int[] { 1 }, new int[] { 1 }) == true;
718        assert Quant.pairwiseSquare(new int[] { 4 }, new int[] { 2 }) == true;
719        assert Quant.pairwiseSquare(new int[] { 27 }, new int[] { 3 }) == false;
720        assert Quant.pairwiseSquare(new int[] { 27 }, new int[] { 4 }) == false;
721        assert Quant.pairwiseSquare(new int[] { 1, 4, 9 }, new int[] { 1, 2, 3 }) == true;
722        assert Quant.pairwiseSquare(new int[] { 1, -4, 9 }, new int[] { 1, 2, 3 }) == false;
723        assert Quant.pairwiseSquare(new int[] { 1, 4, 10 }, new int[] { 1, 2, 3 }) == false;
724      }
725    
726      public static void test_pairwiseBitwiseComplement() {
727        assert Quant.pairwiseBitwiseComplement(new int[] {}, new int[] {}) == true ;
728        assert Quant.pairwiseBitwiseComplement(new int[] { 3, 3 }, new int[] { -4, -4 }) == true ;
729        assert Quant.pairwiseBitwiseComplement(new int[] { 3, 3 }, new int[] { 3, -4 }) == false ;
730        assert Quant.pairwiseBitwiseComplement(new int[] { 3, 21, 0 }, new int[] { -4, -22, -1 }) == true ;
731      }
732    
733      public static void test_pairwiseBitwiseSubset() {
734        assert Quant.pairwiseBitwiseSubset(new int[] {}, new int[] {}) == true ;
735        assert Quant.pairwiseBitwiseSubset(new int[] { 5, 5 }, new int[] { 4, 1 }) == true ;
736        assert Quant.pairwiseBitwiseSubset(new int[] { 5, 5 }, new int[] { 4, 3 }) == false ;
737      }
738    
739      public static class Foo1 { public Bar1 x; public static Bar1 xstatic; }
740      public static class Bar1 {
741        private Baz1 y;
742        public void set_y(Baz1 o) { y = o; }
743        public Baz1f yf;
744      }
745      public static class Baz1 { public int[] z; }
746      public static class Baz1f { public int z; }
747    
748      public static class Foo2 {
749        public Object[] x;
750        private static Object xstatic;
751        public static void set_xstatic(Object o) { xstatic = o; }
752      }
753      public static class Foo2f {
754        private Object x;
755        public void set_x(Object o) { x = o; }
756      }
757    
758      public static class Foo3 {
759        private Bar3[] x;
760        public void set_x(Bar3[] o) { x = o; }
761      }
762      public static class Foo3f { public Bar3 x; }
763      public static class Bar3 { public Baz3 y; }
764      public static class Baz3 { public int z; }
765    
766      public static class Foo3a {
767        private java.util.List<Bar3a> x;
768        public void set_x(java.util.List<Bar3a> o) { x = o; }
769      }
770      public static class Foo3af { public Bar3a x; }
771      public static class Bar3a { public Baz3a y; }
772      public static class Baz3a { public int z; }
773    
774      public static class Foo4 { public Bar4 x; }
775      public static class Bar4 {
776        private Baz4[] y;
777        public void set_y(Baz4[] o) { y = o; }
778      }
779      public static class Bar4f { public Baz4 y; }
780      public static class Baz4 { public String z; }
781    
782      public static void testCollect() {
783    
784        Foo1 f1 = new Foo1(); f1.x = new Bar1(); f1.x.y = new Baz1(); f1.x.y.z = new int[] { 1, 2, 3, 4 };
785        assert_arrays_equals(Quant.collectint(f1, "x.y.z"), new int[] {1, 2, 3, 4});
786    
787        Foo2 f2 = new Foo2(); f2.x = new Object[] { null, "hi", "foobar" };
788        Object[] a1 = Quant.collectObject(f2, "x");
789        assert a1[0]==null && a1[1].equals("hi") && a1[2].equals("foobar");
790    
791        Bar3 b3 = new Bar3(); b3.y = new Baz3(); b3.y.z = 7;
792        Bar3 b4 = new Bar3(); b4.y = new Baz3(); b4.y.z = 8;
793        Bar3 b5 = new Bar3(); b5.y = new Baz3(); b5.y.z = 9;
794        Foo3 f3 = new Foo3(); f3.x = new Bar3[] { b3, b4, b5 };
795        assert_arrays_equals(Quant.collectint(f3, "x.y.z"), new int[] { 7, 8, 9 });
796    
797        Bar3a b3a = new Bar3a(); b3a.y = new Baz3a(); b3a.y.z = 7;
798        Bar3a b4a = new Bar3a(); b4a.y = new Baz3a(); b4a.y.z = 8;
799        Bar3a b5a = new Bar3a(); b5a.y = new Baz3a(); b5a.y.z = 9;
800        Foo3a f3a = new Foo3a(); f3a.x = new java.util.ArrayList<Bar3a>();
801        f3a.x.add(b3a);
802        f3a.x.add(b4a);
803        f3a.x.add(b5a);
804        assert_arrays_equals(Quant.collectint(f3a, "x.y.z"), new int[] { 7, 8, 9 });
805    
806        Baz4 z1 = new Baz4(); z1.z = "hi1";
807        Baz4 z2 = new Baz4(); z2.z = "hi2";
808        Foo4 f4 = new Foo4(); f4.x = new Bar4() ; f4.x.y = new Baz4[] { z1, z2 };
809        String[] a3 = Quant.collectString(f4, "x.y.z");
810        String[] a4 = new String[] { "hi1", "hi2" };
811        assert a3[0].equals(a4[0]) && a3[1].equals(a4[1]);
812      }
813    
814    
815      public static void testCollect_field() {
816    
817        Foo1 f1 = new Foo1(); f1.x = new Bar1(); f1.x.yf = new Baz1f(); f1.x.yf.z = 7;
818    
819        assert Quant.collectint_field(f1, "x.yf.z") == 7;
820    
821        Foo2f f2 = new Foo2f(); f2.x = "hi";
822        Object a1 = Quant.collectObject_field(f2, "x");
823        assert a1.equals("hi");
824    
825        Bar3 b3 = new Bar3(); b3.y = new Baz3(); b3.y.z = 7;
826        Bar3 b4 = new Bar3(); b4.y = new Baz3(); b4.y.z = 8;
827        Bar3 b5 = new Bar3(); b5.y = new Baz3(); b5.y.z = 9;
828        assert Quant.collectint_field(b3, "y.z") == 7;
829        assert Quant.collectint_field(b4, "y.z") == 8;
830        assert Quant.collectint_field(b5, "y.z") == 9;
831    
832        Baz4 z1 = new Baz4(); z1.z = "hi1";
833        Baz4 z2 = new Baz4(); z2.z = "hi2";
834        assert Quant.collectString_field(z1, "z").equals("hi1");
835        assert Quant.collectString_field(z2, "z").equals("hi2");
836    
837        Foo1.xstatic = new Bar1(); Foo1.xstatic.yf = new Baz1f(); Foo1.xstatic.yf.z = 7;
838    
839        assert Quant.collectint_field(Foo1.class, "xstatic.yf.z") == 7;
840    
841        Foo2.set_xstatic("hi");
842        a1 = Quant.collectObject_field(Foo2.class, "xstatic");
843        assert a1.equals("hi");
844    
845      }
846    
847    
848    }