@@ -606,3 +606,67 @@ TEST(VariableReflectionTest, GetEnumConstantDatamembers) {
606606 Cpp::GetEnumConstantDatamembers (MyEnumClass, datamembers2, false );
607607 EXPECT_EQ (datamembers2.size (), 6 );
608608}
609+
610+ TEST (VariableReflectionTest, Is_Get_Pointer) {
611+ Cpp::CreateInterpreter ();
612+ std::vector<Decl*> Decls;
613+ std::string code = R"(
614+ class A {};
615+ int a;
616+ int *b;
617+ double c;
618+ double *d;
619+ A e;
620+ A *f;
621+ )" ;
622+
623+ GetAllTopLevelDecls (code, Decls);
624+
625+ EXPECT_FALSE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[1 ])));
626+ EXPECT_TRUE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[2 ])));
627+ EXPECT_FALSE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[3 ])));
628+ EXPECT_TRUE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[4 ])));
629+ EXPECT_FALSE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[5 ])));
630+ EXPECT_TRUE (Cpp::IsPointerType (Cpp::GetVariableType (Decls[6 ])));
631+
632+ EXPECT_EQ (Cpp::GetPointeeType (Cpp::GetVariableType (Decls[2 ])),
633+ Cpp::GetVariableType (Decls[1 ]));
634+ EXPECT_EQ (Cpp::GetPointeeType (Cpp::GetVariableType (Decls[4 ])),
635+ Cpp::GetVariableType (Decls[3 ]));
636+ EXPECT_EQ (Cpp::GetPointeeType (Cpp::GetVariableType (Decls[6 ])),
637+ Cpp::GetVariableType (Decls[5 ]));
638+
639+ EXPECT_FALSE (Cpp::GetPointeeType (Cpp::GetVariableType (Decls[5 ])));
640+ }
641+
642+ TEST (VariableReflectionTest, Is_Get_Reference) {
643+ Cpp::CreateInterpreter ();
644+ std::vector<Decl*> Decls;
645+ std::string code = R"(
646+ class A {};
647+ int a;
648+ int &b = a;
649+ double c;
650+ double &d = c;
651+ A e;
652+ A &f = e;
653+ )" ;
654+
655+ GetAllTopLevelDecls (code, Decls);
656+
657+ EXPECT_FALSE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[1 ])));
658+ EXPECT_TRUE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[2 ])));
659+ EXPECT_FALSE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[3 ])));
660+ EXPECT_TRUE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[4 ])));
661+ EXPECT_FALSE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[5 ])));
662+ EXPECT_TRUE (Cpp::IsReferenceType (Cpp::GetVariableType (Decls[6 ])));
663+
664+ EXPECT_EQ (Cpp::GetNonReferenceType (Cpp::GetVariableType (Decls[2 ])),
665+ Cpp::GetVariableType (Decls[1 ]));
666+ EXPECT_EQ (Cpp::GetNonReferenceType (Cpp::GetVariableType (Decls[4 ])),
667+ Cpp::GetVariableType (Decls[3 ]));
668+ EXPECT_EQ (Cpp::GetNonReferenceType (Cpp::GetVariableType (Decls[6 ])),
669+ Cpp::GetVariableType (Decls[5 ]));
670+
671+ EXPECT_FALSE (Cpp::GetNonReferenceType (Cpp::GetVariableType (Decls[5 ])));
672+ }
0 commit comments