clag-format: format Microsoft::VisualStudio::CppUnitTestFramework Attributes

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

clag-format: format Microsoft::VisualStudio::CppUnitTestFramework Attributes

Robinson, Paul via cfe-dev
Hello,

Is there a way to get clang-format to format Microsoft::VisualStudio::CppUnitTestFramework TEST_CLASS.., TEST_METHOD... Attributes "nicely"?

Currently clang-format (style llvm) "messes" up the following sections:

BEGIN_TEST_CLASS_ATTRIBUTE()
        TEST_CLASS_ATTRIBUTE
and
BEGIN_TEST_METHOD_ATTRIBUTE(tf_clang1)
        TEST_METHOD_ATTRIBUTE(L"ID", L"ID1")


What I want(and used for clang-format style=llvm)  is:

#include "stdafx.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

/**
 \class tc_clang
 Bla Bla Bla
 */
TEST_CLASS(tc_clang) {
    BEGIN_TEST_CLASS_ATTRIBUTE()
        TEST_CLASS_ATTRIBUTE(L"level", L"l1")
        TEST_CLASS_ATTRIBUTE(L"module", L"m1")
    END_TEST_CLASS_ATTRIBUTE()

public:

    /**
     \fn tf_clang1()
     Bla Bla Bla
     */

    BEGIN_TEST_METHOD_ATTRIBUTE(tf_clang1)
        TEST_METHOD_ATTRIBUTE(L"ID", L"ID1")
        TEST_METHOD_ATTRIBUTE(L"Name", L"Name1")
    END_TEST_METHOD_ATTRIBUTE()

    TEST_METHOD(tf_clang1) {

        int n = 1;
        n++;
    }

    /**
     \fn tf_clang2()
    bla bla bla
     */

    BEGIN_TEST_METHOD_ATTRIBUTE (tf_clang2)
        TEST_METHOD_ATTRIBUTE(L"ID", L"ID2")
        TEST_METHOD_ATTRIBUTE(L"Name", L"Name2")
    END_TEST_METHOD_ATTRIBUTE()
    TEST_METHOD(tf_clang2) {
        {
            int i = 1;
            i++;
        }
    }
};





What I get is

#include "stdafx.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

/**
 \class tc_clang
 Bla Bla Bla
 */
TEST_CLASS(tc_clang){
  BEGIN_TEST_CLASS_ATTRIBUTE() TEST_CLASS_ATTRIBUTE(L"level", L"l1")
      TEST_CLASS_ATTRIBUTE(L"module", L"m1") END_TEST_CLASS_ATTRIBUTE()

          public :

              /**
               \fn tf_clang1()
               Bla Bla Bla
               */

              BEGIN_TEST_METHOD_ATTRIBUTE(tf_clang1)
                  TEST_METHOD_ATTRIBUTE(L"ID", L"ID1")
                      TEST_METHOD_ATTRIBUTE(L"Name", L"Name1")
                          END_TEST_METHOD_ATTRIBUTE()

                              TEST_METHOD(tf_clang1){

                                  int n = 1;
n++;
}

/**
 \fn tf_clang2()
bla bla bla
 */

BEGIN_TEST_METHOD_ATTRIBUTE(tf_clang2)
TEST_METHOD_ATTRIBUTE(L"ID", L"ID2")
TEST_METHOD_ATTRIBUTE(L"Name", L"Name2")
END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(tf_clang2) {
  {
    int i = 1;
    i++;
  }
}
}
;


Michael Boelling

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev