Skip to content

Commit

Permalink
Additional tests for CovertKit
Browse files Browse the repository at this point in the history
* byte2FitMemoryString
* memorySize2Byte
* string2OutputStream

These tests were written using Diffblue Cover.
  • Loading branch information
Darren Royle committed Aug 5, 2019
1 parent 55bd109 commit 12faed2
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/test/java/com/blade/kit/ConvertKitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/**
* @author biezhi
Expand Down Expand Up @@ -74,6 +75,46 @@ public void byte2FitMemorySize() throws Exception {
);
}

@Test
public void byte2FitMemoryStringLessThanZero() {
assertEquals(
"shouldn\'t be less than zero!",
ConvertKit.byte2FitMemoryString(-1024)
);
}

@Test
public void byte2FitMemoryStringGB() {
assertEquals(
"1 GB",
ConvertKit.byte2FitMemoryString(1024 * 1024 * 1024)
);
}

@Test
public void byte2FitMemoryStringMB() {
assertEquals(
"1 MB",
ConvertKit.byte2FitMemoryString(1024 * 1024)
);
}

@Test
public void byte2FitMemoryStringKB() {
assertEquals(
"1 KB",
ConvertKit.byte2FitMemoryString(1024)
);
}

@Test
public void byte2FitMemoryStringB() {
assertEquals(
"1 B",
ConvertKit.byte2FitMemoryString(1)
);
}

@Test
public void bytes2Bits_bits2Bytes() throws Exception {
assertEquals(
Expand Down Expand Up @@ -106,4 +147,34 @@ public void inputStream2String_string2InputStream() throws Exception {
);
}

@Test
public void memorySize2ByteInputNegativeZeroOutputNegative() {
assertEquals(
-1L,
ConvertKit.memorySize2Byte(-9_223_372_036_854_775_807L, 0)
);
}

@Test
public void memorySize2ByteInputZeroOutputZero() {
assertEquals(
0L,
ConvertKit.memorySize2Byte(0L, 0)
);
}

@Test
public void string2OutputStreamInputQuestionsReturnNull() {
assertNull(
ConvertKit.string2OutputStream("\u0000\u0000\u0000???????????????????", "")
);
}

@Test
public void string2OutputStreamInputUnicodeReturnNewline() {
assertNull(
ConvertKit.string2OutputStream("\u0000\u0000", "\n")
);
}

}

0 comments on commit 12faed2

Please sign in to comment.