Skip to content

Commit

Permalink
Update unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj0 committed Apr 5, 2024
1 parent 7fb0ae1 commit ca6e56c
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions unittests/CppInterOp/FunctionReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
int f () { return 0; }
};
void f1() {}
double f2() { return 0.2; }
Switch f3() { return ON; }
N::C f4() { return N::C(); }
N::C *f5() { return new N::C(); }
const N::C f6() { return N::C(); }
volatile N::C f7() { return N::C(); }
const volatile N::C f8() { return N::C(); }
int n;
class MyTemplatedMethodClass {
template<class A>
char get_string(A) {
Expand All @@ -252,38 +262,41 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
return sizeof(A) + i;
}
};
void f1() {}
double f2() { return 0.2; }
Switch f3() { return ON; }
N::C f4() { return N::C(); }
N::C *f5() { return new N::C(); }
const N::C f6() { return N::C(); }
volatile N::C f7() { return N::C(); }
const volatile N::C f8() { return N::C(); }
int n;
)";

GetAllTopLevelDecls(code, Decls, true);
GetAllSubDecls(Decls[2], SubDecls);
GetAllSubDecls(Decls[3], TemplateSubDecls);
GetAllSubDecls(Decls[12], TemplateSubDecls);

// #include <string>

EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[4])), "void");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[5])), "double");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[6])), "Switch");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[7])), "N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[8])), "N::C *");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[9])), "const N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[10])), "volatile N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[11])), "const volatile N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[12])), "NULL TYPE");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[3])), "void");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[4])),
"double");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[5])),
"Switch");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[6])), "N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[7])),
"N::C *");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[8])),
"const N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[9])),
"volatile N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[10])),
"const volatile N::C");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(Decls[11])),
"NULL TYPE");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(SubDecls[1])), "void");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(SubDecls[2])), "int");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[1])), "char");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[2])), "void");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[3])), "long");
EXPECT_EQ(
Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[1])),
"char");
EXPECT_EQ(
Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[2])),
"void");
EXPECT_EQ(
Cpp::GetTypeAsString(Cpp::GetFunctionReturnType(TemplateSubDecls[3])),
"long");
}

TEST(FunctionReflectionTest, GetFunctionNumArgs) {
Expand Down

0 comments on commit ca6e56c

Please sign in to comment.