diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp b/clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp index eb453fcbb09..a3f63857e10 100644 --- a/clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-container-size-empty.cpp @@ -7,6 +7,15 @@ template <typename T> struct vector { bool empty() const; }; +template <typename T> struct basic_string { + basic_string(); + unsigned long size() const; + bool empty() const; +}; + +typedef basic_string<char> string; +typedef basic_string<wchar_t> wstring; + inline namespace __v2 { template <typename T> struct set { set(); @@ -20,10 +29,24 @@ template <typename T> struct set { int main() { std::set<int> intSet; + std::string str; + std::wstring wstr; + str.size() + 0; + str.size() - 0; + 0 + str.size(); + 0 - str.size(); if (intSet.size() == 0) ; // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] // CHECK-FIXES: {{^ }}if (intSet.empty()){{$}} + if (str.size() == 0) + ; + // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used + // CHECK-FIXES: {{^ }}if (str.empty()){{$}} + if (wstr.size() == 0) + ; + // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used + // CHECK-FIXES: {{^ }}if (wstr.empty()){{$}} std::vector<int> vect; if (vect.size() == 0) ; |