(NavigableSet<Integer> set,
int min, int max, boolean ascending,
BitSet bs)
| 784 | } |
| 785 | |
| 786 | void bashSubSet(NavigableSet<Integer> set, |
| 787 | int min, int max, boolean ascending, |
| 788 | BitSet bs) { |
| 789 | check(set, min, max, ascending, bs); |
| 790 | check(set.descendingSet(), min, max, !ascending, bs); |
| 791 | |
| 792 | mutateSubSet(set, min, max, bs); |
| 793 | check(set, min, max, ascending, bs); |
| 794 | check(set.descendingSet(), min, max, !ascending, bs); |
| 795 | |
| 796 | // Recurse |
| 797 | if (max - min < 2) |
| 798 | return; |
| 799 | int midPoint = (min + max) / 2; |
| 800 | |
| 801 | // headSet - pick direction and endpoint inclusion randomly |
| 802 | boolean incl = rnd.nextBoolean(); |
| 803 | NavigableSet<Integer> hm = set.headSet(midPoint, incl); |
| 804 | if (ascending) { |
| 805 | if (rnd.nextBoolean()) |
| 806 | bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true, bs); |
| 807 | else |
| 808 | bashSubSet(hm.descendingSet(), min, midPoint - (incl ? 0 : 1), |
| 809 | false, bs); |
| 810 | } else { |
| 811 | if (rnd.nextBoolean()) |
| 812 | bashSubSet(hm, midPoint + (incl ? 0 : 1), max, false, bs); |
| 813 | else |
| 814 | bashSubSet(hm.descendingSet(), midPoint + (incl ? 0 : 1), max, |
| 815 | true, bs); |
| 816 | } |
| 817 | |
| 818 | // tailSet - pick direction and endpoint inclusion randomly |
| 819 | incl = rnd.nextBoolean(); |
| 820 | NavigableSet<Integer> tm = set.tailSet(midPoint,incl); |
| 821 | if (ascending) { |
| 822 | if (rnd.nextBoolean()) |
| 823 | bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true, bs); |
| 824 | else |
| 825 | bashSubSet(tm.descendingSet(), midPoint + (incl ? 0 : 1), max, |
| 826 | false, bs); |
| 827 | } else { |
| 828 | if (rnd.nextBoolean()) { |
| 829 | bashSubSet(tm, min, midPoint - (incl ? 0 : 1), false, bs); |
| 830 | } else { |
| 831 | bashSubSet(tm.descendingSet(), min, midPoint - (incl ? 0 : 1), |
| 832 | true, bs); |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | // subSet - pick direction and endpoint inclusion randomly |
| 837 | int rangeSize = max - min + 1; |
| 838 | int[] endpoints = new int[2]; |
| 839 | endpoints[0] = min + rnd.nextInt(rangeSize); |
| 840 | endpoints[1] = min + rnd.nextInt(rangeSize); |
| 841 | Arrays.sort(endpoints); |
| 842 | boolean lowIncl = rnd.nextBoolean(); |
| 843 | boolean highIncl = rnd.nextBoolean(); |
no test coverage detected