diff options
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 12 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 13 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 2 |
3 files changed, 17 insertions, 10 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 93e3f7a5936..5de15e3c2b9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -17,6 +17,10 @@ namespace clang { namespace format { +FormatStyle getGoogleStyle() { + return getGoogleStyle(FormatStyle::LK_Cpp); +} + class FormatTest : public ::testing::Test { protected: std::string format(llvm::StringRef Code, unsigned Offset, unsigned Length, @@ -5783,7 +5787,7 @@ TEST_F(FormatTest, FormatObjCMethodExpr) { " backing:NSBackingStoreBuffered\n" " defer:NO]);\n" "}", - getChromiumStyle()); + getChromiumStyle(FormatStyle::LK_Cpp)); verifyFormat("[contentsContainer replaceSubview:[subviews objectAtIndex:0]\n" " with:contentsNativeView];"); @@ -7250,14 +7254,14 @@ TEST_F(FormatTest, GetsPredefinedStyleByName) { EXPECT_TRUE(getPredefinedStyle("gOOgle", FormatStyle::LK_Cpp, &Styles[2])); EXPECT_ALL_STYLES_EQUAL(Styles); - Styles[0] = getGoogleJSStyle(); + Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript); EXPECT_TRUE( getPredefinedStyle("Google", FormatStyle::LK_JavaScript, &Styles[1])); EXPECT_TRUE( getPredefinedStyle("gOOgle", FormatStyle::LK_JavaScript, &Styles[2])); EXPECT_ALL_STYLES_EQUAL(Styles); - Styles[0] = getChromiumStyle(); + Styles[0] = getChromiumStyle(FormatStyle::LK_Cpp); EXPECT_TRUE(getPredefinedStyle("Chromium", FormatStyle::LK_Cpp, &Styles[1])); EXPECT_TRUE(getPredefinedStyle("cHRoMiUM", FormatStyle::LK_Cpp, &Styles[2])); EXPECT_ALL_STYLES_EQUAL(Styles); @@ -7290,7 +7294,7 @@ TEST_F(FormatTest, GetsCorrectBasedOnStyle) { EXPECT_ALL_STYLES_EQUAL(Styles); Styles.resize(5); - Styles[0] = getGoogleJSStyle(); + Styles[0] = getGoogleStyle(FormatStyle::LK_JavaScript); Styles[1] = getLLVMStyle(); Styles[1].Language = FormatStyle::LK_JavaScript; EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value()); diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 8a9ac9e20b8..c0215e7d142 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -31,19 +31,19 @@ protected: return Result; } - static std::string format(llvm::StringRef Code, - const FormatStyle &Style = getGoogleJSStyle()) { + static std::string format(llvm::StringRef Code, const FormatStyle &Style) { return format(Code, 0, Code.size(), Style); } static FormatStyle getGoogleJSStyleWithColumns(unsigned ColumnLimit) { - FormatStyle Style = getGoogleJSStyle(); + FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); Style.ColumnLimit = ColumnLimit; return Style; } - static void verifyFormat(llvm::StringRef Code, - const FormatStyle &Style = getGoogleJSStyle()) { + static void verifyFormat( + llvm::StringRef Code, + const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) { EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); } }; @@ -82,6 +82,9 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) { TEST_F(FormatTestJS, SpacesInContainerLiterals) { verifyFormat("var arr = [1, 2, 3];"); verifyFormat("var obj = {a: 1, b: 2, c: 3};"); + + verifyFormat("var obj = {a: 1, b: 2, c: 3};", + getChromiumStyle(FormatStyle::LK_JavaScript)); } TEST_F(FormatTestJS, SingleQuoteStrings) { diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 276139623e3..0a4416ec268 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -32,7 +32,7 @@ protected: } static std::string format(llvm::StringRef Code) { - FormatStyle Style = getGoogleProtoStyle(); + FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto); Style.ColumnLimit = 60; // To make writing tests easier. return format(Code, 0, Code.size(), Style); } |