-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathiterator_test.h
42 lines (33 loc) · 1.11 KB
/
iterator_test.h
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
#ifndef MYTINYSTL_ITERATOR_TEST_H_
#define MYTINYSTL_ITERATOR_TEST_H_
#include "test.h"
#include "../MyTinySTL/iterator.h"
#include "../MyTinySTL/stream_iterator.h"
namespace mystl
{
namespace test
{
namespace iterator_test
{
void stream_iterator_test()
{
std::cout << "[===============================================================]\n";
std::cout << "[------------- Run iterator test : stream_iterator--------------]\n";
std::cout << "[-------------------------- API test ---------------------------]\n";
static_assert(mystl::is_exactly_input_iterator<mystl::istream_iterator<int>>::value,
"istream_iterator must have input_iterator_tag)");
std::istringstream is("1 2 3");
mystl::istream_iterator<int> first{is}, last;
std::cout << mystl::distance(first, last) << '\n';
std::istringstream istream("1 2 3 4 5 6");
mystl::istream_iterator<int> beg{istream}, end;
for (; beg != end; ++beg) {
std::cout << *beg << " ";
}
std::cout << '\n';
PASSED;
}
} // namespace stream_iterator_test
} // namespace test
} // namespace mystl
#endif // !MYTINYSTL_STREAM_ITERATOR_TEST_H_