1 | /* |
---|---|
2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying |
3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
4 | * |
5 | * See http://www.boost.org/libs/iostreams for documentation. |
6 | |
7 | * File: libs/iostreams/test/stream_offset_32bit_test.cpp |
8 | * Date: Sun Dec 23 21:11:23 MST 2007 |
9 | * Copyright: 2007-2008 CodeRage, LLC |
10 | * Author: Jonathan Turkanis |
11 | * Contact: turkanis at coderage dot com |
12 | * |
13 | * Tests the functions defined in the header "boost/iostreams/positioning.hpp" |
14 | * with small (32-bit) file offsets. |
15 | */ |
16 | |
17 | #include <boost/iostreams/positioning.hpp> |
18 | #include <boost/test/test_tools.hpp> |
19 | #include <boost/test/unit_test.hpp> |
20 | #include <boost/type_traits/is_integral.hpp> |
21 | |
22 | using namespace std; |
23 | using namespace boost; |
24 | using namespace boost::iostreams; |
25 | using boost::unit_test::test_suite; |
26 | |
27 | void stream_offset_32bit_test() |
28 | { |
29 | stream_offset small_file = 1000000; |
30 | stream_offset off = -small_file; |
31 | streampos pos = offset_to_position(off); |
32 | |
33 | while (off < small_file) |
34 | { |
35 | BOOST_CHECK(off == position_to_offset(offset_to_position(off))); |
36 | BOOST_CHECK(pos == offset_to_position(position_to_offset(pos))); |
37 | off += 20000; |
38 | pos += 20000; |
39 | BOOST_CHECK(off == position_to_offset(offset_to_position(off))); |
40 | BOOST_CHECK(pos == offset_to_position(position_to_offset(pos))); |
41 | off -= 10000; |
42 | pos -= 10000; |
43 | } |
44 | } |
45 | |
46 | test_suite* init_unit_test_suite(int, char* []) |
47 | { |
48 | test_suite* test = BOOST_TEST_SUITE("stream_offset 32-bit test"); |
49 | test->add(BOOST_TEST_CASE(&stream_offset_32bit_test)); |
50 | return test; |
51 | } |
52 |