-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaw_iterator_checked_iterator_proxy_test.cpp
More file actions
49 lines (41 loc) · 1.23 KB
/
daw_iterator_checked_iterator_proxy_test.cpp
File metadata and controls
49 lines (41 loc) · 1.23 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
// 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/iterator/daw_checked_iterator_proxy.h"
#include "daw/daw_benchmark.h"
#include <iostream>
#include <stdexcept>
#include <vector>
void daw_checked_iterator_proxy_001( ) {
std::vector<int> const test = { 0, 1, 2, 3, 4 };
for( auto it = daw::make_checked_iterator_proxy( test.begin( ), test.end( ) );
it != test.end( );
++it ) {
std::cout << *it << '\n';
}
}
void daw_checked_iterator_proxy_002( ) {
std::vector<int> const test = { 0, 1, 2, 3, 4 };
bool result = false;
try {
for( auto it =
daw::make_checked_iterator_proxy( test.begin( ), test.begin( ) + 2 );
it != test.end( );
++it ) {
std::cout << *it << '\n';
}
} catch( std::out_of_range const &ex ) {
result = true;
std::cout << "Expected exception with message: " << ex.what( ) << '\n';
}
daw::expecting_message(
result, "Expected an out_of_range exception but didn't get one" );
}
int main( ) {
daw_checked_iterator_proxy_001( );
daw_checked_iterator_proxy_002( );
}