Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63435 - trunk/libs/iostreams/test
From: daniel_james_at_[hidden]
Date: 2010-06-29 11:20:12


Author: danieljames
Date: 2010-06-29 11:20:11 EDT (Tue, 29 Jun 2010)
New Revision: 63435
URL: http://svn.boost.org/trac/boost/changeset/63435

Log:
Repeat the new file descriptor tests for the three different classes.
Text files modified:
   trunk/libs/iostreams/test/deprecated_file_descriptor_test.cpp | 134 ++++++++++++++++++++-------------------
   trunk/libs/iostreams/test/file_descriptor_test.cpp | 74 ++++++++++++---------
   2 files changed, 110 insertions(+), 98 deletions(-)

Modified: trunk/libs/iostreams/test/deprecated_file_descriptor_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/deprecated_file_descriptor_test.cpp (original)
+++ trunk/libs/iostreams/test/deprecated_file_descriptor_test.cpp 2010-06-29 11:20:11 EDT (Tue, 29 Jun 2010)
@@ -10,12 +10,9 @@
 namespace boost_ios = boost::iostreams;
 namespace ios_test = boost::iostreams::test;
 
-void deprecated_file_descriptor_test()
+template <class FileDescriptor>
+void file_handle_test_impl(FileDescriptor*)
 {
- typedef boost_ios::stream<boost_ios::file_descriptor_source> fdistream;
- typedef boost_ios::stream<boost_ios::file_descriptor_sink> fdostream;
- typedef boost_ios::stream<boost_ios::file_descriptor> fdstream;
-
     ios_test::test_file test1;
     ios_test::test_file test2;
                     
@@ -24,8 +21,8 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1(handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1(handle);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
         ios_test::close_file_handle(handle);
@@ -34,8 +31,8 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1(handle, false);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1(handle, false);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
         ios_test::close_file_handle(handle);
@@ -44,36 +41,36 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1(handle, true);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1(handle, true);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1(handle);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1(handle);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1(handle, false);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1(handle, false);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1(handle, true);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1(handle, true);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
@@ -82,9 +79,9 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1;
- source1.open(handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1;
+ device1.open(handle);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
         ios_test::close_file_handle(handle);
@@ -93,9 +90,9 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1;
- source1.open(handle, false);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1;
+ device1.open(handle, false);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
         ios_test::close_file_handle(handle);
@@ -104,40 +101,40 @@
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1;
- source1.open(handle, true);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1;
+ device1.open(handle, true);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1;
- source1.open(handle);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1;
+ device1.open(handle);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1;
- source1.open(handle, false);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1;
+ device1.open(handle, false);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = ios_test::open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1;
- source1.open(handle, true);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1;
+ device1.open(handle, true);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
@@ -148,15 +145,15 @@
         boost_ios::detail::file_handle handle2 = ios_test::open_file_handle(test1.name());
 
         {
- boost_ios::file_descriptor_source source1(handle1);
- BOOST_CHECK(source1.handle() == handle1);
+ FileDescriptor device1(handle1);
+ BOOST_CHECK(device1.handle() == handle1);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.open(handle2);
- BOOST_CHECK(source1.handle() == handle2);
+ device1.open(handle2);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.close();
+ device1.close();
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_CLOSED(handle2);
         }
@@ -171,15 +168,15 @@
         boost_ios::detail::file_handle handle2 = ios_test::open_file_handle(test1.name());
 
         {
- boost_ios::file_descriptor_source source1(handle1, true);
- BOOST_CHECK(source1.handle() == handle1);
+ FileDescriptor device1(handle1, true);
+ BOOST_CHECK(device1.handle() == handle1);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.open(handle2);
- BOOST_CHECK(source1.handle() == handle2);
+ device1.open(handle2);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_CLOSED(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.close();
+ device1.close();
             BOOST_CHECK_HANDLE_CLOSED(handle1);
             BOOST_CHECK_HANDLE_CLOSED(handle2);
         }
@@ -192,12 +189,12 @@
         boost_ios::detail::file_handle handle2 = ios_test::open_file_handle(test1.name());
 
         {
- boost_ios::file_descriptor_source source1(handle1, false);
- BOOST_CHECK(source1.handle() == handle1);
+ FileDescriptor device1(handle1, false);
+ BOOST_CHECK(device1.handle() == handle1);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.open(handle2, false);
- BOOST_CHECK(source1.handle() == handle2);
+ device1.open(handle2, false);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
         }
@@ -213,12 +210,12 @@
         boost_ios::detail::file_handle handle2 = ios_test::open_file_handle(test1.name());
 
         {
- boost_ios::file_descriptor_source source1(handle1, true);
- BOOST_CHECK(source1.handle() == handle1);
+ FileDescriptor device1(handle1, true);
+ BOOST_CHECK(device1.handle() == handle1);
             BOOST_CHECK_HANDLE_OPEN(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
- source1.open(handle2, true);
- BOOST_CHECK(source1.handle() == handle2);
+ device1.open(handle2, true);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_CLOSED(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
         }
@@ -227,6 +224,13 @@
     }
 }
 
+void deprecated_file_descriptor_test()
+{
+ file_handle_test_impl((boost_ios::file_descriptor*) 0);
+ file_handle_test_impl((boost_ios::file_descriptor_sink*) 0);
+ file_handle_test_impl((boost_ios::file_descriptor_source*) 0);
+}
+
 boost::unit_test::test_suite* init_unit_test_suite(int, char* [])
 {
     boost::unit_test::test_suite* test = BOOST_TEST_SUITE("deprecated file_descriptor test");

Modified: trunk/libs/iostreams/test/file_descriptor_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/file_descriptor_test.cpp (original)
+++ trunk/libs/iostreams/test/file_descriptor_test.cpp 2010-06-29 11:20:11 EDT (Tue, 29 Jun 2010)
@@ -510,7 +510,8 @@
     }
 }
 
-void file_handle_test()
+template <class FileDescriptor>
+void file_handle_test_impl(FileDescriptor*)
 {
     test_file test1;
     test_file test2;
@@ -518,8 +519,8 @@
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1(handle, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1(handle, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
         close_file_handle(handle);
@@ -528,28 +529,28 @@
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1(handle, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1(handle, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle);
         }
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1(handle, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1(handle, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_OPEN(handle);
         close_file_handle(handle);
     }
 
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
- boost_ios::file_descriptor_source source1(handle, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle);
- source1.close();
- BOOST_CHECK(!source1.is_open());
+ FileDescriptor device1(handle, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle);
+ device1.close();
+ BOOST_CHECK(!device1.is_open());
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 
@@ -557,10 +558,10 @@
         boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
         boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
         {
- boost_ios::file_descriptor_source source1(handle1, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle1);
- source1.open(handle2, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle2);
+ FileDescriptor device1(handle1, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle1);
+ device1.open(handle2, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle2);
         }
         BOOST_CHECK_HANDLE_OPEN(handle1);
         BOOST_CHECK_HANDLE_OPEN(handle2);
@@ -572,10 +573,10 @@
         boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
         boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
         {
- boost_ios::file_descriptor_source source1(handle1, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle1);
- source1.open(handle2, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle2);
+ FileDescriptor device1(handle1, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle1);
+ device1.open(handle2, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_CLOSED(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
         }
@@ -587,10 +588,10 @@
         boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
         boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
         {
- boost_ios::file_descriptor_source source1(handle1, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle1);
- source1.open(handle2, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle2);
+ FileDescriptor device1(handle1, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle1);
+ device1.open(handle2, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle2);
             BOOST_CHECK_HANDLE_CLOSED(handle1);
             BOOST_CHECK_HANDLE_OPEN(handle2);
         }
@@ -602,10 +603,10 @@
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1;
- BOOST_CHECK(!source1.is_open());
- source1.open(handle, boost_ios::never_close_handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1;
+ BOOST_CHECK(!device1.is_open());
+ device1.open(handle, boost_ios::never_close_handle);
+ BOOST_CHECK(device1.handle() == handle);
             BOOST_CHECK_HANDLE_OPEN(handle);
         }
         BOOST_CHECK_HANDLE_OPEN(handle);
@@ -615,16 +616,23 @@
     {
         boost_ios::detail::file_handle handle = open_file_handle(test1.name());
         {
- boost_ios::file_descriptor_source source1;
- BOOST_CHECK(!source1.is_open());
- source1.open(handle, boost_ios::close_handle);
- BOOST_CHECK(source1.handle() == handle);
+ FileDescriptor device1;
+ BOOST_CHECK(!device1.is_open());
+ device1.open(handle, boost_ios::close_handle);
+ BOOST_CHECK(device1.handle() == handle);
             BOOST_CHECK_HANDLE_OPEN(handle);
         }
         BOOST_CHECK_HANDLE_CLOSED(handle);
     }
 }
 
+void file_handle_test()
+{
+ file_handle_test_impl((boost_ios::file_descriptor*) 0);
+ file_handle_test_impl((boost_ios::file_descriptor_source*) 0);
+ file_handle_test_impl((boost_ios::file_descriptor_sink*) 0);
+}
+
 test_suite* init_unit_test_suite(int, char* [])
 {
     test_suite* test = BOOST_TEST_SUITE("file_descriptor 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