@@ -296,19 +296,50 @@ TEST(FunctionReflectionTest, GetClassDecls) {
296
296
GetAllSubDecls (Decls[0 ], SubDecls);
297
297
298
298
std::vector<Cpp::TCppFunction_t> methods;
299
- std::vector<Cpp::TCppFunction_t> template_methods;
300
-
301
299
Cpp::GetClassMethods (Decls[0 ], methods);
300
+
301
+ EXPECT_EQ (methods.size (), 10 ); // includes structors and operators
302
+ EXPECT_EQ (Cpp::GetName (methods[0 ]), Cpp::GetName (SubDecls[4 ]));
303
+ EXPECT_EQ (Cpp::GetName (methods[1 ]), Cpp::GetName (SubDecls[5 ]));
304
+ EXPECT_EQ (Cpp::GetName (methods[2 ]), Cpp::GetName (SubDecls[7 ]));
305
+ EXPECT_EQ (Cpp::GetName (methods[3 ]), Cpp::GetName (SubDecls[8 ]));
306
+ }
307
+
308
+ TEST (FunctionReflectionTest, GetFunctionTemplatedDecls) {
309
+ std::vector<Decl*> Decls, SubDecls;
310
+ std::string code = R"(
311
+ class MyTemplatedMethodClass {
312
+ template<class A, class B>
313
+ long get_size(A, B, int i = 0) {}
314
+
315
+ template<class A = int, class B = char>
316
+ long get_float_size(int i, A a = A(), B b = B()) {}
317
+
318
+ template<class A>
319
+ void get_char_size(long k, A, char ch = 'a', double l = 0.0) {}
320
+
321
+ void f1() {}
322
+ void f2(int i, double d, long l, char ch) {}
323
+
324
+ template<class A>
325
+ void get_size(long k, A, char ch = 'a', double l = 0.0) {}
326
+
327
+ void f3(int i, double d, long l = 0, char ch = 'a') {}
328
+ void f4(int i = 0, double d = 0.0, long l = 0, char ch = 'a') {}
329
+ };
330
+ )" ;
331
+
332
+ GetAllTopLevelDecls (code, Decls);
333
+ GetAllSubDecls (Decls[0 ], SubDecls);
334
+
335
+ std::vector<Cpp::TCppFunction_t> template_methods;
302
336
Cpp::GetFunctionTemplatedDecls (Decls[0 ], template_methods);
303
337
338
+ EXPECT_EQ (template_methods.size (), 4 );
304
339
EXPECT_EQ (Cpp::GetName (template_methods[0 ]), Cpp::GetName (SubDecls[1 ]));
305
340
EXPECT_EQ (Cpp::GetName (template_methods[1 ]), Cpp::GetName (SubDecls[2 ]));
306
341
EXPECT_EQ (Cpp::GetName (template_methods[2 ]), Cpp::GetName (SubDecls[3 ]));
307
- EXPECT_EQ (Cpp::GetName (methods[0 ]) , Cpp::GetName (SubDecls[4 ]));
308
- EXPECT_EQ (Cpp::GetName (methods[1 ]) , Cpp::GetName (SubDecls[5 ]));
309
342
EXPECT_EQ (Cpp::GetName (template_methods[3 ]), Cpp::GetName (SubDecls[6 ]));
310
- EXPECT_EQ (Cpp::GetName (methods[2 ]) , Cpp::GetName (SubDecls[7 ]));
311
- EXPECT_EQ (Cpp::GetName (methods[3 ]) , Cpp::GetName (SubDecls[8 ]));
312
343
}
313
344
314
345
TEST (FunctionReflectionTest, GetFunctionReturnType) {
0 commit comments