@@ -228,7 +228,7 @@ TEST(FunctionReflectionTest, GetFunctionsUsingName) {
228
228
}
229
229
230
230
TEST (FunctionReflectionTest, GetFunctionReturnType) {
231
- std::vector<Decl*> Decls, SubDecls;
231
+ std::vector<Decl*> Decls, SubDecls, TemplateSubDecls ;
232
232
std::string code = R"(
233
233
namespace N { class C {}; }
234
234
enum Switch { OFF, ON };
@@ -238,7 +238,6 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
238
238
int f () { return 0; }
239
239
};
240
240
241
-
242
241
void f1() {}
243
242
double f2() { return 0.2; }
244
243
Switch f3() { return ON; }
@@ -248,22 +247,56 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
248
247
volatile N::C f7() { return N::C(); }
249
248
const volatile N::C f8() { return N::C(); }
250
249
int n;
250
+
251
+ class MyTemplatedMethodClass {
252
+ template<class A>
253
+ char get_string(A) {
254
+ return 'A';
255
+ }
256
+
257
+ template<class A>
258
+ void get_size() {}
259
+
260
+ template<class A>
261
+ long add_size (int i) {
262
+ return sizeof(A) + i;
263
+ }
264
+ };
251
265
)" ;
252
266
253
267
GetAllTopLevelDecls (code, Decls, true );
254
268
GetAllSubDecls (Decls[2 ], SubDecls);
269
+ GetAllSubDecls (Decls[12 ], TemplateSubDecls);
270
+
271
+ // #include <string>
255
272
256
273
EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[3 ])), " void" );
257
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[4 ])), " double" );
258
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[5 ])), " Switch" );
274
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[4 ])),
275
+ " double" );
276
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[5 ])),
277
+ " Switch" );
259
278
EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[6 ])), " N::C" );
260
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[7 ])), " N::C *" );
261
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[8 ])), " const N::C" );
262
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[9 ])), " volatile N::C" );
263
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[10 ])), " const volatile N::C" );
264
- EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[11 ])), " NULL TYPE" );
279
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[7 ])),
280
+ " N::C *" );
281
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[8 ])),
282
+ " const N::C" );
283
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[9 ])),
284
+ " volatile N::C" );
285
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[10 ])),
286
+ " const volatile N::C" );
287
+ EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (Decls[11 ])),
288
+ " NULL TYPE" );
265
289
EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (SubDecls[1 ])), " void" );
266
290
EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (SubDecls[2 ])), " int" );
291
+ EXPECT_EQ (
292
+ Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (TemplateSubDecls[1 ])),
293
+ " char" );
294
+ EXPECT_EQ (
295
+ Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (TemplateSubDecls[2 ])),
296
+ " void" );
297
+ EXPECT_EQ (
298
+ Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (TemplateSubDecls[3 ])),
299
+ " long" );
267
300
}
268
301
269
302
TEST (FunctionReflectionTest, GetFunctionNumArgs) {
0 commit comments