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