@@ -83,6 +83,10 @@ TEST_F(CppParserTest, FilesAreInDatabase)
83
83
file = _db->query_value <model::File>(QFile::filename == " namespace.cpp" );
84
84
EXPECT_EQ (file.type , " CPP" );
85
85
EXPECT_EQ (file.parseStatus , model::File::PSFullyParsed);
86
+
87
+ file = _db->query_value <model::File>(QFile::filename == " using.cpp" );
88
+ EXPECT_EQ (file.type , " CPP" );
89
+ EXPECT_EQ (file.parseStatus , model::File::PSFullyParsed);
86
90
});
87
91
}
88
92
@@ -546,7 +550,7 @@ TEST_F(CppParserTest, Fields)
546
550
{
547
551
_transaction ([&, this ] {
548
552
model::CppVariable fieldFunction = _db->query_value <model::CppVariable>(
549
- QCppFunction ::name == " fieldFunction" );
553
+ QCppVariable ::name == " fieldFunction" );
550
554
RCppAstNode astNodes = _db->query <model::CppAstNode>(
551
555
QCppAstNode::entityHash == fieldFunction.entityHash );
552
556
@@ -686,11 +690,11 @@ TEST_F(CppParserTest, Namespace)
686
690
model::CppNamespace myNamespace1 = _db->query_value <model::CppNamespace>(
687
691
QCppNamespace::name == " MyNamespace1" );
688
692
model::CppAstNode astNode = _db->query_value <model::CppAstNode>(
689
- QCppAstNode::entityHash == myNamespace1.entityHash );
693
+ QCppAstNode::entityHash == myNamespace1.entityHash &&
694
+ QCppAstNode::astType == model::CppAstNode::AstType::Definition);
690
695
691
696
EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Namespace);
692
697
EXPECT_EQ (astNode.location .range .start .line , 1 );
693
- EXPECT_EQ (astNode.astType , model::CppAstNode::AstType::Definition);
694
698
695
699
model::CppNamespace myNamespace2 = _db->query_value <model::CppNamespace>(
696
700
QCppNamespace::name == " MyNamespace2" );
@@ -702,3 +706,66 @@ TEST_F(CppParserTest, Namespace)
702
706
EXPECT_EQ (astNode.astType , model::CppAstNode::AstType::Definition);
703
707
});
704
708
}
709
+
710
+ TEST_F (CppParserTest, Using)
711
+ {
712
+ _transaction ([&, this ] {
713
+ model::CppNamespace nested = _db->query_value <model::CppNamespace>(
714
+ QCppNamespace::name == " Nested" );
715
+
716
+ model::CppAstNode astNode = _db->query_value <model::CppAstNode>(
717
+ QCppAstNode::entityHash == nested.entityHash &&
718
+ QCppAstNode::astType == model::CppAstNode::AstType::Usage);
719
+
720
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Namespace);
721
+ EXPECT_EQ (astNode.location .range .start .line , 20 );
722
+
723
+
724
+ model::CppRecord cClass = _db->query_value <model::CppRecord>(
725
+ QCppRecord::qualifiedName == " Nested::MyNamespace::C" );
726
+
727
+ astNode = _db->query_value <model::CppAstNode>(
728
+ QCppAstNode::entityHash == cClass.entityHash &&
729
+ QCppAstNode::astType == model::CppAstNode::AstType::UsingLoc);
730
+
731
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Other);
732
+ EXPECT_EQ (astNode.location .range .start .line , 26 );
733
+
734
+
735
+ model::CppVariable var1 = _db->query_value <model::CppVariable>(
736
+ QCppVariable::name == " VAR1" );
737
+
738
+ astNode = _db->query_value <model::CppAstNode>(
739
+ QCppAstNode::entityHash == var1.entityHash &&
740
+ QCppAstNode::astType == model::CppAstNode::AstType::UsingLoc);
741
+
742
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Other);
743
+ EXPECT_EQ (astNode.location .range .start .line , 27 );
744
+
745
+ astNode = _db->query_value <model::CppAstNode>(
746
+ QCppAstNode::entityHash == var1.entityHash &&
747
+ QCppAstNode::astType == model::CppAstNode::AstType::Read);
748
+
749
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Variable);
750
+ EXPECT_EQ (astNode.location .range .start .line , 31 );
751
+
752
+ RCppFunction functions_with_g = _db->query <model::CppFunction>(
753
+ QCppFunction::qualifiedName == " Nested::MyNamespace::g" );
754
+
755
+ for (const model::CppFunction& func : functions_with_g) {
756
+ astNode = _db->query_value <model::CppAstNode>(
757
+ QCppAstNode::entityHash == func.entityHash &&
758
+ QCppAstNode::astType == model::CppAstNode::AstType::UsingLoc);
759
+
760
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Other);
761
+ EXPECT_EQ (astNode.location .range .start .line , 22 );
762
+
763
+
764
+ astNode = _db->query_value <model::CppAstNode>(
765
+ QCppAstNode::entityHash == func.entityHash &&
766
+ QCppAstNode::astType == model::CppAstNode::AstType::Usage);
767
+
768
+ EXPECT_EQ (astNode.symbolType , model::CppAstNode::SymbolType::Function);
769
+ }
770
+ });
771
+ }
0 commit comments