Skip to content

Commit 604c211

Browse files
committed
Both DataBlock.rd and DataBlock.wr inherits byte order from the source byte buffer.
1 parent 91b4684 commit 604c211

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<sequential>
3737
<property name="testName" value=""/>
3838
<get-test-name propertyName="testName"/>
39-
<java classname="org.jsl.tests.${testName}.Main" fork="true">
39+
<java classname="org.jsl.tests.${testName}.Main" fork="true" failonerror="true">
4040
<classpath>
4141
<pathelement location="${build}/classes"/>
4242
<pathelement location="${build}/tests"/>

src/main/java/org/jsl/collider/DataBlock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public DataBlock(ByteBuffer buf)
3131
{
3232
wr = buf;
3333
rd = buf.duplicate();
34+
rd.order(buf.order());
3435
}
3536

3637
public final DataBlock reset()

tests/src/org/jsl/tests/unit/Main.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
import java.nio.ByteOrder;
2323
import org.jsl.collider.DataBlock;
2424

25+
interface TestFunc {
26+
void run() throws Exception;
27+
}
28+
2529
public class Main {
2630
private static void dataBlockInheritsByteOrder() throws Exception {
2731
final ByteOrder [] orders = {ByteOrder.LITTLE_ENDIAN, ByteOrder.BIG_ENDIAN};
@@ -38,13 +42,20 @@ private static void dataBlockInheritsByteOrder() throws Exception {
3842
}
3943
}
4044

41-
public static void main(String [] args) {
42-
int failedTests = 0;
43-
try { dataBlockInheritsByteOrder(); }
44-
catch (final Exception ex) {
45+
private static int runTest(TestFunc testFunc) {
46+
try {
47+
testFunc.run();
48+
return 0;
49+
} catch (final Exception ex) {
4550
System.out.println(ex.getMessage());
46-
failedTests++;
51+
return 1;
4752
}
53+
}
54+
55+
public static void main(String [] args) {
56+
int failedTests = 0;
57+
failedTests += runTest(Main::dataBlockInheritsByteOrder);
4858
System.out.println(failedTests + " tests failed");
59+
System.exit((failedTests == 0) ? 0 : -1);
4960
}
5061
}

tests/tests.iml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="true" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="module" module-name="js-collider" />
11+
</component>
12+
</module>

0 commit comments

Comments
 (0)