@@ -234,6 +234,49 @@ TEST(FunctionReflectionTest, GetFunctionsUsingName) {
234
234
EXPECT_EQ (get_number_of_funcs_using_name (Decls[2 ], " " ), 0 );
235
235
}
236
236
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
+
237
280
TEST (FunctionReflectionTest, GetFunctionReturnType) {
238
281
std::vector<Decl*> Decls, SubDecls, TemplateSubDecls;
239
282
std::string code = R"(
0 commit comments