blob: 5b6c498570446e78985b0dc94d67acebaab12402 [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);
13
14#include <vector>
15#include <cassert>
16
17#include "../../../stack_allocator.h"
Marshall Clow061d0cc2013-11-26 20:58:02 +000018#include "min_allocator.h"
Marshall Clow1f50f2d2014-05-08 14:14:06 +000019#include "asan_testing.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020
21template <class C>
22void
23test(typename C::size_type n, const typename C::value_type& x)
24{
25 C c(n, x);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070026 assert(c.__invariants());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000027 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);
36 test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070037#if __cplusplus >= 201103L
Howard Hinnant2c39cbe2013-06-27 19:35:32 +000038 test<std::vector<int, min_allocator<int>> >(50, 3);
39#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000040}