Skip to content

Commit e6abe86

Browse files
gliptakjbgi
authored andcommitted
Add tests for Strings (#295)
1 parent 49c6f8d commit e6abe86

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package fj.function;
2+
3+
import fj.Function;
4+
import org.junit.Test;
5+
6+
import static fj.F1Functions.o;
7+
import static fj.Function.compose;
8+
import static fj.function.Strings.*;
9+
import static org.junit.Assert.*;
10+
import static org.hamcrest.core.Is.is;
11+
12+
public class StringsTest {
13+
@Test
14+
public void testLines() {
15+
assertThat(compose(unlines(), lines()).f("one two three"), is("one two three"));
16+
}
17+
18+
@Test
19+
public void testLinesEmpty() {
20+
assertThat(o(unlines(), lines()).f(""), is(""));
21+
}
22+
23+
@Test
24+
public void testLength() {
25+
assertThat(length.f("functionaljava"), is(14));
26+
}
27+
28+
@Test
29+
public void testMatches() {
30+
assertThat(matches.f("foo").f("foo"), is(true));
31+
}
32+
33+
@Test
34+
public void testContains() {
35+
assertThat(contains.f("bar").f("foobar1"), is(true));
36+
}
37+
38+
@Test(expected = NullPointerException.class)
39+
public void testIsEmptyException() {
40+
assertThat(isEmpty.f(null), is(true));
41+
}
42+
43+
@Test
44+
public void testIsEmpty() {
45+
assertThat(isEmpty.f(""), is(true));
46+
}
47+
48+
@Test
49+
public void testIsNotNullOrEmpty() {
50+
assertThat(isNotNullOrEmpty.f("foo"), is(true));
51+
}
52+
53+
@Test
54+
public void testIsNullOrEmpty() {
55+
assertThat(isNullOrEmpty.f(null), is(true));
56+
}
57+
58+
@Test
59+
public void testIsNotNullOrBlank() {
60+
assertThat(isNotNullOrBlank.f("foo"), is(true));
61+
}
62+
63+
@Test
64+
public void testIsNullOrBlank() {
65+
assertThat(isNullOrBlank.f(" "), is(true));
66+
}
67+
}

0 commit comments

Comments
 (0)