Skip to content

Commit

Permalink
Test String ref and value
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Aug 19, 2024
1 parent dd4b1d2 commit 2c12c69
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.xpenatan.jparser.example.testlib.TestMethodClass;
import com.github.xpenatan.jparser.example.testlib.TestObjectClass;
import com.github.xpenatan.jparser.example.testlib.TestObjectClassArray;
import com.github.xpenatan.jparser.example.testlib.idl.helper.IDLString;

public class TestLib {

Expand Down Expand Up @@ -207,6 +208,37 @@ private static boolean testMethodClass() {
array.dispose();
test.dispose();
}
{
TestMethodClass test = new TestMethodClass();
try {
String strValue01 = "Hello";
test.setMethod05(strValue01);
String stringValue = test.getStrValue01().data();
if(!(strValue01.equals(stringValue))) {
throw new RuntimeException("strValue01.equals(stringValue)");
}
} catch(Throwable e) {
e.printStackTrace();
test.dispose();
}

}
{
TestMethodClass test = new TestMethodClass();
try {
String strValue01 = "RefHello";
test.setMethod05(strValue01);
IDLString refStrValue01 = test.getRefStrValue01();
String stringValue = refStrValue01.data();
if(!(strValue01.equals(stringValue))) {
throw new RuntimeException("strValue01.equals(stringValue)");
}
} catch(Throwable e) {
e.printStackTrace();
test.dispose();
}

}
return true;
}

Expand Down
1 change: 1 addition & 0 deletions example/lib/lib-build/src/main/cpp/TestLib.idl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ interface TestMethodClass {
float getFloatValue02();
float getBoolValue01();
[Const, Value] IDLStringView getStrValue01();
[Const, Ref] IDLString getRefStrValue01();
[Const] TestObjectClass getPointerObject01();
TestObjectClass getPointerObject02();
[Const, Ref] TestObjectClass getRefObject01();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class TestMethodClass {
float getFloatValue02() { return floatValue02; };
bool getBoolValue01() { return boolValue01; };
const char* getStrValue01() { return strValue01.c_str(); };
const string& getRefStrValue01() { return strValue01; };
const TestObjectClass* getPointerObject01() { return pointerObject01; };
TestObjectClass* getPointerObject02() { return pointerObject02; };
const TestObjectClass& getRefObject01() { return refObject01; };
Expand Down

0 comments on commit 2c12c69

Please sign in to comment.