@@ -237,6 +237,9 @@ public void testSet(Permutation p, int i, int v) {
237237 public void testSet (Permutation p , int i , int [] a ) {
238238 set (p , i , a );
239239 }
240+ public void testSet (Permutation p , int [] s , int from , int to , int numElements ) {
241+ set (p , s , from , to , numElements );
242+ }
240243 }
241244 MyMech test = new MyMech ();
242245
@@ -276,6 +279,42 @@ public void testSet(Permutation p, int i, int[] a) {
276279 assertEquals ("elements after end should not change" , a [i ], p .get (i ));
277280 }
278281 }
282+ for (int [] a : arrays ) {
283+ Permutation p = new Permutation (a .length , 0 );
284+ test .testSet (p , a .clone (), 0 , 0 , a .length );
285+ validatePermutation (p , a .length );
286+ for (int i = 0 ; i < a .length ; i ++) assertEquals ("elements should be in same order" , a [i ], p .get (i ));
287+ }
288+ for (int [] a : arrays ) {
289+ Permutation p = new Permutation (a );
290+ int [] change = a .length > 2 ? new int [] {7 , 5 } : new int [] {7 };
291+ int start = a .length > 1 ? 1 : 0 ;
292+ test .testSet (p , change , 0 , start , change .length );
293+ for (int i = 0 ; i < start ; i ++) {
294+ assertEquals ("elements before start should not change" , a [i ], p .get (i ));
295+ }
296+ for (int i = 0 ; i < change .length ; i ++) {
297+ assertEquals ("checking changed elements" , change [i ], p .get (start +i ));
298+ }
299+ for (int i = start + change .length ; i < a .length ; i ++) {
300+ assertEquals ("elements after end should not change" , a [i ], p .get (i ));
301+ }
302+ }
303+ for (int [] a : arrays ) {
304+ Permutation p = new Permutation (a );
305+ int [] change = a .length > 2 ? new int [] {9 , 9 , 7 , 5 , 9 , 9 } : new int [] {9 , 9 , 7 , 9 , 9 };
306+ int start = a .length > 1 ? 1 : 0 ;
307+ test .testSet (p , change , 2 , start , change .length - 4 );
308+ for (int i = 0 ; i < start ; i ++) {
309+ assertEquals ("elements before start should not change" , a [i ], p .get (i ));
310+ }
311+ for (int i = 2 ; i < change .length -2 ; i ++) {
312+ assertEquals ("checking changed elements" , change [i ], p .get (start +i -2 ));
313+ }
314+ for (int i = start + change .length - 4 ; i < a .length ; i ++) {
315+ assertEquals ("elements after end should not change" , a [i ], p .get (i ));
316+ }
317+ }
279318 }
280319
281320 @ Test
0 commit comments