Skip to content

Commit

Permalink
Merge pull request #367 from Diffblue-benchmarks/os-pr-day-5-aug
Browse files Browse the repository at this point in the history
Additional tests for com.blade.kit.ConvertKit
  • Loading branch information
hellokaton authored Sep 26, 2019
2 parents 7c83575 + 12faed2 commit d32a3ea
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 d32a3ea

Please sign in to comment.