aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cz/crcs/ectester/common/test/CompoundTest.java2
-rw-r--r--src/cz/crcs/ectester/common/test/TestSuite.java12
-rw-r--r--src/cz/crcs/ectester/common/util/ByteUtil.java17
3 files changed, 30 insertions, 1 deletions
diff --git a/src/cz/crcs/ectester/common/test/CompoundTest.java b/src/cz/crcs/ectester/common/test/CompoundTest.java
index 10ecf9c..69122b0 100644
--- a/src/cz/crcs/ectester/common/test/CompoundTest.java
+++ b/src/cz/crcs/ectester/common/test/CompoundTest.java
@@ -12,7 +12,7 @@ import java.util.function.Function;
public class CompoundTest extends Test {
private Function<Test[], Result> callback;
private Test[] tests;
- private String description;
+ private String description = "";
private CompoundTest(Function<Test[], Result> callback, Test... tests) {
this.callback = callback;
diff --git a/src/cz/crcs/ectester/common/test/TestSuite.java b/src/cz/crcs/ectester/common/test/TestSuite.java
index f4f30ee..5bcee85 100644
--- a/src/cz/crcs/ectester/common/test/TestSuite.java
+++ b/src/cz/crcs/ectester/common/test/TestSuite.java
@@ -32,11 +32,23 @@ public abstract class TestSuite {
writer.end();
}
+ /**
+ * Run the given test and return it back.
+ * @param t The test to run.
+ * @return The test that was run.
+ * @throws TestException
+ */
protected Test runTest(Test t) throws TestException {
t.run();
return t;
}
+ /**
+ * Run the given test, output it and return it back.
+ * @param t The test to run.
+ * @return The test that was run.
+ * @throws TestException
+ */
protected Test doTest(Test t) throws TestException {
t.run();
writer.outputTest(t);
diff --git a/src/cz/crcs/ectester/common/util/ByteUtil.java b/src/cz/crcs/ectester/common/util/ByteUtil.java
index 90c6eaa..ad9f1bf 100644
--- a/src/cz/crcs/ectester/common/util/ByteUtil.java
+++ b/src/cz/crcs/ectester/common/util/ByteUtil.java
@@ -39,6 +39,23 @@ public class ByteUtil {
return true;
}
+ public static byte[] shortToBytes(short value) {
+ byte[] result = new byte[2];
+ setShort(result, 0, value);
+ return result;
+ }
+
+ public static byte[] shortToBytes(short[] shorts) {
+ if (shorts == null) {
+ return null;
+ }
+ byte[] result = new byte[shorts.length * 2];
+ for (int i = 0; i < shorts.length; ++i) {
+ setShort(result, 2 * i, shorts[i]);
+ }
+ return result;
+ }
+
public static byte[] hexToBytes(String hex) {
return hexToBytes(hex, true);
}