|
Boost-Commit : |
From: technews_at_[hidden]
Date: 2007-12-25 00:18:05
Author: turkanis
Date: 2007-12-25 00:18:04 EST (Tue, 25 Dec 2007)
New Revision: 42291
URL: http://svn.boost.org/trac/boost/changeset/42291
Log:
These files were left out of the last iostreams commit.
Corrected integer overflow in positioning test which masked failures by
Borland 5.6.4-5.8.2 (at least); split positioning test into two files:
stream_offset_32bit_test.cpp and stream_offset_64bit_test.cpp.
This affects:
test/positioning_test.cpp
test/stream_offset_32biit_test.cpp
test/stream_offset_64bit_test.cpp
Added:
branches/iostreams_dev/libs/iostreams/test/stream_offset_32bit_test.cpp (contents, props changed)
branches/iostreams_dev/libs/iostreams/test/stream_offset_64bit_test.cpp (contents, props changed)
Removed:
branches/iostreams_dev/libs/iostreams/test/positioning_test.cpp
Deleted: branches/iostreams_dev/libs/iostreams/test/positioning_test.cpp
==============================================================================
--- branches/iostreams_dev/libs/iostreams/test/positioning_test.cpp 2007-12-25 00:18:04 EST (Tue, 25 Dec 2007)
+++ (empty file)
@@ -1,70 +0,0 @@
-// (C) Copyright Jonathan Turkanis 2005
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
-
-// See http://www.boost.org/libs/iostreams for documentation.
-
-#include <boost/iostreams/detail/ios.hpp>
-#include <boost/iostreams/positioning.hpp>
-#include <boost/integer_traits.hpp>
-#include <boost/test/test_tools.hpp>
-#include <boost/test/unit_test.hpp>
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-using namespace boost;
-using namespace boost::iostreams;
-using boost::unit_test::test_suite;
-
-void large_file_test()
-{
- stream_offset large_file = (stream_offset) 100 *
- (stream_offset) 1024 *
- (stream_offset) 1024 *
- (stream_offset) 1024;
- stream_offset first = -large_file - (-large_file) % 10000000;
- stream_offset last = large_file - large_file % 10000000;
-
- fstream log;
- log.open("C:/borland-output-5.8.2.txt", std::ios::out | std::ios::trunc);
- for (stream_offset off = first; off < last; off += 10000000)
- {
- if (off == position_to_offset(offset_to_position(off))) {
- log << "offset = " << off << "\n";
- } else {
- log << "offset = " << off
- << "; pos = " << position_to_offset(offset_to_position(off))
- << "\n";
- }
- //BOOST_CHECK(off == position_to_offset(offset_to_position(off)));
- }
-}
-
-void small_file_test()
-{
- stream_offset small_file = 1000000;
- stream_offset off = -small_file;
- streampos pos = offset_to_position(off);
-
- while (off < small_file)
- {
- BOOST_CHECK(off == position_to_offset(offset_to_position(off)));
- BOOST_CHECK(pos == offset_to_position(position_to_offset(pos)));
- off += 20000;
- pos += 20000;
- BOOST_CHECK(off == position_to_offset(offset_to_position(off)));
- BOOST_CHECK(pos == offset_to_position(position_to_offset(pos)));
- off -= 10000;
- pos -= 10000;
- }
-}
-
-test_suite* init_unit_test_suite(int, char* [])
-{
- test_suite* test = BOOST_TEST_SUITE("positioning test");
- test->add(BOOST_TEST_CASE(&large_file_test));
- test->add(BOOST_TEST_CASE(&small_file_test));
- return test;
-}
Added: branches/iostreams_dev/libs/iostreams/test/stream_offset_32bit_test.cpp
==============================================================================
--- (empty file)
+++ branches/iostreams_dev/libs/iostreams/test/stream_offset_32bit_test.cpp 2007-12-25 00:18:04 EST (Tue, 25 Dec 2007)
@@ -0,0 +1,50 @@
+/*
+ * Distributed under the Boost Software License, Version 1.0.(See accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+ *
+ * See http://www.boost.org/libs/iostreams for documentation.
+
+ * File: libs/iostreams/test/stream_offset_32bit_test.cpp
+ * Date: Sun Dec 23 21:11:23 MST 2007
+ * Copyright: 2007 CodeRage
+ * Author: Jonathan Turkanis
+ *
+ * Tests the functions defined in the header "boost/iostreams/positioning.hpp"
+ * with small (32-bit) file offsets.
+ */
+
+#include <boost/iostreams/positioning.hpp>
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace boost::iostreams;
+using boost::unit_test::test_suite;
+
+void stream_offset_32bit_test()
+{
+ stream_offset small_file = 1000000;
+ stream_offset off = -small_file;
+ streampos pos = offset_to_position(off);
+
+ while (off < small_file)
+ {
+ BOOST_CHECK(off == position_to_offset(offset_to_position(off)));
+ BOOST_CHECK(pos == offset_to_position(position_to_offset(pos)));
+ off += 20000;
+ pos += 20000;
+ BOOST_CHECK(off == position_to_offset(offset_to_position(off)));
+ BOOST_CHECK(pos == offset_to_position(position_to_offset(pos)));
+ off -= 10000;
+ pos -= 10000;
+ }
+}
+
+test_suite* init_unit_test_suite(int, char* [])
+{
+ test_suite* test = BOOST_TEST_SUITE("stream_offset 32-bit test");
+ test->add(BOOST_TEST_CASE(&stream_offset_32bit_test));
+ return test;
+}
Added: branches/iostreams_dev/libs/iostreams/test/stream_offset_64bit_test.cpp
==============================================================================
--- (empty file)
+++ branches/iostreams_dev/libs/iostreams/test/stream_offset_64bit_test.cpp 2007-12-25 00:18:04 EST (Tue, 25 Dec 2007)
@@ -0,0 +1,50 @@
+/*
+ * Distributed under the Boost Software License, Version 1.0.(See accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+ *
+ * See http://www.boost.org/libs/iostreams for documentation.
+
+ * File: libs/iostreams/test/stream_offset_64bit_test.cpp
+ * Date: Sun Dec 23 21:11:23 MST 2007
+ * Copyright: 2007 CodeRage
+ * Author: Jonathan Turkanis
+ *
+ * Tests the functions defined in the header "boost/iostreams/positioning.hpp"
+ * with large (64-bit) file offsets.
+ */
+
+#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/iostreams/positioning.hpp>
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace boost::iostreams;
+using boost::unit_test::test_suite;
+
+#ifdef BOOST_MSVC
+# pragma warning(disable:4127)
+#endif
+
+void stream_offset_64bit_test()
+{
+ stream_offset large_file = (stream_offset) 100 *
+ (stream_offset) 1024 *
+ (stream_offset) 1024 *
+ (stream_offset) 1024;
+ stream_offset first = -large_file - (-large_file) % 10000000;
+ stream_offset last = large_file - large_file % 10000000;
+
+ for (stream_offset off = first; off < last; off += 10000000)
+ {
+ BOOST_REQUIRE(off == position_to_offset(offset_to_position(off)));
+ }
+}
+
+test_suite* init_unit_test_suite(int, char* [])
+{
+ test_suite* test = BOOST_TEST_SUITE("stream_offset 64-bit test");
+ test->add(BOOST_TEST_CASE(&stream_offset_64bit_test));
+ return test;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk