TEST(FriendDecl, FriendTemplateClassLocation) { LocationVerifier<FriendDecl> Verifier; Verifier.expectLocation(3, 14); EXPECT_TRUE(Verifier.match("struct A {\n" "template <typename T>\n" "friend class B;\n" "};\n", friendDecl())); }
TEST(FriendDecl, FriendTemplateFunctionLocation) { LocationVerifier<FriendDecl> Verifier; Verifier.expectLocation(3, 13); EXPECT_TRUE(Verifier.match("struct A {\n" "template <typename T>\n" "friend void f();\n" "};\n", friendDecl())); }
TEST(FriendDecl, FriendTemplateParameterLocation) { LocationVerifier<FriendDecl> Verifier; Verifier.expectLocation(3, 8); EXPECT_TRUE(Verifier.match("template <typename T>\n" "struct A {\n" "friend T;\n" "};\n", friendDecl(), Lang_CXX11)); }
TEST(FriendDecl, FriendSimpleTypeLocation) { LocationVerifier<FriendDecl> Verifier; Verifier.expectLocation(3, 8); EXPECT_TRUE(Verifier.match("class B;\n" "struct A {\n" "friend B;\n" "};\n", friendDecl(), Lang_CXX11)); }
TEST(FriendDecl, FriendDecltypeLocation) { LocationVerifier<FriendDecl> Verifier; Verifier.expectLocation(4, 8); EXPECT_TRUE(Verifier.match("struct A;\n" "A foo();\n" "struct A {\n" "friend decltype(foo());\n" "};\n", friendDecl(), Lang_CXX11)); }
TEST(FriendDecl, FriendConstructorDestructorLocation) { const std::string Code = "struct B {\n" "B();\n" "~B();\n" "};\n" "struct A {\n" "friend B::B(), B::~B();\n" "};\n"; LocationVerifier<FriendDecl> ConstructorVerifier; ConstructorVerifier.expectLocation(6, 11); EXPECT_TRUE(ConstructorVerifier.match( Code, friendDecl(has(constructorDecl(ofClass(hasName("B"))))))); LocationVerifier<FriendDecl> DestructorVerifier; DestructorVerifier.expectLocation(6, 19); EXPECT_TRUE(DestructorVerifier.match( Code, friendDecl(has(destructorDecl(ofClass(hasName("B"))))))); }
TEST(ParmVarDecl, KNRLocation) { LocationVerifier<ParmVarDecl> Verifier; Verifier.expectLocation(1, 8); EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C)); }
TEST(LocationVerifier, WrongLocation) { LocationVerifier<VarDecl> Verifier; Verifier.expectLocation(1, 1); EXPECT_FALSE(Verifier.match("int i;", varDecl())); }
TEST(MatchVerifier, WrongType) { LocationVerifier<RecordDecl> Verifier; Verifier.expectLocation(1, 1); EXPECT_FALSE(Verifier.match("int i;", varDecl())); }
TEST(MatchVerifier, NoMatch) { LocationVerifier<VarDecl> Verifier; Verifier.expectLocation(1, 1); EXPECT_FALSE(Verifier.match("int i;", recordDecl())); }
TEST(MatchVerifier, ParseError) { LocationVerifier<VarDecl> Verifier; Verifier.expectLocation(1, 1); EXPECT_FALSE(Verifier.match("int i", varDecl())); }