public void testCopyOfExplicit_comparator() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asList("in", "the", "quick", "jumped", "over", "a")); assertSame(STRING_LENGTH, set.comparator()); }
public void testCopyOfExplicit_iterator_comparator() { SortedSet<String> set = ImmutableSortedSet.copyOf( STRING_LENGTH, asIterator("in", "the", "quick", "jumped", "over", "a")); assertSame(STRING_LENGTH, set.comparator()); }
public void testCopyOfSorted_natural_comparator() { SortedSet<String> input = Sets.newTreeSet(asList("in", "the", "quick", "jumped", "over", "a")); SortedSet<String> set = ImmutableSortedSet.copyOfSorted(input); assertSame(Ordering.natural(), set.comparator()); }
public void testEmpty_headSet() { SortedSet<String> set = of(); assertSame(set, set.headSet("c")); }
public void testEmpty_tailSet() { SortedSet<String> set = of(); assertSame(set, set.tailSet("f")); }
public void testSingle_comparator() { SortedSet<String> set = of("e"); assertSame(Ordering.natural(), set.comparator()); }
public void testOf_comparator() { SortedSet<String> set = of("e", "a", "f", "b", "d", "c"); assertSame(Ordering.natural(), set.comparator()); }
public void testCopyOf_comparator() { SortedSet<String> set = copyOf(asList("e", "a", "f", "b", "d", "c")); assertSame(Ordering.natural(), set.comparator()); }
public void testCopyOf_sortedSet_comparator() { SortedSet<String> set = copyOf(Sets.<String>newTreeSet()); assertSame(Ordering.natural(), set.comparator()); }
public void testCopyOfSorted_explicit_ordering() { SortedSet<String> input = Sets.newTreeSet(STRING_LENGTH); Collections.addAll(input, "in", "the", "quick", "jumped", "over", "a"); SortedSet<String> set = ImmutableSortedSet.copyOfSorted(input); assertThat(set).containsExactly("a", "in", "the", "over", "quick", "jumped").inOrder(); assertSame(STRING_LENGTH, set.comparator()); }
public void testSingle_headSet() { SortedSet<String> set = of("e"); assertTrue(set.headSet("g") instanceof ImmutableSortedSet); assertThat(set.headSet("g")).contains("e"); assertSame(of(), set.headSet("c")); assertSame(of(), set.headSet("e")); }
public void testOf_headSet() { SortedSet<String> set = of("e", "f", "b", "d", "c"); assertTrue(set.headSet("e") instanceof ImmutableSortedSet); assertThat(set.headSet("e")).containsExactly("b", "c", "d").inOrder(); assertThat(set.headSet("g")).containsExactly("b", "c", "d", "e", "f").inOrder(); assertSame(of(), set.headSet("a")); assertSame(of(), set.headSet("b")); }
public void testSingle_tailSet() { SortedSet<String> set = of("e"); assertTrue(set.tailSet("c") instanceof ImmutableSortedSet); assertThat(set.tailSet("c")).contains("e"); assertThat(set.tailSet("e")).contains("e"); assertSame(of(), set.tailSet("g")); }
public void testAsList() { ImmutableSet<String> set = ImmutableSortedSet.of("a", "e", "i", "o", "u"); ImmutableList<String> list = set.asList(); assertEquals(ImmutableList.of("a", "e", "i", "o", "u"), list); assertSame(list, ImmutableList.copyOf(set)); }
public void testExplicit_comparator() { SortedSet<String> set = ImmutableSortedSet.orderedBy(STRING_LENGTH) .add("in", "the", "quick", "jumped", "over", "a") .build(); assertSame(STRING_LENGTH, set.comparator()); }
public void testOf_tailSet() { SortedSet<String> set = of("e", "f", "b", "d", "c"); assertTrue(set.tailSet("e") instanceof ImmutableSortedSet); assertThat(set.tailSet("e")).containsExactly("e", "f").inOrder(); assertThat(set.tailSet("a")).containsExactly("b", "c", "d", "e", "f").inOrder(); assertSame(of(), set.tailSet("g")); }
@GwtIncompatible // SerializableTester public void testExplicitEmpty_serialization() { SortedSet<String> set = ImmutableSortedSet.orderedBy(STRING_LENGTH).build(); SortedSet<String> copy = SerializableTester.reserializeAndAssert(set); assertTrue(set.isEmpty()); assertTrue(copy.isEmpty()); assertSame(set.comparator(), copy.comparator()); }
@GwtIncompatible // SerializableTester public void testEmpty_serialization() { SortedSet<String> set = of(); SortedSet<String> copy = SerializableTester.reserialize(set); assertSame(set, copy); }
public void testSingle_subSet() { SortedSet<String> set = of("e"); assertTrue(set.subSet("c", "g") instanceof ImmutableSortedSet); assertThat(set.subSet("c", "g")).contains("e"); assertThat(set.subSet("e", "g")).contains("e"); assertSame(of(), set.subSet("f", "g")); assertSame(of(), set.subSet("c", "e")); assertSame(of(), set.subSet("c", "d")); }
@GwtIncompatible // SerializableTester public void testExplicit_serialization() { SortedSet<String> set = ImmutableSortedSet.orderedBy(STRING_LENGTH) .add("in", "the", "quick", "jumped", "over", "a") .build(); SortedSet<String> copy = SerializableTester.reserializeAndAssert(set); assertTrue(Iterables.elementsEqual(set, copy)); assertSame(set.comparator(), copy.comparator()); }