Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63429 - in trunk/libs/iostreams/test: . detail
From: daniel_james_at_[hidden]
Date: 2010-06-29 10:13:53


Author: danieljames
Date: 2010-06-29 10:13:52 EDT (Tue, 29 Jun 2010)
New Revision: 63429
URL: http://svn.boost.org/trac/boost/changeset/63429

Log:
Use `unique_path` instead of tmpnam. Refs #2325.
Text files modified:
   trunk/libs/iostreams/test/Jamfile.v2 | 1 +
   trunk/libs/iostreams/test/detail/temp_file.hpp | 33 +++------------------------------
   trunk/libs/iostreams/test/tee_test.cpp | 37 ++++++++++++++++++-------------------
   3 files changed, 22 insertions(+), 49 deletions(-)

Modified: trunk/libs/iostreams/test/Jamfile.v2
==============================================================================
--- trunk/libs/iostreams/test/Jamfile.v2 (original)
+++ trunk/libs/iostreams/test/Jamfile.v2 2010-06-29 10:13:52 EDT (Tue, 29 Jun 2010)
@@ -20,6 +20,7 @@
             run
                 $(sources)
                 /boost/test//boost_unit_test_framework/<link>static
+ /boost/filesystem//boost_filesystem/<link>static
             : # command
             : # input files
             : # build requirements

Modified: trunk/libs/iostreams/test/detail/temp_file.hpp
==============================================================================
--- trunk/libs/iostreams/test/detail/temp_file.hpp (original)
+++ trunk/libs/iostreams/test/detail/temp_file.hpp 2010-06-29 10:13:52 EDT (Tue, 29 Jun 2010)
@@ -13,10 +13,7 @@
 #include <cstdlib> // rand, toupper, tolower (VC6)
 #include <fstream>
 #include <string>
-#if defined(__CYGWIN__)
-# include <boost/random/linear_congruential.hpp>
-# include <boost/random/uniform_smallint.hpp>
-#endif
+#include <boost/filesystem/v3/operations.hpp>
 #include "./constants.hpp"
 
 #ifdef BOOST_NO_STDC_NAMESPACE
@@ -42,33 +39,9 @@
     operator const ::std::string() const { return name_; }
 private:
     void set_name() {
- // Windows CreateFileMapping API function doesn't accept some
- // names generated by std::tmpnam.
- #if defined(_WIN32) || defined(__WIN32__) || \
- defined(WIN32) || defined(__CYGWIN__) \
- /**/
- for (int z = 0; z < 5; ++z)
- name_ += static_cast<char>('0' + rand());
- #else
- using namespace std;
- char tmp[L_tmpnam]; name_ = tmpnam(tmp);
- #endif
+ name_ = boost::filesystem3::unique_path().native();
     }
- #if defined(__CYGWIN__)
- int rand()
- {
- static rand48 random_gen;
- static uniform_smallint<int> random_dist(0, 9);
- return random_dist(random_gen);
- }
- #else
- # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- int rand()
- {
- return (std::rand() * 10) / RAND_MAX;
- }
- # endif
- #endif
+
     ::std::string name_;
 };
 

Modified: trunk/libs/iostreams/test/tee_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/tee_test.cpp (original)
+++ trunk/libs/iostreams/test/tee_test.cpp 2010-06-29 10:13:52 EDT (Tue, 29 Jun 2010)
@@ -22,7 +22,6 @@
 using namespace boost::iostreams;
 using namespace boost::iostreams::test;
 using boost::unit_test::test_suite;
-namespace io = boost::iostreams;
 
 void read_write_test()
 {
@@ -154,7 +153,7 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
+ boost::iostreams::tee(
                 closable_device<output>(seq.new_operation(1)),
                 closable_device<
                     #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
@@ -174,7 +173,7 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
+ boost::iostreams::tee(
                 closable_device<bidirectional>(
                     seq.new_operation(1),
                     seq.new_operation(2)
@@ -194,7 +193,7 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
+ boost::iostreams::tee(
                 closable_device<seekable>(seq.new_operation(1)),
                 closable_device<seekable>(seq.new_operation(2))
             )
@@ -207,7 +206,7 @@
     {
         operation_sequence seq;
         chain<output> ch;
- ch.push(io::tee(closable_device<output>(seq.new_operation(1))));
+ ch.push(boost::iostreams::tee(closable_device<output>(seq.new_operation(1))));
         ch.push(closable_device<output>(seq.new_operation(2)));
         BOOST_CHECK_NO_THROW(ch.reset());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
@@ -218,7 +217,7 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
+ boost::iostreams::tee(
                 closable_device<bidirectional>(
                     seq.new_operation(1),
                     seq.new_operation(2)
@@ -234,7 +233,7 @@
     {
         operation_sequence seq;
         chain<output> ch;
- ch.push(io::tee(closable_device<seekable>(seq.new_operation(1))));
+ ch.push(boost::iostreams::tee(closable_device<seekable>(seq.new_operation(1))));
         ch.push(closable_device<seekable>(seq.new_operation(2)));
         BOOST_CHECK_NO_THROW(ch.reset());
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
@@ -251,8 +250,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<output>(seq.new_operation(1)),
                     closable_device<output>(seq.new_operation(2))
                 ),
@@ -268,8 +267,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<bidirectional>(
                         seq.new_operation(2),
                         seq.new_operation(3)
@@ -291,8 +290,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<seekable>(seq.new_operation(1)),
                     closable_device<seekable>(seq.new_operation(2))
                 ),
@@ -309,8 +308,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<output>(seq.new_operation(1)),
                     closable_device<output>(seq.new_operation(2))
                 )
@@ -326,8 +325,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<bidirectional>(
                         seq.new_operation(2),
                         seq.new_operation(3)
@@ -349,8 +348,8 @@
         operation_sequence seq;
         chain<output> ch;
         ch.push(
- io::tee(
- io::compose(
+ boost::iostreams::tee(
+ boost::iostreams::compose(
                     closable_filter<seekable>(seq.new_operation(1)),
                     closable_device<seekable>(seq.new_operation(2))
                 )


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