aboutsummaryrefslogtreecommitdiff
path: root/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
blob: 95262aab1bdccba89936bfbc85f936a3f091d74f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview

// size_type size()     const noexcept;
// size_type max_size() const noexcept;
// bool      empty()    const noexcept;

#include <__config>

#include <experimental/dynarray>
#include <cassert>

#include <algorithm>
#include <complex>
#include <string>

using std::experimental::dynarray;

template <class T>
void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
    assert ( dyn.size ()     == sz );
    assert ( dyn.max_size () == sz );
    assert ( dyn.empty () == ( sz == 0 ));
    }

template <class T>
void test ( std::initializer_list<T> vals ) {
    typedef dynarray<T> dynA;

    dynA d1 ( vals );
    dyn_test ( d1, vals.size ());
    }

int main()
{
    test ( { 1, 1, 2, 3, 5, 8 } );
    test ( { 1., 1., 2., 3., 5., 8. } );
    test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
                std::string("5"), std::string("8")} );

    test<int> ( {} );
    test<std::complex<double>> ( {} );
    test<std::string> ( {} );
}