MCPcopy Create free account
hub / github.com/alibaba/MNN / main

Method main

3rd_party/flatbuffers/tests/JavaTest.java:29–76  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

27
28class JavaTest {
29 public static void main(String[] args) {
30
31 // First, let's test reading a FlatBuffer generated by C++ code:
32 // This file was generated from monsterdata_test.json
33
34 byte[] data = null;
35 File file = new File("monsterdata_test.mon");
36 RandomAccessFile f = null;
37 try {
38 f = new RandomAccessFile(file, "r");
39 data = new byte[(int)f.length()];
40 f.readFully(data);
41 f.close();
42 } catch(java.io.IOException e) {
43 System.out.println("FlatBuffers test: couldn't read file");
44 return;
45 }
46
47 // Now test it:
48
49 ByteBuffer bb = ByteBuffer.wrap(data);
50 TestBuffer(bb);
51
52 // Second, let's create a FlatBuffer from scratch in Java, and test it also.
53 // We use an initial size of 1 to exercise the reallocation algorithm,
54 // normally a size larger than the typical FlatBuffer you generate would be
55 // better for performance.
56 FlatBufferBuilder fbb = new FlatBufferBuilder(1);
57
58 TestBuilderBasics(fbb, true);
59 TestBuilderBasics(fbb, false);
60
61 TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer());
62
63 TestNamespaceNesting();
64
65 TestNestedFlatBuffer();
66
67 TestCreateByteVector();
68
69 TestCreateUninitializedVector();
70
71 TestByteBufferFactory();
72
73 TestSizedInputStream();
74
75 System.out.println("FlatBuffers test: completed successfully");
76 }
77
78 static void TestEnums() {
79 TestEq(Color.name(Color.Red), "Red");

Calls 11

TestBufferMethod · 0.95
TestBuilderBasicsMethod · 0.95
TestExtendedBufferMethod · 0.95
TestNamespaceNestingMethod · 0.95
TestNestedFlatBufferMethod · 0.95
TestCreateByteVectorMethod · 0.95
TestByteBufferFactoryMethod · 0.95
TestSizedInputStreamMethod · 0.95
lengthMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected