-
Notifications
You must be signed in to change notification settings - Fork 36
Tests for static GetClassDecls #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -234,6 +234,49 @@ TEST(FunctionReflectionTest, GetFunctionsUsingName) { | |||||
| EXPECT_EQ(get_number_of_funcs_using_name(Decls[2], ""), 0); | ||||||
| } | ||||||
|
|
||||||
| TEST(FunctionReflectionTest, GetClassDecls) { | ||||||
| std::vector<Decl*> Decls, SubDecls; | ||||||
| std::string code = R"( | ||||||
| class MyTemplatedMethodClass { | ||||||
| template<class A, class B> | ||||||
| long get_size(A, B, int i = 0) {} | ||||||
|
|
||||||
| template<class A = int, class B = char> | ||||||
| long get_float_size(int i, A a = A(), B b = B()) {} | ||||||
|
|
||||||
| template<class A> | ||||||
| void get_char_size(long k, A, char ch = 'a', double l = 0.0) {} | ||||||
|
|
||||||
| void f1() {} | ||||||
| void f2(int i, double d, long l, char ch) {} | ||||||
|
|
||||||
| template<class A> | ||||||
| void get_size(long k, A, char ch = 'a', double l = 0.0) {} | ||||||
|
|
||||||
| void f3(int i, double d, long l = 0, char ch = 'a') {} | ||||||
| void f4(int i = 0, double d = 0.0, long l = 0, char ch = 'a') {} | ||||||
| }; | ||||||
| )"; | ||||||
|
|
||||||
| GetAllTopLevelDecls(code, Decls); | ||||||
| GetAllSubDecls(Decls[0], SubDecls); | ||||||
|
|
||||||
| std::vector<Cpp::TCppFunction_t> methods; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'methods' is not initialized [cppcoreguidelines-init-variables]
Suggested change
|
||||||
| std::vector<Cpp::TCppFunction_t> template_methods; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'template_methods' is not initialized [cppcoreguidelines-init-variables]
Suggested change
|
||||||
|
|
||||||
| Cpp::GetClassMethods(Decls[0], methods); | ||||||
| Cpp::GetFunctionTemplatedDecls(Decls[0], template_methods); | ||||||
|
|
||||||
| EXPECT_EQ(Cpp::GetName(template_methods[0]), Cpp::GetName(SubDecls[1])); | ||||||
| EXPECT_EQ(Cpp::GetName(template_methods[1]), Cpp::GetName(SubDecls[2])); | ||||||
| EXPECT_EQ(Cpp::GetName(template_methods[2]), Cpp::GetName(SubDecls[3])); | ||||||
| EXPECT_EQ(Cpp::GetName(methods[0]) , Cpp::GetName(SubDecls[4])); | ||||||
| EXPECT_EQ(Cpp::GetName(methods[1]) , Cpp::GetName(SubDecls[5])); | ||||||
| EXPECT_EQ(Cpp::GetName(template_methods[3]), Cpp::GetName(SubDecls[6])); | ||||||
| EXPECT_EQ(Cpp::GetName(methods[2]) , Cpp::GetName(SubDecls[7])); | ||||||
| EXPECT_EQ(Cpp::GetName(methods[3]) , Cpp::GetName(SubDecls[8])); | ||||||
| } | ||||||
|
|
||||||
| TEST(FunctionReflectionTest, GetFunctionReturnType) { | ||||||
| std::vector<Decl*> Decls, SubDecls, TemplateSubDecls; | ||||||
| std::string code = R"( | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'Decls' is not initialized [cppcoreguidelines-init-variables]