blob: c62b84104aba7a381924a6b1a55c75f888703ef2 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <vector>
11
12// vector(size_type n, const value_type& x, const allocator_type& a);
13
14#include <vector>
15#include <cassert>
Marshall Clow061d0cc2013-11-26 20:58:02 +000016#include "min_allocator.h"
Marshall Clow1f50f2d2014-05-08 14:14:06 +000017#include "asan_testing.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000018
19template <class C>
20void
21test(typename C::size_type n, const typename C::value_type& x,
22 const typename C::allocator_type& a)
23{
24 C c(n, x, a);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070025 assert(c.__invariants());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000026 assert(a == c.get_allocator());
27 assert(c.size() == n);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070028 assert(is_contiguous_container_asan_correct(c));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000029 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
30 assert(*i == x);
31}
32
33int main()
34{
35 test<std::vector<int> >(50, 3, std::allocator<int>());
Dan Albert1d4a1ed2016-05-25 22:36:09 -070036#if __cplusplus >= 201103L
Howard Hinnant2c39cbe2013-06-27 19:35:32 +000037 test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
38#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000039}