Test c++ calling to rust
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index cfe07ab..d27df41 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -79,4 +79,33 @@
}
}
+extern "C" const char *cxx_run_test() noexcept {
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define ASSERT(x) \
+ do { \
+ if (!(x)) { \
+ return "Assertion failed: `" #x "`, " __FILE__ ":" TOSTRING(__LINE__); \
+ } \
+ } while (false)
+
+ ASSERT(r_return_primitive() == 2020);
+ ASSERT(r_return_shared().z == 2020);
+ ASSERT(r_return_ref(Shared{2020}) == 2020);
+ ASSERT(std::string(r_return_str(Shared{2020})) == "2020");
+ ASSERT(std::string(r_return_rust_string()) == "2020");
+
+ r_take_primitive(2020);
+ r_take_shared(Shared{2020});
+ r_take_unique_ptr(std::unique_ptr<C>(new C{2020}));
+ r_take_ref_c(C{2020});
+ r_take_str(cxxbridge::RustStr("2020"));
+ // TODO r_take_rust_string(cxxbridge::RustString("2020"));
+ r_take_unique_ptr_string(
+ std::unique_ptr<std::string>(new std::string("2020")));
+
+ cxx_test_suite_set_correct();
+ return nullptr;
+}
+
} // namespace tests