From: Marshall Clow Date: Wed, 15 Nov 2017 01:33:33 +0000 (+0000) Subject: Added tests for xxx.size() and xxx.empty() for all the sequence containers X-Git-Tag: llvmorg-6.0.0-rc1~3382 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cb7d78130719390849486b0dee1ed01fba4b033;p=platform%2Fupstream%2Fllvm.git Added tests for xxx.size() and xxx.empty() for all the sequence containers llvm-svn: 318244 --- diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp new file mode 100644 index 0000000..629a51c --- /dev/null +++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class deque + +// bool empty() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::deque 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp new file mode 100644 index 0000000..4974fc7 --- /dev/null +++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class deque + +// size_type size() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::deque 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp new file mode 100644 index 0000000..1226e68 --- /dev/null +++ b/libcxx/test/std/containers/sequences/forwardlist/empty.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class forward_list + +// bool empty() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::forward_list 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp new file mode 100644 index 0000000..b564990 --- /dev/null +++ b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class list + +// bool empty() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::list 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp new file mode 100644 index 0000000..bddaeb5 --- /dev/null +++ b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class list + +// size_type size() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::list 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp new file mode 100644 index 0000000..1471c39 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class vector + +// bool empty() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::vector 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> C; + C c; + ASSERT_NOEXCEPT(c.empty()); + assert(c.empty()); + c.push_back(false); + assert(!c.empty()); + c.clear(); + assert(c.empty()); + } +#endif +} diff --git a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp new file mode 100644 index 0000000..a1dcfd6 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class vector + +// size_type size() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::vector 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp new file mode 100644 index 0000000..d816831 --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class vector + +// bool empty() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::vector 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> 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 +} diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp new file mode 100644 index 0000000..71f531c --- /dev/null +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// class vector + +// size_type size() const noexcept; + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::vector 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> 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 +}