Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions core/src/test/java/fj/function/StringsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package fj.function;

import fj.Function;
import org.junit.Test;

import static fj.F1Functions.o;
import static fj.Function.compose;
import static fj.function.Strings.*;
import static org.junit.Assert.*;
import static org.hamcrest.core.Is.is;

public class StringsTest {
@Test
public void testLines() {
assertThat(compose(unlines(), lines()).f("one two three"), is("one two three"));
}

@Test
public void testLinesEmpty() {
assertThat(o(unlines(), lines()).f(""), is(""));
}

@Test
public void testLength() {
assertThat(length.f("functionaljava"), is(14));
}

@Test
public void testMatches() {
assertThat(matches.f("foo").f("foo"), is(true));
}

@Test
public void testContains() {
assertThat(contains.f("bar").f("foobar1"), is(true));
}

@Test(expected = NullPointerException.class)
public void testIsEmptyException() {
assertThat(isEmpty.f(null), is(true));
}

@Test
public void testIsEmpty() {
assertThat(isEmpty.f(""), is(true));
}

@Test
public void testIsNotNullOrEmpty() {
assertThat(isNotNullOrEmpty.f("foo"), is(true));
}

@Test
public void testIsNullOrEmpty() {
assertThat(isNullOrEmpty.f(null), is(true));
}

@Test
public void testIsNotNullOrBlank() {
assertThat(isNotNullOrBlank.f("foo"), is(true));
}

@Test
public void testIsNullOrBlank() {
assertThat(isNullOrBlank.f(" "), is(true));
}
}