Skip to content

Commit b189990

Browse files
authored
Tests for static GetClassDecls (#230)
1 parent 1e4b64f commit b189990

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,49 @@ TEST(FunctionReflectionTest, GetFunctionsUsingName) {
234234
EXPECT_EQ(get_number_of_funcs_using_name(Decls[2], ""), 0);
235235
}
236236

237+
TEST(FunctionReflectionTest, GetClassDecls) {
238+
std::vector<Decl*> Decls, SubDecls;
239+
std::string code = R"(
240+
class MyTemplatedMethodClass {
241+
template<class A, class B>
242+
long get_size(A, B, int i = 0) {}
243+
244+
template<class A = int, class B = char>
245+
long get_float_size(int i, A a = A(), B b = B()) {}
246+
247+
template<class A>
248+
void get_char_size(long k, A, char ch = 'a', double l = 0.0) {}
249+
250+
void f1() {}
251+
void f2(int i, double d, long l, char ch) {}
252+
253+
template<class A>
254+
void get_size(long k, A, char ch = 'a', double l = 0.0) {}
255+
256+
void f3(int i, double d, long l = 0, char ch = 'a') {}
257+
void f4(int i = 0, double d = 0.0, long l = 0, char ch = 'a') {}
258+
};
259+
)";
260+
261+
GetAllTopLevelDecls(code, Decls);
262+
GetAllSubDecls(Decls[0], SubDecls);
263+
264+
std::vector<Cpp::TCppFunction_t> methods;
265+
std::vector<Cpp::TCppFunction_t> template_methods;
266+
267+
Cpp::GetClassMethods(Decls[0], methods);
268+
Cpp::GetFunctionTemplatedDecls(Decls[0], template_methods);
269+
270+
EXPECT_EQ(Cpp::GetName(template_methods[0]), Cpp::GetName(SubDecls[1]));
271+
EXPECT_EQ(Cpp::GetName(template_methods[1]), Cpp::GetName(SubDecls[2]));
272+
EXPECT_EQ(Cpp::GetName(template_methods[2]), Cpp::GetName(SubDecls[3]));
273+
EXPECT_EQ(Cpp::GetName(methods[0]) , Cpp::GetName(SubDecls[4]));
274+
EXPECT_EQ(Cpp::GetName(methods[1]) , Cpp::GetName(SubDecls[5]));
275+
EXPECT_EQ(Cpp::GetName(template_methods[3]), Cpp::GetName(SubDecls[6]));
276+
EXPECT_EQ(Cpp::GetName(methods[2]) , Cpp::GetName(SubDecls[7]));
277+
EXPECT_EQ(Cpp::GetName(methods[3]) , Cpp::GetName(SubDecls[8]));
278+
}
279+
237280
TEST(FunctionReflectionTest, GetFunctionReturnType) {
238281
std::vector<Decl*> Decls, SubDecls, TemplateSubDecls;
239282
std::string code = R"(

0 commit comments

Comments
 (0)