-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaw_iterator_split_iterator_test.cpp
More file actions
74 lines (61 loc) · 1.48 KB
/
Copy pathdaw_iterator_split_iterator_test.cpp
File metadata and controls
74 lines (61 loc) · 1.48 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
// 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_split_iterator.h"
#include "daw/daw_benchmark.h"
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <string>
void split_it_001( ) {
std::string str = "This is a test of the split";
auto it = daw::make_split_it( str, ' ' );
while( it != str.end( ) ) {
std::cout << *it << '\n';
++it;
}
}
void split_it_002( ) {
std::string str = "t j ";
auto it = daw::make_split_it( str, ' ' );
while( it != str.end( ) ) {
std::cout << *it << '\n';
++it;
}
}
void split_it_003( ) {
std::string str = "This is a test of the split";
auto it = daw::make_split_it( str, ' ' );
auto const last = it.make_end( );
std::vector<std::string> results{ };
std::transform( it, last, std::back_inserter( results ), []( auto sv ) {
return sv.to_string( );
} );
for( auto const &s : results ) {
std::cout << s << '\n';
}
}
void split_it_004( ) {
std::string str = "This is a test of the split";
auto it = daw::make_split_it( str, ' ' );
auto const last = daw::split_it<char>{ };
while( it != last ) {
auto sv = *it;
++it;
--it;
auto sv_prev = *it;
daw::expecting( sv, sv_prev );
++it;
}
}
int main( ) {
split_it_001( );
split_it_002( );
split_it_003( );
split_it_004( );
}