[libcxx] r318244 - Added tests for xxx.size() and xxx.empty() for all the sequence containers

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 17:33:33 PST 2017


Author: marshall
Date: Tue Nov 14 17:33:33 2017
New Revision: 318244

URL: http://llvm.org/viewvc/llvm-project?rev=318244&view=rev
Log:
Added tests for xxx.size() and xxx.empty() for all the sequence containers

Added:
    libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
    libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp
    libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
    libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp

Added: libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// class deque
+
+// bool empty() const noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::deque<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::deque<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// class deque
+
+// size_type size() const noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::deque<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::deque<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// bool empty() const noexcept;
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::forward_list<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_front(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::forward_list<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_front(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// class list
+
+// bool empty() const noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::list<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::list<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// class list
+
+// size_type size() const noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::list<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::list<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// bool empty() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::vector<bool> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(false);
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::vector<bool, min_allocator<bool>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(false);
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// size_type size() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::vector<bool> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(false);
+    assert(c.size() == 1);
+    c.push_back(true);
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(true);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::vector<bool, min_allocator<bool>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(false);
+    assert(c.size() == 1);
+    c.push_back(true);
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(true);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// bool empty() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::vector<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::vector<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.empty());
+    assert(c.empty());
+    c.push_back(C::value_type(1));
+    assert(!c.empty());
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp?rev=318244&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp Tue Nov 14 17:33:33 2017
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// size_type size() const noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::vector<int> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#if TEST_STD_VER >= 11
+    {
+    typedef std::vector<int, min_allocator<int>> C;
+    C c;
+    ASSERT_NOEXCEPT(c.size());
+    assert(c.size() == 0);
+    c.push_back(C::value_type(2));
+    assert(c.size() == 1);
+    c.push_back(C::value_type(1));
+    assert(c.size() == 2);
+    c.push_back(C::value_type(3));
+    assert(c.size() == 3);
+    c.erase(c.begin());
+    assert(c.size() == 2);
+    c.erase(c.begin());
+    assert(c.size() == 1);
+    c.erase(c.begin());
+    assert(c.size() == 0);
+    }
+#endif
+}




More information about the cfe-commits mailing list