Skip to content

Commit aad3499

Browse files
committed
feat(UtilsTest, UtilsTestRunner): partial implementation of Junit Tests to test Utils.java functions
1 parent 6bba20a commit aad3499

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.aniakanl.http2.frame.test;
2+
3+
import static org.junit.Assert.assertArrayEquals;
4+
import org.junit.Test;
5+
6+
import com.aniakanl.utils.Utils;
7+
8+
public class UtilsTest {
9+
10+
@Test
11+
public void testDoubleToBinary() {
12+
13+
double testDouble = 23;
14+
byte[] expectedResult = { 0, 0, 0, 0, 0, 0, 55, 64};
15+
16+
assertArrayEquals(expectedResult, Utils.convertToBinary(testDouble));
17+
18+
}
19+
20+
@Test
21+
public void testStringToBinary() {
22+
23+
String testString = "TestString";
24+
byte[] expectedResult = {84,101,115,116,83,116,114,105,110,103,0};
25+
26+
assertArrayEquals(expectedResult, Utils.convertToBinary(testString));
27+
28+
}
29+
30+
public void testLongToBinary(){
31+
32+
}
33+
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.aniakanl.http2.frame.test;
2+
3+
import org.junit.runner.JUnitCore;
4+
import org.junit.runner.Result;
5+
import org.junit.runner.notification.Failure;
6+
7+
public class UtilsTestRunner {
8+
9+
public static void main(String[] args) {
10+
Result result = JUnitCore.runClasses(UtilsTest.class);
11+
12+
for (Failure failure : result.getFailures()) {
13+
System.out.println(failure.toString());
14+
}
15+
16+
System.out.println(result.wasSuccessful());
17+
}
18+
}

0 commit comments

Comments
 (0)