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