-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaw_bounded_vector_test.cpp
More file actions
87 lines (79 loc) · 2.06 KB
/
daw_bounded_vector_test.cpp
File metadata and controls
87 lines (79 loc) · 2.06 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) Darrell Wright
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/beached/header_libraries
//
#include "daw/daw_bounded_vector.h"
#include "daw/daw_benchmark.h"
constexpr bool daw_bounded_vector_test_001( ) {
daw::bounded_vector_t<int, 10> a{ };
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 4 );
a.push_back( 8 );
a.push_back( 16 );
a.emplace_back( 5 );
int sum = 0;
for( auto c : a ) {
sum += c;
}
daw::expecting( sum, 36 );
return true;
}
static_assert( daw_bounded_vector_test_001( ) );
constexpr bool daw_bounded_vector_test_002( ) {
daw::bounded_vector_t<int, 10> a{ };
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 4 );
daw::expecting( a.back( ), 4 );
daw::expecting( a.pop_back( ), 4 );
daw::expecting( a.back( ), 2 );
daw::expecting( 2U, a.size( ) );
daw::expecting( 10U, a.capacity( ) );
daw::expecting( a.front( ), 1 );
daw::expecting( *a.cbegin( ), 1 );
daw::expecting( a.pop_back( ), 2 );
daw::expecting( a.pop_back( ), 1 );
daw::expecting( 0U, a.size( ) );
daw::expecting( a.empty( ) );
return true;
}
static_assert( daw_bounded_vector_test_002( ) );
constexpr bool daw_bounded_vector_test_003( ) {
daw::bounded_vector_t<int, 6> a{ };
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 4 );
a.push_back( 8 );
a.push_back( 16 );
a.emplace_back( 5 );
daw::expecting( a.full( ) );
return true;
}
static_assert( daw_bounded_vector_test_003( ) );
namespace daw_bounded_vector_test_004_ns {
constexpr auto cx_test( ) {
daw::bounded_vector_t<int, 10> a{ };
a.push_back( 1 );
a.push_back( 2 );
a.push_back( 4 );
a.push_back( 8 );
a.push_back( 16 );
a.emplace_back( 5 );
return a;
}
constexpr bool daw_bounded_vector_test_004( ) {
constexpr auto a = cx_test( );
int sum = 0;
for( auto c : a ) {
sum += c;
}
daw::expecting( sum, 36 );
return true;
}
static_assert( daw_bounded_vector_test_004( ) );
} // namespace daw_bounded_vector_test_004_ns
int main( ) {}