### Question:
StatisticRange { public StatisticRange addAndCollapseDistinctValues(StatisticRange other) { double overlapPercentOfThis = this.overlapPercentWith(other); double overlapPercentOfOther = other.overlapPercentWith(this); double overlapDistinctValuesThis = overlapPercentOfThis * distinctValues; double overlapDistinctValuesOther = overlapPercentOfOther * other.distinctValues; double maxOverlappingValues = max(overlapDistinctValuesThis, overlapDistinctValuesOther); double newDistinctValues = maxOverlappingValues + (1 - overlapPercentOfThis) * distinctValues + (1 - overlapPercentOfOther) * other.distinctValues; return new StatisticRange(minExcludeNaN(low, other.low), maxExcludeNaN(high, other.high), newDistinctValues); } StatisticRange(double low, double high, double distinctValues); static StatisticRange empty(); static StatisticRange from(SymbolStatsEstimate estimate); double getLow(); double getHigh(); double getDistinctValuesCount(); double length(); boolean isEmpty(); double overlapPercentWith(StatisticRange other); StatisticRange intersect(StatisticRange other); StatisticRange addAndSumDistinctValues(StatisticRange other); StatisticRange addAndMaxDistinctValues(StatisticRange other); StatisticRange addAndCollapseDistinctValues(StatisticRange other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testAddAndCollapseDistinctValues() { assertEquals(unboundedRange(NaN).addAndCollapseDistinctValues(unboundedRange(NaN)), unboundedRange(NaN)); assertEquals(unboundedRange(NaN).addAndCollapseDistinctValues(unboundedRange(1)), unboundedRange(NaN)); assertEquals(unboundedRange(1).addAndCollapseDistinctValues(unboundedRange(NaN)), unboundedRange(NaN)); assertEquals(unboundedRange(1).addAndCollapseDistinctValues(unboundedRange(2)), unboundedRange(2)); assertEquals(StatisticRange.empty().addAndCollapseDistinctValues(StatisticRange.empty()), StatisticRange.empty()); assertEquals(range(0, 1, 1).addAndCollapseDistinctValues(StatisticRange.empty()), range(0, 1, 1)); assertEquals(range(0, 1, 1).addAndCollapseDistinctValues(range(1, 2, 1)), range(0, 2, 1)); assertEquals(range(0, 3, 3).addAndCollapseDistinctValues(range(2, 6, 4)), range(0, 6, 6)); }