Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vavr/src/main/java/io/vavr/collection/CharSeq.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* @author Ruslan Sennov, Daniel Dietrich
*/
public final class CharSeq implements CharSequence, IndexedSeq<Character>, Serializable {
public final class CharSeq implements CharSequence, IndexedSeq<Character>, Serializable, Comparable<CharSeq> {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -2356,7 +2356,7 @@ public CharSeq replace(CharSequence target, CharSequence replacement) {
* </tr>
* </table>
* </blockquote>
*
*
* @param regex the delimiting regular expression
* @return the Seq of strings computed by splitting this string around matches of the given regular expression
* @throws PatternSyntaxException if the regular expression's syntax is invalid
Expand Down Expand Up @@ -2430,7 +2430,7 @@ public Seq<CharSeq> split(String regex) {
* Pattern#split(CharSequence, int) split}(<i>str</i>,&nbsp;<i>n</i>)
* </code>
* </blockquote>
*
*
* @param regex the delimiting regular expression
* @param limit the result threshold, as described above
* @return the Seq of strings computed by splitting this string around matches of the given regular expression
Expand Down
27 changes: 25 additions & 2 deletions vavr/src/test/java/io/vavr/collection/CharSeqTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ public void shouldConvertAsJavaImmutableAndRethrowException() {
.hasMessage("test");
}

// -- compareTo(Object)

@Test
public void shouldCastTheCharSeqIntoJavaLangComparable() {
assertThat(CharSeq.empty()).isInstanceOf(Comparable.class);
}

@Test
public void shouldCompareToWhenLessThan() {
assertThat(CharSeq.of("a").compareTo(CharSeq.of("b"))).isEqualTo(-1);
}

@Test
public void shouldCompareToWhenGreaterThan() {
assertThat(CharSeq.of("b").compareTo(CharSeq.of("a"))).isEqualTo(1);
}

@Test
public void shouldCompareToWhenEqualsThan() {
assertThat(CharSeq.of("a").compareTo(CharSeq.of("a"))).isEqualTo(0);
}

// -- exists

@Test
Expand Down Expand Up @@ -791,7 +813,7 @@ public void shouldFilterNonEmptyTraversableAllMatch() {
final CharSeq t = CharSeq.of('1', '2', '3', '4');
assertThat(t.filter(i -> true)).isSameAs(t);
}

// -- reject

@Test
Expand Down Expand Up @@ -1520,7 +1542,7 @@ public void shouldSlideNonNilBySomeClassifier() {
final io.vavr.collection.List<Traversable<Character>> expected = io.vavr.collection.List.of(Vector.of('1', '1', '1'), Vector.of('2', '2'), Vector.of('3'), Vector.of('4'));
assertThat(actual).isEqualTo(expected);
}

// -- sliding(size)

@Test(expected = IllegalArgumentException.class)
Expand Down Expand Up @@ -4017,4 +4039,5 @@ public void shouldConvertToShortUsingRadix() {
public void shouldNotConvertToShortUsingRadixGivenEmptyCharSeq() {
CharSeq.empty().toShort(2);
}

}