Skip to content

Add additional unit tests #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
137 changes: 137 additions & 0 deletions src/test/java/com/jsoniter/TestOmitValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.jsoniter;

import com.jsoniter.spi.OmitValue.*;
import junit.framework.TestCase;

public class TestOmitValue extends TestCase {

public void test_shouldOmitInputPositiveOutputFalse() {

// Arrange
final ZeroByte objectUnderTest = new ZeroByte();
final Object val = (byte)1;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputPositiveOutputFalse2() {

// Arrange
final ZeroInt objectUnderTest = new ZeroInt();
final Object val = 1;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputPositiveOutputFalse3() {

// Arrange
final ZeroLong objectUnderTest = new ZeroLong();
final Object val = 1L;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputZeroOutputTrue() {

// Arrange
final ZeroLong objectUnderTest = new ZeroLong();
final Object val = 0L;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(true, retval);
}

public void test_shouldOmitInputPositiveOutputFalse4() {

// Arrange
final ZeroShort objectUnderTest = new ZeroShort();
final Object val = (short)1;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputTrueOutputFalse() {

// Arrange
final False objectUnderTest = new False();
final Object val = true;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputNotNullOutputFalse() {

// Arrange
final ZeroChar objectUnderTest = new ZeroChar();
final Object val = '\u0001';

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputPositiveOutputFalse5() {

// Arrange
final ZeroDouble objectUnderTest = new ZeroDouble();
final Object val = 0x0.0000000000001p-1022 /* 4.94066e-324 */;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}

public void test_shouldOmitInputZeroOutputTrue2() {

// Arrange
final ZeroDouble objectUnderTest = new ZeroDouble();
final Object val = 0.0;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(true, retval);
}

public void test_shouldOmitInputPositiveOutputFalse6() {

// Arrange
final ZeroFloat objectUnderTest = new ZeroFloat();
final Object val = 0x1p-149f /* 1.4013e-45 */;

// Act
final boolean retval = objectUnderTest.shouldOmit(val);

// Assert result
assertEquals(false, retval);
}
}
28 changes: 28 additions & 0 deletions src/test/java/com/jsoniter/TestSlice.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,32 @@ public void test_hashcode() {
assertEquals("hello", map.get(Slice.make("hello")));
assertEquals("world", map.get(Slice.make("world")));
}

public void test_equalsInputNotNullOutputFalse2() {

// Arrange
final byte[] byteArray = {(byte)2, (byte)1};
final Slice objectUnderTest = new Slice(byteArray, 0, 1073741825);
final byte[] byteArray1 = {(byte)0};
final Slice o = new Slice(byteArray1, 0, 1073741825);

// Act
final boolean retval = objectUnderTest.equals(o);

// Assert result
assertEquals(false, retval);
}

public void test_equalsInputNotNullOutputFalse() {

// Arrange
final Slice objectUnderTest = new Slice(null, 0, -2147483646);
final Slice o = new Slice(null, 0, 2);

// Act
final boolean retval = objectUnderTest.equals(o);

// Assert result
assertEquals(false, retval);
}
}
3 changes: 2 additions & 1 deletion src/test/java/com/jsoniter/suite/AllTestCases.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
TestCollection.class,
TestList.class,
TestAnnotationJsonObject.class,
TestLong.class})
TestLong.class,
TestOmitValue.class})
public abstract class AllTestCases {
}