Skip to content

Commit 7a5d21f

Browse files
committed
Test.
1 parent acb013e commit 7a5d21f

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

build.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@
189189
<run-test/>
190190
</target>
191191

192+
<target name="test.unit" depends="compile_tests">
193+
<run-test/>
194+
</target>
195+
192196
<target name="tests"
193197
depends="test.buffer_overlap_copy,
194198
test.byte_buffer_pool,
@@ -198,6 +202,7 @@
198202
test.echo_throughput,
199203
test.message_queue,
200204
test.msg_size_eq_block_size,
205+
test.pubsub,
201206
test.recv_throughput,
202207
test.remove_acceptor,
203208
test.session_latency,
@@ -207,6 +212,6 @@
207212
test.thread_pool,
208213
test.thread_pool_throughput,
209214
test.timer_queue,
210-
test.pubsub"/>
215+
test.unit"/>
211216

212217
</project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2013 Sergey Zubarev, info@js-labs.org
3+
*
4+
* This file is a part of JS-Collider test.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package org.jsl.tests.unit;
20+
21+
import java.nio.ByteBuffer;
22+
import java.nio.ByteOrder;
23+
import org.jsl.collider.DataBlock;
24+
25+
public class Main {
26+
private static void dataBlockInheritsByteOrder() throws Exception {
27+
final ByteOrder [] orders = {ByteOrder.LITTLE_ENDIAN, ByteOrder.BIG_ENDIAN};
28+
for (ByteOrder byteOrder: orders) {
29+
final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(32);
30+
byteBuffer.order(byteOrder);
31+
final DataBlock dataBlock = new DataBlock(byteBuffer);
32+
if (dataBlock.rd.order() != byteOrder) {
33+
throw new Exception("wrong dataBlock.rd.order()");
34+
}
35+
if (dataBlock.wr.order() != byteOrder) {
36+
throw new Exception("wrong dataBlock.wr.order()");
37+
}
38+
}
39+
}
40+
41+
public static void main(String [] args) {
42+
int failedTests = 0;
43+
try { dataBlockInheritsByteOrder(); }
44+
catch (final Exception ex) {
45+
System.out.println(ex.getMessage());
46+
failedTests++;
47+
}
48+
System.out.println(failedTests + " tests failed");
49+
}
50+
}

0 commit comments

Comments
 (0)