Added tests for xxx.size() and xxx.empty() for all the sequence containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
46
test/std/containers/sequences/forwardlist/empty.pass.cpp
Normal file
46
test/std/containers/sequences/forwardlist/empty.pass.cpp
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
46
test/std/containers/sequences/vector.bool/empty.pass.cpp
Normal file
46
test/std/containers/sequences/vector.bool/empty.pass.cpp
Normal file
@@ -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
|
||||
}
|
||||
62
test/std/containers/sequences/vector.bool/size.pass.cpp
Normal file
62
test/std/containers/sequences/vector.bool/size.pass.cpp
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user