1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // dynarray.overview
11 
12 // size_type size()     const noexcept;
13 // size_type max_size() const noexcept;
14 // bool      empty()    const noexcept;
15 
16 #include <__config>
17 
18 #if _LIBCPP_STD_VER > 11
19 
20 #include <experimental/dynarray>
21 #include <cassert>
22 
23 #include <algorithm>
24 #include <complex>
25 #include <string>
26 
27 using std::experimental::dynarray;
28 
29 template <class T>
dyn_test(const dynarray<T> & dyn,size_t sz)30 void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
31     assert ( dyn.size ()     == sz );
32     assert ( dyn.max_size () == sz );
33     assert ( dyn.empty () == ( sz == 0 ));
34     }
35 
36 template <class T>
test(std::initializer_list<T> vals)37 void test ( std::initializer_list<T> vals ) {
38     typedef dynarray<T> dynA;
39 
40     dynA d1 ( vals );
41     dyn_test ( d1, vals.size ());
42     }
43 
main()44 int main()
45 {
46     test ( { 1, 1, 2, 3, 5, 8 } );
47     test ( { 1., 1., 2., 3., 5., 8. } );
48     test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
49                 std::string("5"), std::string("8")} );
50 
51     test<int> ( {} );
52     test<std::complex<double>> ( {} );
53     test<std::string> ( {} );
54 }
55 #else
main()56 int main() {}
57 #endif
58