|
30 | 30 | */ |
31 | 31 | package org.bridj; |
32 | 32 | import java.io.File; |
| 33 | +import org.bridj.ann.Constructor; |
33 | 34 | import org.bridj.ann.Library; |
34 | 35 | import org.bridj.ann.Virtual; |
35 | 36 | import org.bridj.cpp.CPPObject; |
36 | 37 |
|
37 | 38 | import org.bridj.*; |
38 | 39 | import static org.bridj.Pointer.*; |
| 40 | +import org.bridj.ann.Field; |
39 | 41 | import org.junit.Test; |
40 | 42 | import static org.junit.Assert.*; |
41 | 43 | import org.junit.Ignore; |
@@ -109,4 +111,28 @@ public int add(int a, int b) { |
109 | 111 | }; |
110 | 112 | assertEquals(210, testIVirtualAdd(getPointer(v), 1, 2)); |
111 | 113 | } |
| 114 | + |
| 115 | + public static class Hello extends CPPObject { |
| 116 | + @Constructor(0) |
| 117 | + public Hello(Pointer<Integer> a, Pointer<Integer> b) { |
| 118 | + super((Void)null, 0, a, b); |
| 119 | + } |
| 120 | + public native int Sum(); |
| 121 | + @Field(0) |
| 122 | + public int a() { |
| 123 | + return io.getIntField(this, 0); |
| 124 | + } |
| 125 | + @Field(1) |
| 126 | + public int b() { |
| 127 | + return io.getIntField(this, 1); |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + public void testHello() { |
| 133 | + Hello h = new Hello(pointerToInt(1), pointerToInt(2)); |
| 134 | + assertEquals(1, h.a()); |
| 135 | + assertEquals(2, h.b()); |
| 136 | + assertEquals(3, h.Sum()); |
| 137 | + } |
112 | 138 | } |
0 commit comments