mirror of
https://github.com/tiennm99/styleguide.git
synced 2026-08-15 18:24:24 +00:00
Support C++11 types in build/include_what_you_use
This change adds support for forward, make_pair, make_shared,, make_unique, move, shared_ptr, unique_ptr, unordered_map, unordered_multimap, unordered_multiset, unordered_set, weak_ptr. Closes #133.
This commit is contained in:
@@ -910,6 +910,12 @@ class CpplintTest(CpplintTestBase):
|
||||
""",
|
||||
'Add #include <utility> for pair<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <hash_map>
|
||||
auto foo = std::make_pair(1, 2);
|
||||
""",
|
||||
'Add #include <utility> for make_pair'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <utility>
|
||||
std::pair<int,int> foo;
|
||||
@@ -997,6 +1003,18 @@ class CpplintTest(CpplintTestBase):
|
||||
""",
|
||||
'Add #include <map> for multimap<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <string>
|
||||
void a(const std::unordered_map<int,string> &foobar);
|
||||
""",
|
||||
'Add #include <unordered_map> for unordered_map<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <string>
|
||||
void a(const std::unordered_set<int> &foobar);
|
||||
""",
|
||||
'Add #include <unordered_set> for unordered_set<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <queue>
|
||||
void a(const std::priority_queue<int> &foobar);
|
||||
@@ -1020,6 +1038,31 @@ class CpplintTest(CpplintTestBase):
|
||||
int i = numeric_limits<int>::max()
|
||||
""",
|
||||
'')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <string>
|
||||
std::unique_ptr<int> x;
|
||||
""",
|
||||
'Add #include <memory> for unique_ptr<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <string>
|
||||
auto x = std::make_unique<int>(0);
|
||||
""",
|
||||
'Add #include <memory> for make_unique<>'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <vector>
|
||||
vector<int> foo(vector<int> x) { return std::move(x); }
|
||||
""",
|
||||
'Add #include <utility> for move'
|
||||
' [build/include_what_you_use] [4]')
|
||||
self.TestIncludeWhatYouUse(
|
||||
"""#include <string>
|
||||
int a, b;
|
||||
std::swap(a, b);
|
||||
""",
|
||||
'Add #include <utility> for swap'
|
||||
' [build/include_what_you_use] [4]')
|
||||
|
||||
# Test the UpdateIncludeState code path.
|
||||
mock_header_contents = ['#include "blah/foo.h"', '#include "blah/bar.h"']
|
||||
|
||||
Reference in New Issue
Block a user