1 25 38 package org.jgrapht.experimental.permutation; 39 40 import junit.framework.*; 41 42 import org.jgrapht.util.*; 43 44 45 49 public class CompoundPermutationIterTest 50 extends TestCase 51 { 52 53 55 private CompoundPermutationIter complexPerm; 56 57 59 65 public void testGetNext() 66 { 67 71 this.complexPerm = 72 new CompoundPermutationIter(new int [] { 73 1, 74 1, 75 1, 76 2, 77 2, 78 3, 79 4, 80 5 81 }); 82 int maxPermNum = this.complexPerm.getMax(); 83 84 int counter = 0; 86 while (this.complexPerm.hasNext()) { 87 int [] resultArray = this.complexPerm.getNext(); 88 89 if (false) { 90 System.out.println(ArrayUtil.toString(resultArray)); 91 } 92 counter++; 93 } 94 95 assertEquals(maxPermNum, counter); 97 98 100 this.complexPerm = 102 new CompoundPermutationIter(new int [] { 103 5, 104 4, 105 3, 106 2, 107 2, 108 1, 109 1, 110 1 111 }); 112 113 counter = 0; 116 while (this.complexPerm.hasNext()) { 117 int [] resultArray = this.complexPerm.getNext(); 118 119 if (false) { 120 System.out.println(ArrayUtil.toString(resultArray)); 121 } 122 counter++; 123 } 124 125 assertEquals(maxPermNum, counter); 127 } 129 } 130 | Popular Tags |