forked from shekhargulati/strman-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpropertyTest_2.java
More file actions
92 lines (79 loc) · 3.32 KB
/
propertyTest_2.java
File metadata and controls
92 lines (79 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import com.pholser.junit.quickcheck.Property;
import com.pholser.junit.quickcheck.runner.JUnitQuickcheck;
import org.junit.runner.RunWith;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeThat;
@RunWith(JUnitQuickcheck.class)
public class propertyTest_2 {
// #1: This test was passed
@Property
public void betweenNotEmptyShouldContainStartAndEnd(final String value, final String start, final String end) {
if (Strman.between(value, start, end).length > 0) {
assertTrue(Strman.contains(value, start));
assertTrue(Strman.contains(value, end));
}
}
// #2: This test was passed
@Property
public void charsLengthReturnsOneOnEmptyString(final String value) {
if(value.isEmpty())
assertTrue(1 == Strman.chars(value).length);
}
// #3: This test was passed
@Property
public void charsLengthEqualsNonEmptyString(final String value) {
if(!value.isEmpty())
assertTrue(value.length() == Strman.chars(value).length);
}
// #4: This test was passed
@Property
public void collapseWhiteSpaceHasLessOrEqualLength(final String value) {
assertTrue(Strman.collapseWhitespace(value).length() <= value.length());
}
// #5: This test was passed
@Property
public void containsAllReturnNonEmptyBetween(final String value, final String[] needles) {
String[] test = {""};
if (Strman.containsAll(value,needles,true))
for (int i = 0; i < needles.length - 1; i++)
for (int j = i + 1 ; j < needles.length - 1; j++)
assertTrue(Strman.between(value,needles[i],needles[j]) != test);
}
// #6: This test was passed
@Property
public void ensureLeftContainsBoth(final String value, final String prefix) {
assertTrue(Strman.contains(Strman.ensureLeft(value, prefix), prefix));
assertTrue(Strman.contains(Strman.ensureLeft(value, prefix), value));
}
// #7: This test was passed
@Property
public void ensureRightContainsBoth(final String value, final String suffix) {
assertTrue(Strman.contains(Strman.ensureLeft(value, suffix), suffix));
assertTrue(Strman.contains(Strman.ensureLeft(value, suffix), value));
}
// #8: This test was passed
@Property
public void unEqualReturnFalse(final String value) {
assertFalse(Strman.unequal(value, value));
}
// #9: This test was passed
@Property
public void insertRemainTotalLength(final String value, final String substr, final int index) {
if (index > value.length())
assertEquals(value, Strman.insert(value,substr,index));
else {
if (index >= 0)
assertEquals(value.length() + substr.length(),
Strman.insert(value, substr, index).length());
}
}
// #10: This test was failed
@Property
public void countSubstrReturnNonZeroIfContain(final String value, final String subStr) {
assumeThat (value, containsString(subStr));
assertTrue(Strman.countSubstr(value, subStr) > 0L);
}
}