From 357af64d781ff41903a461e6b6edb92806b85149 Mon Sep 17 00:00:00 2001 From: Nikola Smiljanic Date: Fri, 6 Jun 2014 04:40:35 +0000 Subject: [PATCH] Add first set of tests for FriendDecl source range and location. llvm-svn: 210306 --- clang/unittests/AST/SourceLocationTest.cpp | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp index 6e9444294455..dc00b86fc2c4 100644 --- a/clang/unittests/AST/SourceLocationTest.cpp +++ b/clang/unittests/AST/SourceLocationTest.cpp @@ -263,6 +263,84 @@ TEST(UnresolvedUsingValueDecl, SourceRange) { unresolvedUsingValueDecl())); } +TEST(FriendDecl, FriendFunctionLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(2, 13); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend void f();\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendFunctionRange) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 15); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend void f();\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendClassLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(2, 8); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend class B;\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendClassRange) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 14); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend class B;\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendTemplateParameterLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(3, 8); + EXPECT_TRUE(Verifier.match("template \n" + "struct A {\n" + "friend T;\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + +TEST(FriendDecl, FriendTemplateParameterRange) { + RangeVerifier Verifier; + Verifier.expectRange(3, 1, 3, 8); + EXPECT_TRUE(Verifier.match("template \n" + "struct A {\n" + "friend T;\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + +TEST(FriendDecl, FriendDecltypeLocation) { + LocationVerifier 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, FriendDecltypeRange) { + RangeVerifier Verifier; + Verifier.expectRange(4, 1, 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, InstantiationSourceRange) { RangeVerifier Verifier; Verifier.expectRange(4, 3, 4, 35);