diff options
author | Matthias Braun <matze@braunis.de> | 2018-10-31 00:23:23 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2018-10-31 00:23:23 +0000 |
commit | b3bc95870d94ab6a58a997ba3fb4ac4ed37f861a (patch) | |
tree | 23e3364735fe28c5aa42f7bec8e47abdde2a8e4c /unittests | |
parent | 1c6bfcc50c346e44d3a1c1a9b0e6da159e503362 (diff) |
ADT/STLExtras: Introduce llvm::empty; NFC
This is modeled after C++17 std::empty().
Differential Revision: https://reviews.llvm.org/D53909
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/STLExtrasTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/ADT/STLExtrasTest.cpp b/unittests/ADT/STLExtrasTest.cpp index 427d470b61d..80e10d071ab 100644 --- a/unittests/ADT/STLExtrasTest.cpp +++ b/unittests/ADT/STLExtrasTest.cpp @@ -364,6 +364,23 @@ TEST(STLExtrasTest, ADLTest) { EXPECT_EQ(5, count); } +TEST(STLExtrasTest, EmptyTest) { + std::vector<void*> V; + EXPECT_TRUE(empty(V)); + V.push_back(nullptr); + EXPECT_FALSE(empty(V)); + + std::initializer_list<int> E = {}; + std::initializer_list<int> NotE = {7, 13, 42}; + EXPECT_TRUE(empty(E)); + EXPECT_FALSE(empty(NotE)); + + auto R0 = make_range(V.begin(), V.begin()); + EXPECT_TRUE(empty(R0)); + auto R1 = make_range(V.begin(), V.end()); + EXPECT_FALSE(empty(R1)); +} + TEST(STLExtrasTest, EarlyIncrementTest) { std::list<int> L = {1, 2, 3, 4}; |