[PATCH] Formatting 'enum class' and 'enum struct' as enumerations
Joe Hermaszewski
expipiplus1 at gmail.com
Tue May 28 06:18:02 PDT 2013
duplicating the FormatsEnum tests for enum structs and classes
Hi djasper,
http://llvm-reviews.chandlerc.com/D876
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D876?vs=2154&id=2155#toc
Files:
unittests/Format/FormatTest.cpp
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1332,6 +1332,44 @@
verifyFormat("enum X f() {\n a();\n return 42;\n}");
}
+TEST_F(FormatTest, FormatsEnumStruct) {
+ verifyFormat("enum struct {\n"
+ " Zero,\n"
+ " One = 1,\n"
+ " Two = One + 1,\n"
+ " Three = (One + Two),\n"
+ " Four = (Zero && (One ^ Two)) | (One << Two),\n"
+ " Five = (One, Two, Three, Four, 5)\n"
+ "};");
+ verifyFormat("enum struct Enum {\n"
+ "};");
+ verifyFormat("enum struct {\n"
+ "};");
+ verifyFormat("enum struct X E {\n} d;");
+ verifyFormat("enum struct __attribute__((...)) E {\n} d;");
+ verifyFormat("enum struct __declspec__((...)) E {\n} d;");
+ verifyFormat("enum struct X f() {\n a();\n return 42;\n}");
+}
+
+TEST_F(FormatTest, FormatsEnumClass) {
+ verifyFormat("enum class {\n"
+ " Zero,\n"
+ " One = 1,\n"
+ " Two = One + 1,\n"
+ " Three = (One + Two),\n"
+ " Four = (Zero && (One ^ Two)) | (One << Two),\n"
+ " Five = (One, Two, Three, Four, 5)\n"
+ "};");
+ verifyFormat("enum class Enum {\n"
+ "};");
+ verifyFormat("enum class {\n"
+ "};");
+ verifyFormat("enum class X E {\n} d;");
+ verifyFormat("enum class __attribute__((...)) E {\n} d;");
+ verifyFormat("enum class __declspec__((...)) E {\n} d;");
+ verifyFormat("enum class X f() {\n a();\n return 42;\n}");
+}
+
TEST_F(FormatTest, FormatsBitfields) {
verifyFormat("struct Bitfields {\n"
" unsigned sClass : 8;\n"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D876.2.patch
Type: text/x-patch
Size: 1815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130528/7745b609/attachment.bin>
More information about the cfe-commits
mailing list