mirror of https://github.com/apache/jmeter.git
Add unit tests for org.apache.jorphan.util.JOrphanUtils (#472)
These tests were written using Diffblue Cover
This commit is contained in:
parent
02b9d8aabb
commit
05d39754aa
|
|
@ -255,6 +255,12 @@ public class TestJorphanUtils {
|
|||
assertEquals("abc",JOrphanUtils.trim("abc ;", " ;"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetByteArraySlice() throws Exception {
|
||||
Assert.assertArrayEquals(new byte[] {1, 2},
|
||||
JOrphanUtils.getByteArraySlice(new byte[]{0, 1, 2, 3}, 1, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testbaToHexString(){
|
||||
assertEquals("",JOrphanUtils.baToHexString(new byte[]{}));
|
||||
|
|
@ -262,6 +268,13 @@ public class TestJorphanUtils {
|
|||
assertEquals("0f107f8081ff",JOrphanUtils.baToHexString(new byte[]{15,16,127,-128,-127,-1}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaToHexStringSeparator(){
|
||||
assertEquals("", JOrphanUtils.baToHexString(new byte[]{}, '-'));
|
||||
assertEquals("00", JOrphanUtils.baToHexString(new byte[]{0}, '-'));
|
||||
assertEquals("0f-10-7f-80-81-ff", JOrphanUtils.baToHexString(new byte[]{15,16,127,-128,-127,-1}, '-'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testbaToByte() throws Exception{
|
||||
assertEqualsArray(new byte[]{},JOrphanUtils.baToHexBytes(new byte[]{}));
|
||||
|
|
@ -277,6 +290,13 @@ public class TestJorphanUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullifyIfEmptyTrimmed() {
|
||||
Assert.assertNull(JOrphanUtils.nullifyIfEmptyTrimmed(null));
|
||||
Assert.assertNull(JOrphanUtils.nullifyIfEmptyTrimmed("\u0001"));
|
||||
assertEquals("1234", JOrphanUtils.nullifyIfEmptyTrimmed("1234"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsBlank() {
|
||||
assertTrue(JOrphanUtils.isBlank(""));
|
||||
|
|
@ -295,6 +315,24 @@ public class TestJorphanUtils {
|
|||
assertEquals("baulpismuth", JOrphanUtils.rightAlign(in, 6).toString());
|
||||
in = new StringBuilder("A");
|
||||
assertEquals(" A", JOrphanUtils.rightAlign(in, 8).toString());
|
||||
assertEquals(" foo",
|
||||
JOrphanUtils.rightAlign(new StringBuilder("foo"), 39).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeftAlign() {
|
||||
assertEquals("foo ",
|
||||
JOrphanUtils.leftAlign(new StringBuilder("foo"), 5).toString());
|
||||
assertEquals("foo",
|
||||
JOrphanUtils.leftAlign(new StringBuilder("foo"), 2).toString());
|
||||
assertEquals("foo ",
|
||||
JOrphanUtils.leftAlign(new StringBuilder("foo"), 39).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBooleanToSTRING() {
|
||||
assertEquals("TRUE", JOrphanUtils.booleanToSTRING(true));
|
||||
assertEquals("FALSE", JOrphanUtils.booleanToSTRING(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -357,4 +395,11 @@ public class TestJorphanUtils {
|
|||
public void testReplaceValueWithNullSetterThatGetsCalled() {
|
||||
JOrphanUtils.replaceValue("\\d+", "${port}", true, "80", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsplit() {
|
||||
assertEquals("", JOrphanUtils.unsplit(new Object[] {null, null}, 0));
|
||||
assertEquals("11", JOrphanUtils.unsplit(new Object[] {null, 1}, 1));
|
||||
assertEquals("-26738698", JOrphanUtils.unsplit(new Object[] {-26_738_698}, 1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue