Exemple #1
0
TEST(FriendDecl, FriendInlineFunctionLocation) {
  LocationVerifier<FriendDecl> Verifier;
  Verifier.expectLocation(2, 19);
  EXPECT_TRUE(Verifier.match("struct A {\n"
                             "int inline friend f() { return 0; }"
                             "};\n",
                             friendDecl()));
}
Exemple #2
0
TEST(FriendDecl, FriendElaboratedTypeLocation) {
  LocationVerifier<FriendDecl> Verifier;
  Verifier.expectLocation(2, 8);
  EXPECT_TRUE(Verifier.match("struct A {\n"
                             "friend class B;\n"
                             "};\n",
                             friendDecl()));
}
Exemple #3
0
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")))))));
}
Exemple #4
0
TEST(FriendDecl, FriendNonMemberFunctionDefinitionLocation) {
  LocationVerifier<FriendDecl> Verifier;
  Verifier.expectLocation(2, 12);
  EXPECT_TRUE(Verifier.match("struct A {\n"
                             "friend int f() { return 0; }\n"
                             "};\n",
                             friendDecl()));
}
Exemple #5
0
TEST(FriendDecl, FriendNonMemberFunctionLocation) {
  LocationVerifier<FriendDecl> Verifier;
  Verifier.expectLocation(2, 13);
  EXPECT_TRUE(Verifier.match("struct A {\n"
                             "friend void f();\n"
                             "};\n",
                             friendDecl()));
}
Exemple #6
0
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()));
}
Exemple #7
0
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()));
}
Exemple #8
0
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));
}
Exemple #9
0
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));
}
Exemple #10
0
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));
}
Exemple #11
0
TEST(ParmVarDecl, KNRLocation) {
  LocationVerifier<ParmVarDecl> Verifier;
  Verifier.expectLocation(1, 8);
  EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C));
}
Exemple #12
0
TEST(LocationVerifier, WrongLocation) {
  LocationVerifier<VarDecl> Verifier;
  Verifier.expectLocation(1, 1);
  EXPECT_FALSE(Verifier.match("int i;", varDecl()));
}
Exemple #13
0
TEST(MatchVerifier, WrongType) {
  LocationVerifier<RecordDecl> Verifier;
  Verifier.expectLocation(1, 1);
  EXPECT_FALSE(Verifier.match("int i;", varDecl()));
}
Exemple #14
0
TEST(MatchVerifier, NoMatch) {
  LocationVerifier<VarDecl> Verifier;
  Verifier.expectLocation(1, 1);
  EXPECT_FALSE(Verifier.match("int i;", recordDecl()));
}
Exemple #15
0
TEST(MatchVerifier, ParseError) {
  LocationVerifier<VarDecl> Verifier;
  Verifier.expectLocation(1, 1);
  EXPECT_FALSE(Verifier.match("int i", varDecl()));
}