Skip to content

Commit 0f1c0c0

Browse files
committed
Improve the test coverage of the C API -- Take 6
1 parent 11fea7d commit 0f1c0c0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ TEST(FunctionReflectionTest, GetClassMethods) {
107107
std::vector<Cpp::TCppFunction_t> methods5;
108108
Cpp::GetClassMethods(nullptr, methods5);
109109
EXPECT_EQ(methods5.size(), 0);
110+
111+
// C API
112+
auto* I = clang_createInterpreterFromRawPtr(Cpp::GetInterpreter());
113+
auto C_API_SHIM = [&](Cpp::TCppFunction_t method) {
114+
auto Str = clang_getFunctionSignature(
115+
make_scope(static_cast<clang::Decl*>(method), I));
116+
auto Res = std::string(get_c_string(Str));
117+
dispose_string(Str);
118+
return Res;
119+
};
120+
EXPECT_EQ(C_API_SHIM(methods0[0]), "int A::f1(int a, int b)");
121+
// Clean up resources
122+
clang_Interpreter_takeInterpreterAsPtr(I);
123+
clang_Interpreter_dispose(I);
110124
}
111125

112126
TEST(FunctionReflectionTest, ConstructorInGetClassMethods) {

0 commit comments

Comments
 (0)