diff options
| author | Ben Hamilton <benhamilton@google.com> | 2018-02-27 15:56:40 +0000 |
|---|---|---|
| committer | Ben Hamilton <benhamilton@google.com> | 2018-02-27 15:56:40 +0000 |
| commit | 6e066350d8dcfac70e8a038e9ea580dacb56d08d (patch) | |
| tree | 0013dd76f4e78b81968f924f04d31052bdbd6ae1 /clang/unittests/Format/FormatTest.cpp | |
| parent | 497fd98af2fff16b5b885f1bdac3b9b039f5080f (diff) | |
| download | bcm5719-llvm-6e066350d8dcfac70e8a038e9ea580dacb56d08d.tar.gz bcm5719-llvm-6e066350d8dcfac70e8a038e9ea580dacb56d08d.zip | |
[clang-format] Tidy up new API guessLanguage()
Summary:
This fixes a few issues djasper@ brought up in his review of D43522.
Test Plan:
make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D43598
llvm-svn: 326205
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 082f6e4864d..1cda9827e19 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -11959,34 +11959,16 @@ TEST_F(FormatTest, StructuredBindings) { verifyFormat("auto const &[ a, b ] = f();", Spaces); } -struct GuessLanguageTestCase { - const char *const FileName; - const char *const Code; - const FormatStyle::LanguageKind ExpectedResult; -}; - -class GuessLanguageTest - : public FormatTest, - public ::testing::WithParamInterface<GuessLanguageTestCase> {}; - -TEST_P(GuessLanguageTest, FileAndCode) { - auto TestCase = GetParam(); - EXPECT_EQ(TestCase.ExpectedResult, - guessLanguage(TestCase.FileName, TestCase.Code)); +TEST_F(FormatTest, FileAndCode) { + EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.cc", "")); + EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.m", "")); + EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.mm", "")); + EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "")); + EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface Foo\n@end\n")); + EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", "")); + EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n")); } -static const GuessLanguageTestCase TestCases[] = { - {"foo.cc", "", FormatStyle::LK_Cpp}, - {"foo.m", "", FormatStyle::LK_ObjC}, - {"foo.mm", "", FormatStyle::LK_ObjC}, - {"foo.h", "", FormatStyle::LK_Cpp}, - {"foo.h", "@interface Foo\n@end\n", FormatStyle::LK_ObjC}, - {"foo", "", FormatStyle::LK_Cpp}, - {"foo", "@interface Foo\n@end\n", FormatStyle::LK_ObjC}, -}; -INSTANTIATE_TEST_CASE_P(ValidLanguages, GuessLanguageTest, - ::testing::ValuesIn(TestCases)); - } // end namespace } // end namespace format } // end namespace clang |

