[Boost-bugs] [Boost C++ Libraries] #2395: [filesystem] operations_test regression test fails on MSVC with STDCXX

Subject: [Boost-bugs] [Boost C++ Libraries] #2395: [filesystem] operations_test regression test fails on MSVC with STDCXX
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-10-09 15:27:45


#2395: [filesystem] operations_test regression test fails on MSVC with STDCXX
-----------------------------------------------+----------------------------
 Reporter: Farid Zaripov <faridz_at_[hidden]> | Owner: bemandawes
     Type: Patches | Status: new
Milestone: Boost 1.37.0 | Component: filesystem
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-----------------------------------------------+----------------------------
 The operations_test regression test fails on MSVC with STDCXX:
 http://tinyurl.com/53m6t4

   The reason is checking in libs/filesystem/test/operation_test.cpp, lines
 149-150 :

 {{{
     try
     {
       fs::create_directory( "no-such-dir/foo/bar" );
     }
     catch ( std::runtime_error x )
     {
       exception_thrown = true;
       if ( report_throws ) std::cout << x.what() << std::endl;
       if ( platform == "Windows" && language_id == 0x0409 ) // English
 (United States)
         BOOST_CHECK( std::strcmp( x.what(),
           "boost::filesystem::create_directory" ) == 0 );
     }
 }}}

   Our implementation of the copy ctor (as well as assignment operator) of
 the std::runtime_error class
 copying the resulting string of the what() method of the operand.

   So that in the following code the all three assertions will pass:

 {{{
   boost::system::system_error se(3, boost::system::get_system_category(),
 "boost::filesystem::create_directory");
   std::runtime_error re = se;
   assert (0 != std::strcmp (re.what(),
 "boost::filesystem::create_directory"));
   assert (0 == std::strcmp (re.what(), se.what()));
   assert (0 == std::strcmp (re.what(),
 "boost::filesystem::create_directory: The system cannot find the path
 specified: \"no-such-dir\\foo\\bar\""));
 }}}

   The proposed patch:

 {{{
 Index: libs/filesystem/test/operations_test.cpp
 ===================================================================
 --- libs/filesystem/test/operations_test.cpp (revision 49179)
 +++ libs/filesystem/test/operations_test.cpp (working copy)
 @@ -146,8 +146,9 @@
        exception_thrown = true;
        if ( report_throws ) std::cout << x.what() << std::endl;
        if ( platform == "Windows" && language_id == 0x0409 ) // English
 (United States)
 - BOOST_CHECK( std::strcmp( x.what(),
 - "boost::filesystem::create_directory" ) == 0 );
 + BOOST_CHECK( std::strncmp( x.what(),
 + "boost::filesystem::create_directory",
 + sizeof("boost::filesystem::create_directory")-1 ) == 0 );
      }
      BOOST_CHECK( exception_thrown );

 }}}

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2395>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC