Skip to content

Commit 66f16e6

Browse files
authored
[clang-format][NFC] Add missing config tests for List of Strings (#121451)
Also, simplify the existing test for NamespaceMacros. Like the options tested by the added tests, it's also a list of arbitrary strings and initialized to an empty list. (The other existing tests for list of strings either are initialized to a list of one or more strings or require specific strings.)
1 parent 2bbdce9 commit 66f16e6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {
144144
EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value()); \
145145
EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
146146

147+
#define CHECK_PARSE_LIST(FIELD) \
148+
CHECK_PARSE(#FIELD ": [foo]", FIELD, std::vector<std::string>{"foo"})
149+
147150
#define CHECK_PARSE_NESTED_VALUE(TEXT, STRUCT, FIELD, VALUE) \
148151
EXPECT_NE(VALUE, Style.STRUCT.FIELD) << "Initial value already the same!"; \
149152
EXPECT_EQ(0, parseConfiguration(#STRUCT ":\n " TEXT, &Style).value()); \
@@ -906,11 +909,15 @@ TEST(ConfigParseTest, ParsesConfiguration) {
906909
CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros,
907910
std::vector<std::string>({"QUNUSED", "QT_REQUIRE_VERSION"}));
908911

909-
Style.NamespaceMacros.clear();
910-
CHECK_PARSE("NamespaceMacros: [TESTSUITE]", NamespaceMacros,
911-
std::vector<std::string>{"TESTSUITE"});
912-
CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,
913-
std::vector<std::string>({"TESTSUITE", "SUITE"}));
912+
CHECK_PARSE_LIST(JavaImportGroups);
913+
CHECK_PARSE_LIST(Macros);
914+
CHECK_PARSE_LIST(NamespaceMacros);
915+
CHECK_PARSE_LIST(ObjCPropertyAttributeOrder);
916+
CHECK_PARSE_LIST(TableGenBreakingDAGArgOperators);
917+
CHECK_PARSE_LIST(TemplateNames);
918+
CHECK_PARSE_LIST(TypeNames);
919+
CHECK_PARSE_LIST(TypenameMacros);
920+
CHECK_PARSE_LIST(VariableTemplates);
914921

915922
Style.WhitespaceSensitiveMacros.clear();
916923
CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",

0 commit comments

Comments
 (0)