@@ -105,8 +105,8 @@ TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) {
105105 F^oo(const Foo&) = delete;
106106 };)cpp" );
107107
108- // Not available within templated classes, as it is hard to spell class name
109- // out-of-line in such cases.
108+ // Not available within templated classes with unnamed parameters , as it is
109+ // hard to spell class name out-of-line in such cases.
110110 EXPECT_UNAVAILABLE (R"cpp(
111111 template <typename> struct Foo { void fo^o(){} };
112112 )cpp" );
@@ -154,7 +154,6 @@ TEST_F(DefineOutlineTest, FailsWithoutSource) {
154154}
155155
156156TEST_F (DefineOutlineTest, ApplyTest) {
157- llvm::StringMap<std::string> EditedFiles;
158157 ExtraFiles[" Test.cpp" ] = " " ;
159158 FileName = " Test.hpp" ;
160159
@@ -229,17 +228,18 @@ TEST_F(DefineOutlineTest, ApplyTest) {
229228 // Ctor initializer with attribute.
230229 {
231230 R"cpp(
232- class Foo {
233- F^oo(int z) __attribute__((weak)) : bar(2){}
231+ template <typename T> class Foo {
232+ F^oo(T z) __attribute__((weak)) : bar(2){}
234233 int bar;
235234 };)cpp" ,
236235 R"cpp(
237- class Foo {
238- Foo(int z) __attribute__((weak)) ;
236+ template <typename T> class Foo {
237+ Foo(T z) __attribute__((weak)) ;
239238 int bar;
240- };)cpp" ,
241- " Foo::Foo(int z) __attribute__((weak)) : bar(2){}\n " ,
242- },
239+ };template <typename T>
240+ Foo<T>::Foo(T z) __attribute__((weak)) : bar(2){}
241+ )cpp" ,
242+ " " },
243243 // Virt specifiers.
244244 {
245245 R"cpp(
@@ -369,7 +369,31 @@ TEST_F(DefineOutlineTest, ApplyTest) {
369369 };)cpp" ,
370370 " void A::foo(int) {}\n " ,
371371 },
372- // Destrctors
372+ // Complex class template
373+ {
374+ R"cpp(
375+ template <typename T, typename ...U> struct O1 {
376+ template <class V, int A> struct O2 {
377+ enum E { E1, E2 };
378+ struct I {
379+ E f^oo(T, U..., V, E) { return E1; }
380+ };
381+ };
382+ };)cpp" ,
383+ R"cpp(
384+ template <typename T, typename ...U> struct O1 {
385+ template <class V, int A> struct O2 {
386+ enum E { E1, E2 };
387+ struct I {
388+ E foo(T, U..., V, E) ;
389+ };
390+ };
391+ };template <typename T, typename ...U>
392+ template <class V, int A>
393+ typename O1<T, U...>::template O2<V, A>::E O1<T, U...>::template O2<V, A>::I::foo(T, U..., V, E) { return E1; }
394+ )cpp" ,
395+ " " },
396+ // Destructors
373397 {
374398 " class A { ~A^(){} };" ,
375399 " class A { ~A(); };" ,
@@ -378,9 +402,14 @@ TEST_F(DefineOutlineTest, ApplyTest) {
378402 };
379403 for (const auto &Case : Cases) {
380404 SCOPED_TRACE (Case.Test );
405+ llvm::StringMap<std::string> EditedFiles;
381406 EXPECT_EQ (apply (Case.Test , &EditedFiles), Case.ExpectedHeader );
382- EXPECT_THAT (EditedFiles, testing::ElementsAre (FileWithContents (
383- testPath (" Test.cpp" ), Case.ExpectedSource )));
407+ if (Case.ExpectedSource .empty ()) {
408+ EXPECT_TRUE (EditedFiles.empty ());
409+ } else {
410+ EXPECT_THAT (EditedFiles, testing::ElementsAre (FileWithContents (
411+ testPath (" Test.cpp" ), Case.ExpectedSource )));
412+ }
384413 }
385414}
386415
0 commit comments