Skip to content

Commit e48a7a1

Browse files
authored
Merge pull request #217 from Diffblue-benchmarks/add-diffblue-unit-tests
Add additional unit tests
2 parents 816efb8 + 6e56d6d commit e48a7a1

File tree

3 files changed

+167
-1
lines changed

3 files changed

+167
-1
lines changed

Diff for: src/test/java/com/jsoniter/TestOmitValue.java

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
package com.jsoniter;
2+
3+
import com.jsoniter.spi.OmitValue.*;
4+
import junit.framework.TestCase;
5+
6+
public class TestOmitValue extends TestCase {
7+
8+
public void test_shouldOmitInputPositiveOutputFalse() {
9+
10+
// Arrange
11+
final ZeroByte objectUnderTest = new ZeroByte();
12+
final Object val = (byte)1;
13+
14+
// Act
15+
final boolean retval = objectUnderTest.shouldOmit(val);
16+
17+
// Assert result
18+
assertEquals(false, retval);
19+
}
20+
21+
public void test_shouldOmitInputPositiveOutputFalse2() {
22+
23+
// Arrange
24+
final ZeroInt objectUnderTest = new ZeroInt();
25+
final Object val = 1;
26+
27+
// Act
28+
final boolean retval = objectUnderTest.shouldOmit(val);
29+
30+
// Assert result
31+
assertEquals(false, retval);
32+
}
33+
34+
public void test_shouldOmitInputPositiveOutputFalse3() {
35+
36+
// Arrange
37+
final ZeroLong objectUnderTest = new ZeroLong();
38+
final Object val = 1L;
39+
40+
// Act
41+
final boolean retval = objectUnderTest.shouldOmit(val);
42+
43+
// Assert result
44+
assertEquals(false, retval);
45+
}
46+
47+
public void test_shouldOmitInputZeroOutputTrue() {
48+
49+
// Arrange
50+
final ZeroLong objectUnderTest = new ZeroLong();
51+
final Object val = 0L;
52+
53+
// Act
54+
final boolean retval = objectUnderTest.shouldOmit(val);
55+
56+
// Assert result
57+
assertEquals(true, retval);
58+
}
59+
60+
public void test_shouldOmitInputPositiveOutputFalse4() {
61+
62+
// Arrange
63+
final ZeroShort objectUnderTest = new ZeroShort();
64+
final Object val = (short)1;
65+
66+
// Act
67+
final boolean retval = objectUnderTest.shouldOmit(val);
68+
69+
// Assert result
70+
assertEquals(false, retval);
71+
}
72+
73+
public void test_shouldOmitInputTrueOutputFalse() {
74+
75+
// Arrange
76+
final False objectUnderTest = new False();
77+
final Object val = true;
78+
79+
// Act
80+
final boolean retval = objectUnderTest.shouldOmit(val);
81+
82+
// Assert result
83+
assertEquals(false, retval);
84+
}
85+
86+
public void test_shouldOmitInputNotNullOutputFalse() {
87+
88+
// Arrange
89+
final ZeroChar objectUnderTest = new ZeroChar();
90+
final Object val = '\u0001';
91+
92+
// Act
93+
final boolean retval = objectUnderTest.shouldOmit(val);
94+
95+
// Assert result
96+
assertEquals(false, retval);
97+
}
98+
99+
public void test_shouldOmitInputPositiveOutputFalse5() {
100+
101+
// Arrange
102+
final ZeroDouble objectUnderTest = new ZeroDouble();
103+
final Object val = 0x0.0000000000001p-1022 /* 4.94066e-324 */;
104+
105+
// Act
106+
final boolean retval = objectUnderTest.shouldOmit(val);
107+
108+
// Assert result
109+
assertEquals(false, retval);
110+
}
111+
112+
public void test_shouldOmitInputZeroOutputTrue2() {
113+
114+
// Arrange
115+
final ZeroDouble objectUnderTest = new ZeroDouble();
116+
final Object val = 0.0;
117+
118+
// Act
119+
final boolean retval = objectUnderTest.shouldOmit(val);
120+
121+
// Assert result
122+
assertEquals(true, retval);
123+
}
124+
125+
public void test_shouldOmitInputPositiveOutputFalse6() {
126+
127+
// Arrange
128+
final ZeroFloat objectUnderTest = new ZeroFloat();
129+
final Object val = 0x1p-149f /* 1.4013e-45 */;
130+
131+
// Act
132+
final boolean retval = objectUnderTest.shouldOmit(val);
133+
134+
// Assert result
135+
assertEquals(false, retval);
136+
}
137+
}

Diff for: src/test/java/com/jsoniter/TestSlice.java

+28
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,32 @@ public void test_hashcode() {
1919
assertEquals("hello", map.get(Slice.make("hello")));
2020
assertEquals("world", map.get(Slice.make("world")));
2121
}
22+
23+
public void test_equalsInputNotNullOutputFalse2() {
24+
25+
// Arrange
26+
final byte[] byteArray = {(byte)2, (byte)1};
27+
final Slice objectUnderTest = new Slice(byteArray, 0, 1073741825);
28+
final byte[] byteArray1 = {(byte)0};
29+
final Slice o = new Slice(byteArray1, 0, 1073741825);
30+
31+
// Act
32+
final boolean retval = objectUnderTest.equals(o);
33+
34+
// Assert result
35+
assertEquals(false, retval);
36+
}
37+
38+
public void test_equalsInputNotNullOutputFalse() {
39+
40+
// Arrange
41+
final Slice objectUnderTest = new Slice(null, 0, -2147483646);
42+
final Slice o = new Slice(null, 0, 2);
43+
44+
// Act
45+
final boolean retval = objectUnderTest.equals(o);
46+
47+
// Assert result
48+
assertEquals(false, retval);
49+
}
2250
}

Diff for: src/test/java/com/jsoniter/suite/AllTestCases.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
TestCollection.class,
5757
TestList.class,
5858
TestAnnotationJsonObject.class,
59-
TestLong.class})
59+
TestLong.class,
60+
TestOmitValue.class})
6061
public abstract class AllTestCases {
6162
}

0 commit comments

Comments
 (0)