MCPcopy Index your code
hub / github.com/cpplint/cpplint / testBraceInitializerList

Method testBraceInitializerList

cpplint_unittest.py:3131–3181  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3129 self.TestLint("table_to_children[&*table].push_back(dependent);", "")
3130
3131 def testBraceInitializerList(self):
3132 self.TestLint("MyStruct p = {1, 2};", "")
3133 self.TestLint("MyStruct p{1, 2};", "")
3134 self.TestLint("vector<int> p = {1, 2};", "")
3135 self.TestLint("vector<int> p{1, 2};", "")
3136 self.TestLint("x = vector<int>{1, 2};", "")
3137 self.TestLint("x = (struct in_addr){ 0 };", "")
3138 self.TestLint("Func(vector<int>{1, 2})", "")
3139 self.TestLint("Func((struct in_addr){ 0 })", "")
3140 self.TestLint("Func(vector<int>{1, 2}, 3)", "")
3141 self.TestLint("Func((struct in_addr){ 0 }, 3)", "")
3142 self.TestLint("LOG(INFO) << char{7};", "")
3143 self.TestLint('LOG(INFO) << char{7} << "!";', "")
3144 self.TestLint("int p[2] = {1, 2};", "")
3145 self.TestLint("return {1, 2};", "")
3146 self.TestLint("std::unique_ptr<Foo> foo{new Foo{}};", "")
3147 self.TestLint("auto foo = std::unique_ptr<Foo>{new Foo{}};", "")
3148 self.TestLint('static_assert(Max7String{}.IsValid(), "");', "")
3149 self.TestLint("map_of_pairs[{1, 2}] = 3;", "")
3150 self.TestLint("ItemView{has_offer() ? new Offer{offer()} : nullptr", "")
3151 self.TestLint("template <class T, EnableIf<::std::is_const<T>{}> = 0>", "")
3152
3153 self.TestMultiLineLint("std::unique_ptr<Foo> foo{\n new Foo{}\n};\n", "")
3154 self.TestMultiLineLint(
3155 "std::unique_ptr<Foo> foo{\n new Foo{\n new Bar{}\n }\n};\n", ""
3156 )
3157 self.TestMultiLineLint(
3158 "if (true) {\n if (false){\n func();\n }}\n",
3159 "Missing space before { [whitespace/braces] [5]",
3160 )
3161 self.TestMultiLineLint(
3162 "MyClass::MyClass()\n : initializer_{\n Func()} {\n}\n", ""
3163 )
3164 self.TestLint(
3165 "const pair<string, string> kCL" + ("o" * 41) + "gStr[] = {\n",
3166 "Lines should be <= 80 characters long [whitespace/line_length] [2]",
3167 )
3168 self.TestMultiLineLint(
3169 "const pair<string, string> kCL" + ("o" * 40) + "ngStr[] =\n"
3170 " {\n"
3171 ' {"gooooo", "oooogle"},\n'
3172 "};\n",
3173 "",
3174 )
3175 self.TestMultiLineLint(
3176 "const pair<string, string> kCL" + ("o" * 39) + "ngStr[] =\n"
3177 " {\n"
3178 ' {"gooooo", "oooogle"},\n'
3179 "};\n",
3180 "{ should almost always be at the end of the previous line [whitespace/braces] [4]",
3181 )
3182
3183 def testSpacingAroundElse(self):
3184 self.TestLint("}else {", "Missing space before else [whitespace/braces] [5]")

Callers

nothing calls this directly

Calls 2

TestLintMethod · 0.80
TestMultiLineLintMethod · 0.80

Tested by

no test coverage detected