From: Ilya Biryukov Date: Thu, 13 Dec 2018 17:32:38 +0000 (+0000) Subject: [CodeComplete] Adhere to LLVM naming style in CodeCompletionTest. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24639b1de1c13d33136f0eee96c907752f26e698;p=clang [CodeComplete] Adhere to LLVM naming style in CodeCompletionTest. NFC Also reuses the same var for multiple to reduce the chance of accidentally referecing the previous test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349063 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/Sema/CodeCompleteTest.cpp b/unittests/Sema/CodeCompleteTest.cpp index 421ff11665..ee8c7af663 100644 --- a/unittests/Sema/CodeCompleteTest.cpp +++ b/unittests/Sema/CodeCompleteTest.cpp @@ -183,79 +183,80 @@ TEST(SemaCodeCompleteTest, VisitedNSWithoutQualifier) { TEST(PreferredTypeTest, BinaryExpr) { // Check various operations for arithmetic types. - StringRef code1 = R"cpp( + StringRef Code = R"cpp( void test(int x) { x = ^10; x += ^10; x -= ^10; x *= ^10; x /= ^10; x %= ^10; x + ^10; x - ^10; x * ^10; x / ^10; x % ^10; })cpp"; - EXPECT_THAT(collectPreferredTypes(code1), Each("int")); - StringRef code2 = R"cpp( + EXPECT_THAT(collectPreferredTypes(Code), Each("int")); + + Code = R"cpp( void test(float x) { x = ^10; x += ^10; x -= ^10; x *= ^10; x /= ^10; x %= ^10; x + ^10; x - ^10; x * ^10; x / ^10; x % ^10; })cpp"; - EXPECT_THAT(collectPreferredTypes(code2), Each("float")); + EXPECT_THAT(collectPreferredTypes(Code), Each("float")); // Pointer types. - StringRef code3 = R"cpp( + Code = R"cpp( void test(int *ptr) { ptr - ^ptr; ptr = ^ptr; })cpp"; - EXPECT_THAT(collectPreferredTypes(code3), Each("int *")); + EXPECT_THAT(collectPreferredTypes(Code), Each("int *")); - StringRef code4 = R"cpp( + Code = R"cpp( void test(int *ptr) { ptr + ^10; ptr += ^10; ptr -= ^10; })cpp"; - EXPECT_THAT(collectPreferredTypes(code4), Each("long")); // long is normalized 'ptrdiff_t'. + EXPECT_THAT(collectPreferredTypes(Code), Each("long")); // long is normalized 'ptrdiff_t'. // Comparison operators. - StringRef code5 = R"cpp( + Code = R"cpp( void test(int i) { i <= ^1; i < ^1; i >= ^1; i > ^1; i == ^1; i != ^1; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code5), Each("int")); + EXPECT_THAT(collectPreferredTypes(Code), Each("int")); - StringRef code6 = R"cpp( + Code = R"cpp( void test(int *ptr) { ptr <= ^ptr; ptr < ^ptr; ptr >= ^ptr; ptr > ^ptr; ptr == ^ptr; ptr != ^ptr; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code6), Each("int *")); + EXPECT_THAT(collectPreferredTypes(Code), Each("int *")); // Relational operations. - StringRef code7 = R"cpp( + Code = R"cpp( void test(int i, int *ptr) { i && ^1; i || ^1; ptr && ^1; ptr || ^1; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code7), Each("_Bool")); + EXPECT_THAT(collectPreferredTypes(Code), Each("_Bool")); // Bitwise operations. - StringRef code8 = R"cpp( + Code = R"cpp( void test(long long ll) { ll | ^1; ll & ^1; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code8), Each("long long")); + EXPECT_THAT(collectPreferredTypes(Code), Each("long long")); - StringRef code9 = R"cpp( + Code = R"cpp( enum A {}; void test(A a) { a | ^1; a & ^1; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code9), Each("enum A")); + EXPECT_THAT(collectPreferredTypes(Code), Each("enum A")); - StringRef code10 = R"cpp( + Code = R"cpp( enum class A {}; void test(A a) { // This is technically illegal with the 'enum class' without overloaded @@ -263,10 +264,10 @@ TEST(PreferredTypeTest, BinaryExpr) { a | ^a; a & ^a; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code10), Each("enum A")); + EXPECT_THAT(collectPreferredTypes(Code), Each("enum A")); // Binary shifts. - StringRef code11 = R"cpp( + Code = R"cpp( void test(int i, long long ll) { i << ^1; ll << ^1; i <<= ^1; i <<= ^1; @@ -274,10 +275,10 @@ TEST(PreferredTypeTest, BinaryExpr) { i >>= ^1; i >>= ^1; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code11), Each("int")); + EXPECT_THAT(collectPreferredTypes(Code), Each("int")); // Comma does not provide any useful information. - StringRef code12 = R"cpp( + Code = R"cpp( class Cls {}; void test(int i, int* ptr, Cls x) { (i, ^i); @@ -285,11 +286,11 @@ TEST(PreferredTypeTest, BinaryExpr) { (x, ^x); } )cpp"; - EXPECT_THAT(collectPreferredTypes(code12), Each("NULL TYPE")); + EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE")); // User-defined types do not take operator overloading into account. // However, they provide heuristics for some common cases. - StringRef code13 = R"cpp( + Code = R"cpp( class Cls {}; void test(Cls c) { // we assume arithmetic and comparions ops take the same type. @@ -299,18 +300,18 @@ TEST(PreferredTypeTest, BinaryExpr) { c = ^c; c += ^c; c -= ^c; c *= ^c; c /= ^c; c %= ^c; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code13), Each("class Cls")); + EXPECT_THAT(collectPreferredTypes(Code), Each("class Cls")); - StringRef code14 = R"cpp( + Code = R"cpp( class Cls {}; void test(Cls c) { // we assume relational ops operate on bools. c && ^c; c || ^c; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code14), Each("_Bool")); + EXPECT_THAT(collectPreferredTypes(Code), Each("_Bool")); - StringRef code15 = R"cpp( + Code = R"cpp( class Cls {}; void test(Cls c) { // we make no assumptions about the following operators, since they are @@ -319,7 +320,7 @@ TEST(PreferredTypeTest, BinaryExpr) { c <<= ^c; c >>= ^c; c |= ^c; c &= ^c; } )cpp"; - EXPECT_THAT(collectPreferredTypes(code15), Each("NULL TYPE")); + EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE")); } } // namespace