|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55548 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/build libs/filesystem/example libs/filesystem/src libs/filesystem/test libs/filesystem/test/msvc libs/filesystem/test/msvc/convenience_test libs/filesystem/test/msvc/filesystem_dll libs/filesystem/test/msvc/operations_test libs/filesystem/test/msvc/operations_unit_test libs/filesystem/test/msvc/path_test libs/filesystem/test/msvc/path_unit_test
From: bdawes_at_[hidden]
Date: 2009-08-12 10:30:19
Author: bemandawes
Date: 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
New Revision: 55548
URL: http://svn.boost.org/trac/boost/changeset/55548
Log:
Simplify class path overloads and conversions. Simplify and refactor path_traits. Improve test coverage and refactor some tests.
Added:
sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp
- copied, changed from r55374, /sandbox/filesystem-v3/libs/filesystem/src/convert.cpp
sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp (contents, props changed)
sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp (contents, props changed)
Removed:
sandbox/filesystem-v3/libs/filesystem/src/convert.cpp
sandbox/filesystem-v3/libs/filesystem/test/lpath.hpp
sandbox/filesystem-v3/libs/filesystem/test/wide_test.cpp
Text files modified:
sandbox/filesystem-v3/boost/filesystem/config.hpp | 6
sandbox/filesystem-v3/boost/filesystem/convenience.hpp | 46 -
sandbox/filesystem-v3/boost/filesystem/fstream.hpp | 575 ++++--------------
sandbox/filesystem-v3/boost/filesystem/operations.hpp | 28
sandbox/filesystem-v3/boost/filesystem/path.hpp | 416 +++----------
sandbox/filesystem-v3/boost/filesystem/path_traits.hpp | 73 ++
sandbox/filesystem-v3/libs/filesystem/build/Jamfile.v2 | 7
sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp | 18
sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 21
sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 341 +++--------
sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp | 23
sandbox/filesystem-v3/libs/filesystem/test/Jamfile.v2 | 59 -
sandbox/filesystem-v3/libs/filesystem/test/convenience_test.cpp | 96 +-
sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp | 280 ++++----
sandbox/filesystem-v3/libs/filesystem/test/fstream_test.cpp | 97 +--
sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj | 10
sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln | 57 +
sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj | 8
sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj | 8
sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj | 8
sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj | 8
sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj | 8
sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 636 ++++++++++----------
sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp | 50 +
sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp | 1206 +++++++++++++++++++--------------------
sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 276 +++++---
26 files changed, 1949 insertions(+), 2412 deletions(-)
Modified: sandbox/filesystem-v3/boost/filesystem/config.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/config.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/config.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -2,10 +2,10 @@
// Copyright Beman Dawes 2003
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
//--------------------------------------------------------------------------------------//
Modified: sandbox/filesystem-v3/boost/filesystem/convenience.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/convenience.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/convenience.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -27,45 +27,23 @@
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- BOOST_FS_FUNC_STRING extension(const Path& ph)
+ std::string extension(const path & p)
{
- typedef BOOST_FS_TYPENAME Path::string_type string_type;
- string_type filename = ph.filename();
-
- BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.');
- if (n != string_type::npos)
- return filename.substr(n);
- else
- return string_type();
+ return p.extension().string();
}
- BOOST_FS_FUNC_STRING basename(const Path& ph)
+ std::string basename(const path & p)
{
- typedef BOOST_FS_TYPENAME Path::string_type string_type;
- string_type filename = ph.filename();
- BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.');
- return filename.substr(0, n);
+ return p.stem().string();
}
+ path change_extension( const path & p, const path & new_extension )
+ {
+ path new_p( p );
+ new_p.replace_extension( new_extension );
+ return new_p;
+ }
- BOOST_FS_FUNC(Path) change_extension( const Path & ph,
- const BOOST_FS_TYPENAME Path::string_type & new_extension )
- { return ph.parent_path() / (basename(ph) + new_extension); }
-
- inline std::string extension(const path& ph)
- { return extension<path>(ph); }
- inline std::wstring extension(const wpath& ph)
- { return extension<wpath>(ph); }
-
- inline std::string basename(const path& ph)
- { return basename<path>( ph ); }
- inline std::wstring basename(const wpath& ph)
- { return basename<wpath>( ph ); }
-
- inline path change_extension( const path & ph, const std::string& new_ex )
- { return change_extension<path>( ph, new_ex ); }
- inline wpath change_extension( const wpath & ph, const std::wstring& new_ex )
- { return change_extension<wpath>( ph, new_ex ); }
# endif
@@ -184,8 +162,8 @@
system::error_code ec;
m_imp->m_stack.push(
m_imp->m_no_throw
- ? directory_iterator( *m_imp->m_stack.top(), ec )
- : directory_iterator( *m_imp->m_stack.top() ) );
+ ? directory_iterator( m_imp->m_stack.top()->path(), ec )
+ : directory_iterator( m_imp->m_stack.top()->path() ) );
if ( m_imp->m_stack.top() != end_itr )
{
++m_imp->m_level;
Modified: sandbox/filesystem-v3/boost/filesystem/fstream.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/fstream.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/fstream.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,11 +1,11 @@
// boost/filesystem/fstream.hpp ------------------------------------------------------//
-// Copyright Beman Dawes 2002.
-// Use, modification, and distribution is subject to 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)
+// Copyright Beman Dawes 2002
-// See library home page at http://www.boost.org/libs/filesystem
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
//--------------------------------------------------------------------------------------//
@@ -21,467 +21,150 @@
#include <boost/config/abi_prefix.hpp> // must be the last #include
-// NOTE: fstream.hpp for Boost 1.32.0 and earlier supplied workarounds for
-// various compiler problems. They have been removed to ease development of the
-// basic i18n functionality. Once the new interface is stable, the workarounds
-// will be reinstated for any compilers that otherwise can support the rest of
-// the library after internationalization.
-
namespace boost
{
- namespace filesystem
+namespace filesystem
+{
+
+//--------------------------------------------------------------------------------------//
+// basic_filebuf //
+//--------------------------------------------------------------------------------------//
+
+ template < class charT, class traits = std::char_traits<charT> >
+ class basic_filebuf : public std::basic_filebuf<charT,traits>
{
- namespace detail
- {
-//# if defined(BOOST_WINDOWS_API)
-//# if !defined(BOOST_DINKUMWARE_STDLIB) || BOOST_DINKUMWARE_STDLIB < 405
-// // The 8.3 hack:
-// // C++98 does not supply a wchar_t open, so try to get an equivalent
-// // narrow char name based on the short, so-called 8.3, name.
-// // Not needed for Dinkumware 405 and later as they do supply wchar_t open.
-// BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph,
-// std::ios_base::openmode mode ); // true if succeeds
-// BOOST_FILESYSTEM_DECL std::string narrow_path_api(
-// const std::wstring & ph ); // return is empty if fails
-//
-// inline std::string path_proxy( const std::wstring & file_ph,
-// std::ios_base::openmode mode )
-// // Return a non-existant path if cannot supply narrow short path.
-// // An empty path doesn't work because some Dinkumware versions
-// // assert the path is non-empty.
-// {
-// std::string narrow_ph;
-// bool created_file( false );
-// if ( !exists( file_ph )
-// && (mode & std::ios_base::out) != 0
-// && create_file_api( file_ph, mode ) )
-// {
-// created_file = true;
-// }
-// narrow_ph = narrow_path_api( file_ph );
-// if ( narrow_ph.empty() )
-// {
-// if ( created_file ) remove_api( file_ph );
-// narrow_ph = "\x01";
-// }
-// return narrow_ph;
-// }
-//# else
-// // Dinkumware 405 and later does supply wchar_t functions
-// inline const std::wstring & path_proxy( const std::wstring & file_ph,
-// std::ios_base::openmode )
-// { return file_ph; }
-//# endif
-//# endif
-//
-// inline const std::string & path_proxy( const std::string & file_ph,
-// std::ios_base::openmode )
-// { return file_ph; }
-//
- } // namespace detail
+ private: // disallow copying
+ basic_filebuf( const basic_filebuf & );
+ const basic_filebuf & operator=( const basic_filebuf & );
+
+ public:
+ basic_filebuf() {}
+ virtual ~basic_filebuf() {}
- template < class charT, class traits = std::char_traits<charT> >
- class basic_filebuf : public std::basic_filebuf<charT,traits>
+ basic_filebuf<charT,traits> *
+ open( const path & p, std::ios_base::openmode mode )
{
- private: // disallow copying
- basic_filebuf( const basic_filebuf & );
- const basic_filebuf & operator=( const basic_filebuf & );
- public:
- basic_filebuf() {}
- virtual ~basic_filebuf() {}
-
- basic_filebuf<charT,traits> *
- open( const path & p, std::ios_base::openmode mode );
- };
+ return std::basic_filebuf<charT,traits>::open( p.c_str(), mode )
+ ? this : 0;
+ }
+ };
- template < class charT, class traits = std::char_traits<charT> >
- class basic_ifstream : public std::basic_ifstream<charT,traits>
- {
- private: // disallow copying
- basic_ifstream( const basic_ifstream & );
- const basic_ifstream & operator=( const basic_ifstream & );
- public:
- basic_ifstream() {}
+//--------------------------------------------------------------------------------------//
+// basic_ifstream //
+//--------------------------------------------------------------------------------------//
- // use two signatures, rather than one signature with default second
- // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
+ template < class charT, class traits = std::char_traits<charT> >
+ class basic_ifstream : public std::basic_ifstream<charT,traits>
+ {
+ private: // disallow copying
+ basic_ifstream( const basic_ifstream & );
+ const basic_ifstream & operator=( const basic_ifstream & );
- explicit basic_ifstream( const path & p );
+ public:
+ basic_ifstream() {}
- basic_ifstream( const path & p, std::ios_base::openmode mode );
+ // use two signatures, rather than one signature with default second
+ // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
- void open( const path & p );
- void open( const path & p, std::ios_base::openmode mode );
+ explicit basic_ifstream( const path & p )
+ : std::basic_ifstream<charT,traits>( p.c_str(), std::ios_base::in ) {}
- virtual ~basic_ifstream() {}
- };
+ basic_ifstream( const path & p, std::ios_base::openmode mode )
+ : std::basic_ifstream<charT,traits>( p.c_str(), mode | std::ios_base::in ) {}
- template < class charT, class traits = std::char_traits<charT> >
- class basic_ofstream : public std::basic_ofstream<charT,traits>
- {
- private: // disallow copying
- basic_ofstream( const basic_ofstream & );
- const basic_ofstream & operator=( const basic_ofstream & );
- public:
- basic_ofstream() {}
+ void open( const path & p )
+ { std::basic_ifstream<charT,traits>::open( p.c_str(), std::ios_base::in ); }
- // use two signatures, rather than one signature with default second
- // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
+ void open( const path & p, std::ios_base::openmode mode )
+ { std::basic_ifstream<charT,traits>::open( p.c_str(), mode | std::ios_base::in ); }
- explicit basic_ofstream( const path & p );
+ virtual ~basic_ifstream() {}
+ };
- basic_ofstream( const path & p, std::ios_base::openmode mode );
+//--------------------------------------------------------------------------------------//
+// basic_ofstream //
+//--------------------------------------------------------------------------------------//
- void open( const path & p );
- void open( const path & p, std::ios_base::openmode mode );
+ template < class charT, class traits = std::char_traits<charT> >
+ class basic_ofstream : public std::basic_ofstream<charT,traits>
+ {
+ private: // disallow copying
+ basic_ofstream( const basic_ofstream & );
+ const basic_ofstream & operator=( const basic_ofstream & );
- virtual ~basic_ofstream() {}
- };
+ public:
+ basic_ofstream() {}
- template < class charT, class traits = std::char_traits<charT> >
- class basic_fstream : public std::basic_fstream<charT,traits>
- {
- private: // disallow copying
- basic_fstream( const basic_fstream & );
- const basic_fstream & operator=( const basic_fstream & );
- public:
- basic_fstream() {}
-
- // use two signatures, rather than one signature with default second
- // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
-
- explicit basic_fstream( const path & p );
-
- basic_fstream( const path & p, std::ios_base::openmode mode );
-
- void open( const path & p );
- void open( const path & p, std::ios_base::openmode mode );
-
- virtual ~basic_fstream() {}
-
- };
-
- typedef basic_filebuf<char> filebuf;
- typedef basic_ifstream<char> ifstream;
- typedef basic_ofstream<char> ofstream;
- typedef basic_fstream<char> fstream;
-
- typedef basic_filebuf<wchar_t> wfilebuf;
- typedef basic_ifstream<wchar_t> wifstream;
- typedef basic_fstream<wchar_t> wfstream;
- typedef basic_ofstream<wchar_t> wofstream;
-
-// basic_filebuf definitions ---------------------------------------------------------//
+ // use two signatures, rather than one signature with default second
+ // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
- template <class charT, class traits>
- basic_filebuf<charT,traits> *
- basic_filebuf<charT, traits>::open( const path & p,
- std::ios_base::openmode mode )
- {
- return this->open( p.c_str(), mode );
- }
+ explicit basic_ofstream( const path & p )
+ : std::basic_ofstream<charT,traits>( p.c_str(), std::ios_base::out ) {}
+
+ basic_ofstream( const path & p, std::ios_base::openmode mode )
+ : std::basic_ofstream<charT,traits>( p.c_str(), mode | std::ios_base::out ) {}
-//// basic_ifstream definitions --------------------------------------------------------//
-//
-// template <class charT, class traits> template<class Path>
-// basic_ifstream<charT,traits>::basic_ifstream(const Path & file_ph,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_ifstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in ).c_str(), std::ios_base::in ) {}
-//
-// template <class charT, class traits>
-// basic_ifstream<charT,traits>::basic_ifstream( const wpath & file_ph )
-// : std::basic_ifstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in ).c_str(), std::ios_base::in ) {}
-//
-// template <class charT, class traits> template<class Path>
-// basic_ifstream<charT,traits>::basic_ifstream( const Path & file_ph,
-// std::ios_base::openmode mode,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_ifstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in ) {}
-//
-// template <class charT, class traits>
-// basic_ifstream<charT,traits>::basic_ifstream( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_ifstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in ) {}
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_ifstream<charT,traits>::open( const Path & file_ph )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in ).c_str(), std::ios_base::in );
-// }
-//
-// template <class charT, class traits>
-// void basic_ifstream<charT,traits>::open( const wpath & file_ph )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in ).c_str(), std::ios_base::in );
-// }
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_ifstream<charT,traits>::open( const Path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in );
-// }
-//
-// template <class charT, class traits>
-// void basic_ifstream<charT,traits>::open( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in );
-// }
-//
-//// basic_ofstream definitions --------------------------------------------------------//
-//
-// template <class charT, class traits> template<class Path>
-// basic_ofstream<charT,traits>::basic_ofstream(const Path & file_ph,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_ofstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::out ).c_str(), std::ios_base::out ) {}
-//
-// template <class charT, class traits>
-// basic_ofstream<charT,traits>::basic_ofstream( const wpath & file_ph )
-// : std::basic_ofstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::out ).c_str(), std::ios_base::out ) {}
-//
-// template <class charT, class traits> template<class Path>
-// basic_ofstream<charT,traits>::basic_ofstream( const Path & file_ph,
-// std::ios_base::openmode mode,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_ofstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::out ) {}
-//
-// template <class charT, class traits>
-// basic_ofstream<charT,traits>::basic_ofstream( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_ofstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::out ) {}
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_ofstream<charT,traits>::open( const Path & file_ph )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::out ).c_str(), std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_ofstream<charT,traits>::open( const wpath & file_ph )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::out ).c_str(), std::ios_base::out );
-// }
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_ofstream<charT,traits>::open( const Path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_ofstream<charT,traits>::open( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::out );
-// }
-//
-//// basic_fstream definitions ---------------------------------------------------------//
-//
-// template <class charT, class traits> template<class Path>
-// basic_fstream<charT,traits>::basic_fstream(const Path & file_ph,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_fstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in|std::ios_base::out ).c_str(),
-// std::ios_base::in|std::ios_base::out ) {}
-//
-// template <class charT, class traits>
-// basic_fstream<charT,traits>::basic_fstream( const wpath & file_ph )
-// : std::basic_fstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in|std::ios_base::out ).c_str(),
-// std::ios_base::in|std::ios_base::out ) {}
-//
-// template <class charT, class traits> template<class Path>
-// basic_fstream<charT,traits>::basic_fstream( const Path & file_ph,
-// std::ios_base::openmode mode,
-// typename boost::enable_if<is_basic_path<Path> >::type* )
-// : std::basic_fstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {}
-//
-// template <class charT, class traits>
-// basic_fstream<charT,traits>::basic_fstream( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_fstream<charT,traits>(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {}
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_fstream<charT,traits>::open( const Path & file_ph )
-// {
-// std::basic_fstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in|std::ios_base::out ).c_str(),
-// std::ios_base::in|std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_fstream<charT,traits>::open( const wpath & file_ph )
-// {
-// std::basic_fstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// std::ios_base::in|std::ios_base::out ).c_str(),
-// std::ios_base::in|std::ios_base::out );
-// }
-//
-// template <class charT, class traits> template<class Path>
-// typename boost::enable_if<is_basic_path<Path>, void>::type
-// basic_fstream<charT,traits>::open( const Path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_fstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in | std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_fstream<charT,traits>::open( const wpath & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_fstream<charT,traits>::open(
-// detail::path_proxy( file_ph.external_file_string(),
-// mode ).c_str(), mode | std::ios_base::in | std::ios_base::out );
-// }
-//
-//
-//
-//# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
-// template <class charT, class traits>
-// basic_filebuf<charT,traits> *
-// basic_filebuf<charT, traits>::open( const path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// return std::basic_filebuf<charT,traits>::open(
-// file_ph.file_string().c_str(), mode ) == 0 ? 0 : this;
-// }
-//# endif
-//
-// template <class charT, class traits>
-// basic_ifstream<charT,traits>::basic_ifstream( const path & file_ph )
-// : std::basic_ifstream<charT,traits>(
-// file_ph.file_string().c_str(), std::ios_base::in ) {}
-//
-// template <class charT, class traits>
-// basic_ifstream<charT,traits>::basic_ifstream( const path & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_ifstream<charT,traits>(
-// file_ph.file_string().c_str(), mode ) {}
-//
-//# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
-// template <class charT, class traits>
-// void basic_ifstream<charT,traits>::open( const path & file_ph )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// file_ph.file_string().c_str(), std::ios_base::in );
-// }
-//
-// template <class charT, class traits>
-// void basic_ifstream<charT,traits>::open( const path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ifstream<charT,traits>::open(
-// file_ph.file_string().c_str(), mode );
-// }
-//# endif
-//
-// template <class charT, class traits>
-// basic_ofstream<charT,traits>::basic_ofstream( const path & file_ph )
-// : std::basic_ofstream<charT,traits>(
-// file_ph.file_string().c_str(), std::ios_base::out ) {}
-//
-// template <class charT, class traits>
-// basic_ofstream<charT,traits>::basic_ofstream( const path & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_ofstream<charT,traits>(
-// file_ph.file_string().c_str(), mode ) {}
-//
-//# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
-// template <class charT, class traits>
-// void basic_ofstream<charT,traits>::open( const path & file_ph )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// file_ph.file_string().c_str(), std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_ofstream<charT,traits>::open( const path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_ofstream<charT,traits>::open(
-// file_ph.file_string().c_str(), mode );
-// }
-//# endif
-//
-// template <class charT, class traits>
-// basic_fstream<charT,traits>::basic_fstream( const path & file_ph )
-// : std::basic_fstream<charT,traits>(
-// file_ph.file_string().c_str(),
-// std::ios_base::in|std::ios_base::out ) {}
-//
-//
-// template <class charT, class traits>
-// basic_fstream<charT,traits>::basic_fstream( const path & file_ph,
-// std::ios_base::openmode mode )
-// : std::basic_fstream<charT,traits>(
-// file_ph.file_string().c_str(), mode ) {}
-//
-//# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
-// template <class charT, class traits>
-// void basic_fstream<charT,traits>::open( const path & file_ph )
-// {
-// std::basic_fstream<charT,traits>::open(
-// file_ph.file_string().c_str(), std::ios_base::in|std::ios_base::out );
-// }
-//
-// template <class charT, class traits>
-// void basic_fstream<charT,traits>::open( const path & file_ph,
-// std::ios_base::openmode mode )
-// {
-// std::basic_fstream<charT,traits>::open(
-// file_ph.file_string().c_str(), mode );
-// }
-//# endif
- } // namespace filesystem
+ void open( const path & p )
+ { std::basic_ofstream<charT,traits>::open( p.c_str(), std::ios_base::out ); }
+
+ void open( const path & p, std::ios_base::openmode mode )
+ { std::basic_ofstream<charT,traits>::open( p.c_str(), mode | std::ios_base::out ); }
+
+ virtual ~basic_ofstream() {}
+ };
+
+//--------------------------------------------------------------------------------------//
+// basic_fstream //
+//--------------------------------------------------------------------------------------//
+
+ template < class charT, class traits = std::char_traits<charT> >
+ class basic_fstream : public std::basic_fstream<charT,traits>
+ {
+ private: // disallow copying
+ basic_fstream( const basic_fstream & );
+ const basic_fstream & operator=( const basic_fstream & );
+
+ public:
+ basic_fstream() {}
+
+ // use two signatures, rather than one signature with default second
+ // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
+
+ explicit basic_fstream( const path & p )
+ : std::basic_fstream<charT,traits>( p.c_str(),
+ std::ios_base::in | std::ios_base::out ) {}
+
+ basic_fstream( const path & p, std::ios_base::openmode mode )
+ : std::basic_fstream<charT,traits>( p.c_str(),
+ mode | std::ios_base::in | std::ios_base::out ) {}
+
+ void open( const path & p )
+ { std::basic_fstream<charT,traits>::open( p.c_str(),
+ std::ios_base::in | std::ios_base::out ); }
+
+ void open( const path & p, std::ios_base::openmode mode )
+ { std::basic_fstream<charT,traits>::open( p.c_str(),
+ mode | std::ios_base::in | std::ios_base::out ); }
+
+ virtual ~basic_fstream() {}
+
+ };
+
+//--------------------------------------------------------------------------------------//
+// typedefs //
+//--------------------------------------------------------------------------------------//
+
+ typedef basic_filebuf<char> filebuf;
+ typedef basic_ifstream<char> ifstream;
+ typedef basic_ofstream<char> ofstream;
+ typedef basic_fstream<char> fstream;
+
+ typedef basic_filebuf<wchar_t> wfilebuf;
+ typedef basic_ifstream<wchar_t> wifstream;
+ typedef basic_fstream<wchar_t> wfstream;
+ typedef basic_ofstream<wchar_t> wofstream;
+
+} // namespace filesystem
} // namespace boost
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -8,7 +8,7 @@
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
//--------------------------------------------------------------------------------------//
/*
@@ -179,10 +179,16 @@
// in alphabetical order, unless otherwise noted //
// //
//--------------------------------------------------------------------------------------//
-
BOOST_FILESYSTEM_DECL // declaration must precede complete()
path initial_path( system::error_code & ec = throws() );
+# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
+ // support legacy initial_path<...>()
+ template <class Path>
+ path initial_path( system::error_code & ec = throws() )
+ { return initial_path( ec ); }
+# endif
+
BOOST_FILESYSTEM_DECL
path complete( const path & p, const path & base = initial_path() );
@@ -312,8 +318,9 @@
file_status status( system::error_code & ec = throws() ) const;
file_status symlink_status( system::error_code & ec = throws() ) const;
- // conversion simplifies the most common use of directory_entry
- operator const boost::filesystem::path &() const { return m_path; }
+ //// conversion simplifies the most common use of directory_entry
+ // Removed; poor design + too likely to conflict with path v3 constructor templates
+ //operator const boost::filesystem::path &() const { return m_path; }
//# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
// // deprecated functions preserve common use cases in legacy code
@@ -338,6 +345,19 @@
}; // directory_entry
+//// dispatch directory_entry supplied here rather than in
+//// <boost/filesystem/path_traits.hpp>, thus avoiding header circularity.
+//// test cases are in operations_unit_test.cpp
+//
+//namespace path_traits
+//{
+// template <class U> inline
+// void dispatch( const directory_entry & de, U & to, const codecvt_type & )
+// {
+// to = de.path().source();
+// }
+//} // namespace path_traits
+
//--------------------------------------------------------------------------------------//
// //
// directory_iterator helpers //
Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -3,12 +3,12 @@
// Copyright Beman Dawes 2002-2005, 2008
// Copyright Vladimir Prus 2002
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
-// basic_path's stem(), extension(), and replace_extension() are based on
+// path::stem(), extension(), and replace_extension() are based on
// basename(), extension(), and change_extension() from the original
// filesystem/convenience.hpp header by Vladimir Prus.
@@ -18,7 +18,7 @@
* Document breaking changes, provide workarounds where possible.
* Windows, POSIX, conversions for char16_t, char32_t for supporting compilers.
- * Need an error category for codecvt errors. Seed path.cpp detail::append, etc.
+ * Move semantics and other C++0x features.
* Add Alternate Data Stream test cases. See http://en.wikipedia.org/wiki/NTFS Features.
* test case: relational on paths differing only in trailing separator. rationale?
* Behavior of root_path() has been changed. Change needs to be propagated to trunk.
@@ -31,16 +31,17 @@
* reference.html: operator /= is underspecified as to when a "/" is appended, and
whether a '/' or '\' is appended.
* path.cpp: locale and detail append/convert need error handling.
- * path_unit_test needs to probe error handling, verify exceptions are thrown when
- requested.
* Provide the name check functions for more character types? Templatize?
* Why do native() and generic() return paths rather than const strings/string refs?
Either change or document rationale.
+ * Use BOOST_DELETED, BOOST_DEFAULTED, where appropriate.
+ * imbue/codecvt too complex. Move to path_traits? Refactor?
+ * path_unit_test, x /= x test failing, commented out. Fix. See test_appends.
+ * The name source() is obscure. Come up with a more explicit name.
+ * Add test for scoped_path_locale.
Design Questions
- * Could sentinel_iterator be used to reduce number of overloads?
- * Should append be changed to convert, and use back_inserter to append?
* Should path_locale use thread local storage?
* Will locale overloads be needed in practice?
@@ -56,7 +57,7 @@
No. KISS. basic_string<char> is special because it is the predominent
use case. w (and other) flavors can be added later.
* Should UDT's be supported? Yes. Easy to do and pretty harmless.
- * What to do about Cygwin and other environments that don't support wchar_t?
+ * Remove all support for environments that don't support wstring.
* Should path iteration to a separator result in:
-- the actual separator used
-- the preferred separator
@@ -69,13 +70,14 @@
#define BOOST_FILESYSTEM_PATH_HPP
#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path_traits.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/iterator/iterator_facade.hpp>
-#include <boost/utility/enable_if.hpp>
+//#include <boost/utility/enable_if.hpp>
#include <boost/throw_exception.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/type_traits/is_same.hpp>
+//#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <string>
#include <cstring>
@@ -136,141 +138,6 @@
String m_source;
};
-//--------------------------------------------------------------------------------------//
-// //
-// path_traits //
-// //
-// Specializations are provided for char, wchar_t, char16_t, and char32_t value //
-// types and their related string and iterator types. //
-// //
-// Users are permitted to add specializations for additional types. //
-// //
-//--------------------------------------------------------------------------------------//
-
-namespace path_traits
-{
-
-#ifdef BOOST_WINDOWS_API
- typedef std::wstring string_type; // path internal representation type
-#else
- typedef std::string string_type;
-#endif
-
- typedef string_type::value_type value_type;
-
- template< class I > struct is_iterator { static const bool value = false; };
- template< class C > struct is_container { static const bool value = false; };
-
- template< class charT > // specialization optional
- inline void append( const charT * begin, // requires: null termination
- string_type & target, system::error_code & ec )
- {
- path_traits::append<charT>( begin, static_cast<const charT *>(0), target, ec );
- }
-
- template< class charT > // specialization required
- void append( const charT * begin, const charT * end,
- string_type & target, system::error_code & ec );
-
- template< class String > // specialization required
- String convert( const string_type & source, system::error_code & ec );
-
-} // namespace path_traits
-
- //------------------------------------------------------------------------------------//
- // implementation details //
- //------------------------------------------------------------------------------------//
-
-namespace detail
-{
-#ifdef BOOST_WINDOWS_API
- typedef std::string interface_string_type;
-#else
- typedef std::wstring interface_string_type;
-#endif
-
- typedef interface_string_type::value_type interface_value_type;
-
- BOOST_FILESYSTEM_DECL
- void append( const interface_value_type * begin,
- const interface_value_type * end, // 0 for null terminated MBCS
- path_traits::string_type & target, system::error_code & ec );
-
- BOOST_FILESYSTEM_DECL
- interface_string_type convert_to_string( const path_traits::string_type & src,
- system::error_code & ec );
-
-} // namespace detail
-
- //------------------------------------------------------------------------------------//
- // path_traits specializations //
- //------------------------------------------------------------------------------------//
-
-namespace path_traits
-{
- template<> struct is_iterator<const char *> { static const bool value = true; };
- template<> struct is_iterator<char *> { static const bool value = true; };
- template<> struct is_iterator<std::string::iterator> { static const bool value = true; };
- template<> struct is_iterator<std::string::const_iterator> { static const bool value = true; };
- template<> struct is_container<std::string> { static const bool value = true; };
-
- template<> struct is_iterator<const wchar_t *> { static const bool value = true; };
- template<> struct is_iterator<wchar_t *> { static const bool value = true; };
- template<> struct is_iterator<std::wstring::iterator> { static const bool value = true; };
- template<> struct is_iterator<std::wstring::const_iterator> { static const bool value = true; };
- template<> struct is_container<std::wstring> { static const bool value = true; };
-
- template<>
- inline void append<string_type::value_type>( const string_type::value_type * begin,
- const string_type::value_type * end, string_type & target, system::error_code & ec )
- {
- target.assign( begin, end ); // TODO: what if throws() bad_alloc?
- if ( &ec != &throws() ) ec.clear();
- }
-
- template<>
- inline void append<string_type::value_type>( const string_type::value_type * begin,
- string_type & target, system::error_code & ec )
- {
- target += begin; // TODO: what if throws() bad_alloc?
- if ( &ec != &throws() ) ec.clear();
- }
-
- template<>
- inline string_type convert<string_type>( const string_type & s, system::error_code & ec )
- {
- if ( &ec != &throws() ) ec.clear();
- return s;
- }
-
- template<>
- inline void append<detail::interface_value_type>( const detail::interface_value_type * begin,
- const detail::interface_value_type * end,
- string_type & target, system::error_code & ec )
- {
- detail::append( begin, end, target, ec );
- }
-
- template<>
- inline void append<detail::interface_value_type>( const detail::interface_value_type * begin,
- string_type & target, system::error_code & ec )
- {
- detail::append( begin, 0, target, ec );
- }
-
- template<>
- inline detail::interface_string_type convert<detail::interface_string_type>( const string_type & s,
- system::error_code & ec )
- {
- return detail::convert_to_string( s, ec );
- }
-
-# ifdef BOOST_FILESYSTEM_CPP0X_CHAR_TYPES
- ...
-# endif
-
-} // namespace path_traits
-
//------------------------------------------------------------------------------------//
// //
// class path //
@@ -283,13 +150,15 @@
// string_type is the std::basic_string type corresponding to the character
// type for paths used by the native operating system API.
- //
- // Thus string_type is std::string for POSIX and std::wstring for Windows.
- // value_type is char for POSIX and wchar_t for Windows.
- typedef path_traits::string_type string_type;
- typedef string_type::value_type value_type;
- typedef string_type::size_type size_type;
+#ifdef BOOST_WINDOWS_API
+ typedef std::wstring string_type; // internal representation type
+#else
+ typedef std::string string_type;
+#endif
+ typedef string_type::value_type value_type;
+ typedef string_type::size_type size_type;
+ typedef path_traits::codecvt_type codecvt_type;
// ----- character encoding conversions -----
@@ -348,87 +217,56 @@
//
// ************************************************************************
- // ----- constructors -----
-
- path(){} // #1
+ // Supported source arguments: half-open iterator range, container, c-array,
+ // and single pointer to null terminated string.
- path( const path & p ) : m_path(p.m_path) {} // #2
+ // All source arguments except pointers to null terminated byte strings support
+ // multi-byte character string, which may have embedded nulls. Embedded null
+ // support is required for some Asian languages on Windows.
- // construct from null terminated sequence
- template< class InputIterator >
- path( InputIterator begin,
- system::error_code & ec = boost::throws(),
- typename boost::enable_if<path_traits::is_iterator<InputIterator> >::type* dummy=0 ) // #3
- { m_append( begin, m_path, ec ); }
-
- // construct from (potentially) multi-byte character string, which may have embedded
- // nulls. Embedded null support is required for some Asian languages on Windows.
- template< class ForwardIterator >
- path( ForwardIterator begin, ForwardIterator end,
- system::error_code & ec = boost::throws() ) // #4
- { m_append( begin, end, m_path, ec ); }
-
- // construct from container of (potentially) multi-byte chars, which may have embedded
- // nulls. Embedded null support is required for some Asian languages on Windows.
- template< class Container >
- path( const Container & ctr,
- system::error_code & ec = boost::throws(),
- typename boost::enable_if<path_traits::is_container<Container> >::type* dummy=0 ) // #5
- { m_append( ctr.begin(), ctr.end(), m_path, ec ); }
+ // ----- constructors -----
+ path(){}
- // ----- assignments -----
+ path( const path & p ) : m_path(p.m_path) {}
- path & operator=( const path & p ) // #1
- {
- m_path = p.m_path;
- return *this;
+ template <class ContiguousIterator>
+ path( ContiguousIterator begin, ContiguousIterator end )
+ {
+ if ( begin != end )
+ path_traits::convert( &*begin, &*begin+std::distance(begin, end),
+ m_path, codecvt() );
}
- template< class InputIterator >
- typename boost::enable_if<path_traits::is_iterator<InputIterator>, path &>::type
- operator=( InputIterator begin ) // #2
+ template <class Pathable>
+ path( Pathable const & pathable )
{
- m_path.clear();
- m_append( begin, m_path, boost::throws() );
- return *this;
+ path_traits::dispatch( pathable, m_path, codecvt() );
}
- template< class InputIterator >
- typename boost::enable_if<path_traits::is_iterator<InputIterator>, path &>::type
- assign( InputIterator begin,
- system::error_code & ec = boost::throws() ) // #3
+ // ----- assignments -----
+
+ path & operator=( const path & p )
{
- m_path.clear();
- m_append( begin, m_path, ec );
+ m_path = p.m_path;
return *this;
}
- template< class FowardIterator >
- path & assign( FowardIterator begin, FowardIterator end,
- system::error_code & ec = boost::throws() ) // #4
+ template <class ContiguousIterator>
+ path & assign( ContiguousIterator begin, ContiguousIterator end )
{
m_path.clear();
- m_append( begin, end, m_path, ec );
+ if ( begin != end )
+ path_traits::convert( &*begin, &*begin+std::distance(begin, end),
+ m_path, codecvt() );
return *this;
}
-
- template< class Container >
- typename boost::enable_if<path_traits::is_container<Container>, path &>::type
- operator=( const Container & ctr ) // #5
- {
- m_path.clear();
- m_append( ctr.begin(), ctr.end(), m_path, boost::throws() );
- return *this;
- }
-
- template< class Container >
- typename boost::enable_if<path_traits::is_container<Container>, path &>::type
- assign( const Container & ctr,
- system::error_code & ec = boost::throws() ) // #6
- {
+
+ template <class Pathable>
+ path & operator=( Pathable const & range )
+ {
m_path.clear();
- m_append( ctr.begin(), ctr.end(), m_path, ec );
+ path_traits::dispatch( range, m_path, codecvt() );
return *this;
}
@@ -437,57 +275,28 @@
// if a separator is added, it is the preferred separator for the platform;
// slash for POSIX, backslash for Windows
- path & operator/=( const path & p ) // #1
+ path & operator/=( const path & p )
{
append_separator_if_needed_();
m_path += p.m_path;
return *this;
}
- template< class InputIterator >
- typename boost::enable_if<path_traits::is_iterator<InputIterator>, path &>::type
- operator/=( InputIterator begin ) // #2
- {
+ template <class ContiguousIterator>
+ path & append( ContiguousIterator begin, ContiguousIterator end )
+ {
append_separator_if_needed_();
- m_append( begin, m_path, boost::throws() );
+ if ( begin != end )
+ path_traits::convert( &*begin, &*begin+std::distance(begin, end),
+ m_path, codecvt() );
return *this;
}
- template< class InputIterator >
- typename boost::enable_if<path_traits::is_iterator<InputIterator>, path &>::type
- append( InputIterator begin,
- system::error_code & ec = boost::throws() ) // #3
+ template <class Pathable>
+ path & operator/=( Pathable const & range )
{
append_separator_if_needed_();
- m_append( begin, m_path, ec );
- return *this;
- }
-
- template< class FowardIterator >
- path & append( FowardIterator begin, FowardIterator end,
- system::error_code & ec = boost::throws() ) // #4
- {
- append_separator_if_needed_();
- m_append( begin, end, m_path, ec );
- return *this;
- }
-
- template< class Container >
- typename boost::enable_if<path_traits::is_container<Container>, path &>::type
- operator/=( const Container & ctr ) // #5
- {
- append_separator_if_needed_();
- m_append( ctr.begin(), ctr.end(), m_path, boost::throws() );
- return *this;
- }
-
- template< class Container >
- typename boost::enable_if<path_traits::is_container<Container>, path &>::type
- append( const Container & ctr,
- system::error_code & ec = boost::throws() ) // #6
- {
- append_separator_if_needed_();
- m_append( ctr.begin(), ctr.end(), m_path, ec );
+ path_traits::dispatch( range, m_path, codecvt() );
return *this;
}
@@ -496,9 +305,15 @@
void clear() { m_path.clear(); }
void swap( path & rhs ) { m_path.swap( rhs.m_path ); }
path & remove_filename();
- path & replace_extension( const path & source = path() );
+ path & replace_extension( const path & new_extension = path() );
+//# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
+// path & normalize() { return m_normalize(); }
+//# endif
// ----- observers -----
+
+ std::size_t size() const { return m_path.size(); }
+
// For operating systems that format file paths differently than directory
// paths, return values from observers are formatted as file names unless there
@@ -516,18 +331,24 @@
// generic: backslashes are converted to slashes
// source: slashes and backslashes are not modified
- template< class T >
- T string( system::error_code & ec = boost::throws() ) const // source (i.e. original) format
- {
- return path_traits::convert<T>( m_path, ec );
- }
+// template< class T >
+// T string( system::error_code & ec = boost::throws() ) const // source (i.e. original) format
+// {
+// return path_traits::convert<T>( m_path, ec );
+// }
# ifdef BOOST_WINDOWS_API
// source format
- const std::string string( system::error_code & ec = boost::throws() ) const { return detail::convert_to_string( m_path, ec ); }
- const std::wstring & wstring() const { return m_path; }
- const std::wstring & wstring( system::error_code & ec ) const { ec.clear(); return m_path; }
+ const std::string string() const
+ {
+ std::string tmp;
+ if ( !m_path.empty() )
+ path_traits::convert( &*m_path.begin(), &*m_path.begin()+m_path.size(),
+ tmp, codecvt() );
+ return tmp;
+ }
+ const std::wstring & wstring() const { return m_path; }
# else // BOOST_POSIX_API
@@ -556,7 +377,7 @@
// c_str() returns a C string suitable for calls to the operating system API.
// On POSIX and Windows that's source format, on some OS's it may be native format.
- const value_type * c_str() const { return m_path.c_str(); }
+ const value_type * c_str() const { return m_path.c_str(); }
// ----- decomposition -----
@@ -588,10 +409,16 @@
# endif
}
- // ----- locale -----
+ // ----- imbue -----
static std::locale imbue( const std::locale & loc );
- static std::locale imbue( const std::locale & loc, system::error_code & ec );
+
+ // ----- codecvt -----
+
+ static const codecvt_type & codecvt()
+ {
+ return *wchar_t_codecvt_facet();
+ }
// ----- iterators -----
@@ -601,43 +428,24 @@
iterator begin() const;
iterator end() const;
- //------------------------------------------------------------------------------------//
- // class path private members //
- //------------------------------------------------------------------------------------//
+//--------------------------------------------------------------------------------------//
+// class path private members //
+//--------------------------------------------------------------------------------------//
private:
-
- // m_path has the type, encoding, and format required by the native
- // operating system. Thus for POSIX and Windows there is no conversion for
- // passing m_path.c_str() to the O/S API or when obtaining a path from the
- // O/S API. POSIX encoding is unspecified other than for dot and slash
- // characters; POSIX just treats paths as a sequence of bytes. Windows
- // encoding is UCS-2 or UTF-16 depending on the version.
-
+/*
+ m_path has the type, encoding, and format required by the native
+ operating system. Thus for POSIX and Windows there is no conversion for
+ passing m_path.c_str() to the O/S API or when obtaining a path from the
+ O/S API. POSIX encoding is unspecified other than for dot and slash
+ characters; POSIX just treats paths as a sequence of bytes. Windows
+ encoding is UCS-2 or UTF-16 depending on the version.
+*/
string_type m_path; // Windows: as input; backslashes NOT converted to slashes,
// slashes NOT converted to backslashes
- // These helpers factor out common code and convert iterators to pointers.
- template< class InputIterator >
- inline void m_append( InputIterator begin,
- string_type & target, system::error_code & ec )
- {
- BOOST_ASSERT( &*begin );
- path_traits::append( &*begin, target, ec );
- }
-
- template< class FowardIterator >
- inline void m_append( FowardIterator begin, FowardIterator end,
- string_type & target, system::error_code & ec )
- {
- if ( begin == end ) return;
- BOOST_ASSERT( &*begin );
- path_traits::append( &*begin,
- &*begin + std::distance( begin, end ), // avoid dereference of end iterator
- target, ec );
- }
-
void append_separator_if_needed_();
+ //path & m_normalize();
// Was qualified; como433beta8 reports:
// warning #427-D: qualified name is not allowed in member declaration
@@ -650,10 +458,13 @@
// see path::iterator::increment/decrement comment below
static void m_path_iterator_increment( path::iterator & it );
static void m_path_iterator_decrement( path::iterator & it );
+
+ static const codecvt_type *& wchar_t_codecvt_facet();
+
}; // class path
//------------------------------------------------------------------------------------//
- // class path::iterator //
+ // class path::iterator //
//------------------------------------------------------------------------------------//
class path::iterator
@@ -697,17 +508,16 @@
class scoped_path_locale
{
public:
- scoped_path_locale( const std::locale & loc,
- system::error_code & ec = boost::throws() )
+ scoped_path_locale( const std::locale & loc )
: m_saved_locale(loc)
{
- path::imbue( loc, ec );
+ path::imbue( loc );
}
~scoped_path_locale() // never throws()
{
- system::error_code ec;
- path::imbue( m_saved_locale, ec );
+ try { path::imbue( m_saved_locale ); }
+ catch ( ... ) {}
};
private:
Modified: sandbox/filesystem-v3/boost/filesystem/path_traits.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path_traits.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path_traits.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -7,6 +7,43 @@
// Library home page: http://www.boost.org/libs/filesystem
+/*
+ FAQ
+
+ Why are there no error_code & arguments?
+ ----------------------------------------
+
+ error_code & arguments add considerably to the surface area of the interface, yet
+ appear to be of limited usefulness. They have not been requested by users; the need
+ for filesystem error reporting via error_code seems limited to operational failures
+ rather than path failures.
+
+ error_code & arguments double the number of signatures, since for efficiency the
+ use of a default throws() argument is not desirable.
+
+ Errors in path conversions only occur if the source and target value types differ AND
+ the target encoding can't represent a character present in the source. The only
+ commonplace case is when directory iteration on Windows encounters a file name that
+ can't be represented in a char encoding.
+
+ Workarounds (such as pre-scanning for characters that can't be encoded) appear
+ resonable.
+
+ Why are there no const codecvt_type & arguments?
+ ------------------------------------------------
+
+ To hold down the size of the class path interface. Per function codecvt facets
+ just aren't needed very often in practice.
+
+ An RAII idiom can be used to ensure push/pop behavior as an alternative.
+
+ Note that codecvt() is passed to the path_traits::convert functions, since that
+ decouples the convert functions from class path.
+
+ const codecvt_type & can be added later, but once added, they can never be removed
+ since that would break user code.
+*/
+
#ifndef BOOST_FILESYSTEM_PATH_TRAITS_HPP
#define BOOST_FILESYSTEM_PATH_TRAITS_HPP
@@ -15,13 +52,45 @@
#include <iterator>
#include <boost/assert.hpp>
#include <boost/system/error_code.hpp>
+// #include <iostream> //**** comment me out ****
#include <boost/config/abi_prefix.hpp> // must be the last #include
-namespace boost { namespace filesystem { namespace path_traits {
+namespace boost { namespace filesystem {
+
+ class directory_entry;
+namespace path_traits {
+
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
+ // Pathable dispatchers
+
+ template <class Container, class U> inline
+ void dispatch( const Container & c, U & to, const codecvt_type & cvt )
+ {
+// std::cout << "dispatch() container\n";
+ if ( c.size() )
+ convert( &*c.begin(), &*c.begin() + c.size(), to, cvt );
+ }
+
+ template <class T, class U> inline
+ void dispatch( T * const & c_str, U & to, const codecvt_type & cvt )
+ {
+// std::cout << "dispatch() const T *\n";
+ convert( c_str, to, cvt );
+ }
+
+ template <typename T, size_t N, class U> inline
+ void dispatch( T (&array)[N], U & to, const codecvt_type & cvt ) // T, N, U deduced
+ {
+// std::cout << "dispatch() array, N=" << N << "\n";
+ convert( array, array + N - 1, to, cvt );
+ }
+
+ BOOST_FILESYSTEM_DECL
+ void dispatch( const directory_entry & de, std::wstring & to, const codecvt_type & );
+
// value types differ ---------------------------------------------------------------//
//
// A from_end argument of 0 is less efficient than a known end, so use only if needed
@@ -100,4 +169,6 @@
}}} // namespace boost::filesystem::path_traits
+#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+
#endif // BOOST_FILESYSTEM_PATH_TRAITS_HPP
Modified: sandbox/filesystem-v3/libs/filesystem/build/Jamfile.v2
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/build/Jamfile.v2 (original)
+++ sandbox/filesystem-v3/libs/filesystem/build/Jamfile.v2 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,4 +1,3 @@
-
# Boost Filesystem Library Build Jamfile
# (C) Copyright Beman Dawes 2002-2006
@@ -16,15 +15,15 @@
;
SOURCES =
- operations path portability utf8_codecvt_facet ;
+ operations path path_traits portability utf8_codecvt_facet windows_file_codecvt ;
lib boost_filesystem
:
$(SOURCES).cpp
../../system/build//boost_system
:
- <link>shared:<define>BOOST_ALL_DYN_LINK=1 # tell source we're building dll's
- <link>static:<define>BOOST_All_STATIC_LINK=1 # tell source we're building static lib's
+ <link>shared:<define>BOOST_FILESYSTEM_DYN_LINK=1
+ <link>static:<define>BOOST_FILESYSTEM_STATIC_LINK=1
:
:
;
Modified: sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -20,12 +20,10 @@
int main( int argc, char* argv[] )
{
- boost::progress_timer t( std::clog );
-
- fs::path full_path( fs::initial_path<fs::path>() );
+ fs::path p( fs::initial_path() );
if ( argc > 1 )
- full_path = fs::system_complete( fs::path( argv[1] ) );
+ p = fs::system_complete( argv[1] );
else
std::cout << "\nusage: simple_ls [path]" << std::endl;
@@ -34,18 +32,18 @@
unsigned long other_count = 0;
unsigned long err_count = 0;
- if ( !fs::exists( full_path ) )
+ if ( !fs::exists( p ) )
{
- std::cout << "\nNot found: " << full_path.file_string() << std::endl;
+ std::cout << "\nNot found: " << p.string() << std::endl;
return 1;
}
- if ( fs::is_directory( full_path ) )
+ if ( fs::is_directory( p ) )
{
std::cout << "\nIn directory: "
- << full_path.directory_string() << "\n\n";
+ << p.string() << "\n\n";
fs::directory_iterator end_iter;
- for ( fs::directory_iterator dir_itr( full_path );
+ for ( fs::directory_iterator dir_itr( p );
dir_itr != end_iter;
++dir_itr )
{
@@ -81,7 +79,7 @@
}
else // must be a file
{
- std::cout << "\nFound: " << full_path.file_string() << "\n";
+ std::cout << "\nFound: " << p.string() << "\n";
}
return 0;
}
Deleted: sandbox/filesystem-v3/libs/filesystem/src/convert.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/convert.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
+++ (empty file)
@@ -1,180 +0,0 @@
-// filesystem convert.cpp ------------------------------------------------------------//
-
-// Copyright Beman Dawes 2008, 2009
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// Library home page: http://www.boost.org/libs/filesystem
-
-#include <boost/filesystem/detail/convert.hpp>
-#include <boost/filesystem/config.hpp>
-#include <boost/scoped_array.hpp>
-#include <cstring> // for strlen
-#include <cwchar> // for wcslen
-
-//--------------------------------------------------------------------------------------//
-// configuration //
-//--------------------------------------------------------------------------------------//
-
-#ifndef BOOST_FILESYSTEM_CODECVT_BUF_SIZE
-# define BOOST_FILESYSTEM_CODECVT_BUF_SIZE 256
-#endif
-
-namespace {
-
- const std::size_t default_codecvt_buf_size = BOOST_FILESYSTEM_CODECVT_BUF_SIZE;
-
-
-//--------------------------------------------------------------------------------------//
-// //
-// The public convert() functions do buffer management, and then forward to the //
-// convert_aux() functions for the actual call to the codecvt facet. //
-// //
-//--------------------------------------------------------------------------------------//
-
-//--------------------------------------------------------------------------------------//
-// convert_aux const char * to wstring //
-//--------------------------------------------------------------------------------------//
-
- void convert_aux(
- const char * from,
- const char * from_end,
- wchar_t * to, wchar_t * to_end,
- std::wstring & target,
- const boost::filesystem::codecvt_type & cvt )
- {
- //std::cout << std::hex
- // << " from=" << std::size_t(from)
- // << " from_end=" << std::size_t(from_end)
- // << " to=" << std::size_t(to)
- // << " to_end=" << std::size_t(to_end)
- // << std::endl;
-
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const char * from_next;
- wchar_t * to_next;
-
- std::codecvt_base::result res;
-
- if ( (res=cvt.in( state, from, from_end, from_next,
- to, to_end, to_next )) != std::codecvt_base::ok )
- {
- //std::cout << " result is " << static_cast<int>(res) << std::endl;
- assert( 0 && "append error handling not implemented yet" );
- throw "append error handling not implemented yet";
- }
- target.append( to, to_next );
- }
-
-//--------------------------------------------------------------------------------------//
-// convert_aux const wchar_t * to string //
-//--------------------------------------------------------------------------------------//
-
- void convert_aux(
- const wchar_t * from,
- const wchar_t * from_end,
- char * to, char * to_end,
- std::string & target,
- const boost::filesystem::codecvt_type & cvt )
- {
- //std::cout << std::hex
- // << " from=" << std::size_t(from)
- // << " from_end=" << std::size_t(from_end)
- // << " to=" << std::size_t(to)
- // << " to_end=" << std::size_t(to_end)
- // << std::endl;
-
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const wchar_t * from_next;
- char * to_next;
-
- std::codecvt_base::result res;
-
- if ( (res=cvt.out( state, from, from_end, from_next,
- to, to_end, to_next )) != std::codecvt_base::ok )
- {
- //std::cout << " result is " << static_cast<int>(res) << std::endl;
- assert( 0 && "append error handling not implemented yet" );
- throw "append error handling not implemented yet";
- }
- target.append( to, to_next );
- }
-
-} // unnamed namespace
-
-namespace boost { namespace filesystem { namespace detail {
-
-//--------------------------------------------------------------------------------------//
-// convert const char * to wstring //
-//--------------------------------------------------------------------------------------//
-
- BOOST_FILESYSTEM_DECL
- void convert( const char * from,
- const char * from_end, // 0 for null terminated MBCS
- std::wstring & to,
- const codecvt_type & cvt )
- {
- BOOST_ASSERT( from );
-
- if ( !from_end ) // null terminated
- {
- from_end = from + std::strlen( from );
- }
-
- if ( from == from_end ) return;
-
- std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK
-
- // dynamically allocate a buffer only if source is unusually large
- if ( buf_size > default_codecvt_buf_size )
- {
- boost::scoped_array< wchar_t > buf( new wchar_t [buf_size] );
- convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt );
- }
- else
- {
- wchar_t buf[default_codecvt_buf_size];
- convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt );
- }
- }
-
-//--------------------------------------------------------------------------------------//
-// convert const wchar_t * to string //
-//--------------------------------------------------------------------------------------//
-
- BOOST_FILESYSTEM_DECL
- void convert( const wchar_t * from,
- const wchar_t * from_end, // 0 for null terminated MBCS
- std::string & to,
- const codecvt_type & cvt )
- {
- BOOST_ASSERT( from );
-
- if ( !from_end ) // null terminated
- {
- from_end = from + std::wcslen( from );
- }
-
- if ( from == from_end ) return;
-
- // The codecvt length functions may not be implemented, and I don't really
- // understand them either. Thus this code is just a guess; if it turns
- // out the buffer is too small then an error will be reported and the code
- // will have to be fixed.
- std::size_t buf_size = (from_end - from) * 4; // perhaps too large, but that's OK
- buf_size += 4; // encodings like shift-JIS need some prefix space
-
- // dynamically allocate a buffer only if source is unusually large
- if ( buf_size > default_codecvt_buf_size )
- {
- boost::scoped_array< char > buf( new char [buf_size] );
- convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt );
- }
- else
- {
- char buf[default_codecvt_buf_size];
- convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt );
- }
- }
-}}} // namespace boost::filesystem::detail
Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -206,7 +206,7 @@
else
{ // error
if ( &ec == &throws() )
- throw_exception( filesystem_error( message,
+ throw/*_exception*/( filesystem_error( message,
p, BOOST_ERRNO, system_category ) );
else
ec.assign( BOOST_ERRNO, system_category );
@@ -1326,7 +1326,11 @@
path system_complete( const path & p, system::error_code & ec )
{
# ifdef BOOST_WINDOWS_API
- if ( p.empty() ) return p;
+ if ( p.empty() )
+ {
+ if ( &ec != &throws() ) ec.clear();
+ return p;
+ }
wchar_t buf[buf_size];
wchar_t * pfn;
std::size_t len = get_full_path_name( p, buf_size, buf, &pfn );
@@ -1335,7 +1339,7 @@
return path();
if ( len < buf_size ) // len does not include null termination character
- return path( buf );
+ return path( &buf[0] );
boost::scoped_array<wchar_t> big_buf( new wchar_t[len] );
@@ -1424,6 +1428,17 @@
return m_symlink_status;
}
+// dispatch directory_entry supplied here rather than in
+// <boost/filesystem/path_traits.hpp>, thus avoiding header circularity.
+// test cases are in operations_unit_test.cpp
+
+ namespace path_traits
+ {
+ void dispatch( const directory_entry & de, std::wstring & to, const codecvt_type & )
+ {
+ to = de.path().source();
+ }
+} // namespace path_traits
} // namespace filesystem
} // namespace boost
Modified: sandbox/filesystem-v3/libs/filesystem/src/path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -2,8 +2,10 @@
// Copyright Beman Dawes 2008
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
@@ -17,6 +19,7 @@
#include <cstddef>
#include <cstring>
#include <cassert>
+#include "windows_file_codecvt.hpp"
#ifdef BOOST_FILESYSTEM_DEBUG
# include <iostream>
@@ -294,6 +297,76 @@
return *this;
}
+//
+// // m_normalize ------------------------------------------------------------//
+// //
+//
+// path & path::m_normalize()
+// {
+// if ( m_path.empty() ) return *this;
+//
+// path_type temp;
+// iterator start( begin() );
+// iterator last( end() );
+// iterator stop( last-- );
+// for ( iterator itr( start ); itr != stop; ++itr )
+// {
+// // ignore "." except at start and last
+// if ( itr->size() == 1
+// && (*itr)[0] == dot
+// && itr != start
+// && itr != last ) continue;
+//
+// // ignore a name and following ".."
+// if ( !temp.empty()
+// && itr->size() == 2
+// && (*itr)[0] == dot
+// && (*itr)[1] == dot ) // dot dot
+// {
+// string_type lf( temp.filename() );
+// if ( lf.size() > 0
+// && (lf.size() != 1
+// || (lf[0] != dot
+// && lf[0] != separator))
+// && (lf.size() != 2
+// || (lf[0] != dot
+// && lf[1] != dot
+//# ifdef BOOST_WINDOWS_PATH
+// && lf[1] != colon
+//# endif
+// )
+// )
+// )
+// {
+// temp.remove_filename();
+// // if not root directory, must also remove "/" if any
+// if ( temp.m_path.size() > 0
+// && temp.m_path[temp.m_path.size()-1]
+// == separator )
+// {
+// typename string_type::size_type rds(
+// detail::root_directory_start<String,Traits>( temp.m_path,
+// temp.m_path.size() ) );
+// if ( rds == string_type::npos
+// || rds != temp.m_path.size()-1 )
+// { temp.m_path.erase( temp.m_path.size()-1 ); }
+// }
+//
+// iterator next( itr );
+// if ( temp.empty() && ++next != stop
+// && next == last && *last == dot_str ) temp /= dot_str;
+// continue;
+// }
+// }
+//
+// temp /= *itr;
+// };
+//
+// if ( temp.empty() ) temp /= dot_str;
+// m_path = temp.m_path;
+// return *this;
+// }
+
} // namespace filesystem
} // namespace boost
@@ -602,87 +675,6 @@
namespace
{
-# ifdef BOOST_WINDOWS_API
-
- //------------------------------------------------------------------------------------//
- // //
- // class windows_file_api_codecvt_facet //
- // //
- // Warning: partial implementation; even do_in and do_out only partially meet the //
- // standard library specifications; the "to" buffer must hold the entire result. //
- //------------------------------------------------------------------------------------//
-
- class windows_file_api_codecvt_facet
- : public std::codecvt< wchar_t, char, std::mbstate_t >
- {
- public:
- explicit windows_file_api_codecvt_facet()
- : std::codecvt<wchar_t, char, std::mbstate_t>(0) {}
- protected:
-
- virtual bool do_always_noconv() const throw() { return false; }
-
- // seems safest to assume variable number of characters since we don't
- // actually know what codepage is active
- virtual int do_encoding() const throw() { return 0; }
-
- virtual std::codecvt_base::result do_in( std::mbstate_t& state,
- const char * from, const char * from_end, const char *& from_next,
- wchar_t * to, wchar_t * to_end, wchar_t *& to_next ) const;
-
- virtual std::codecvt_base::result do_out( std::mbstate_t & state,
- const wchar_t * from, const wchar_t * from_end, const wchar_t *& from_next,
- char * to, char * to_end, char *& to_next ) const;
-
- virtual std::codecvt_base::result do_unshift( std::mbstate_t&,
- char * from, char * /*to*/, char * & next) const { return ok; }
-
- virtual int do_length( std::mbstate_t &,
- const char * from, const char * from_end, std::size_t max ) const { return 0; }
-
- virtual int do_max_length() const throw () { return 0; }
- };
-
- std::codecvt_base::result windows_file_api_codecvt_facet::do_in(
- std::mbstate_t & state,
- const char * from, const char * from_end, const char *& from_next,
- wchar_t * to, wchar_t * to_end, wchar_t *& to_next ) const
- {
- UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
-
- int count;
- if ( (count = ::MultiByteToWideChar( codepage, MB_PRECOMPOSED, from,
- from_end - from, to, to_end - to )) == 0 )
- {
- return error; // conversion failed
- }
-
- from_next = from_end;
- to_next = to + count;
- *to_next = L'\0';
- return ok;
- }
-
- std::codecvt_base::result windows_file_api_codecvt_facet::do_out(
- std::mbstate_t & state,
- const wchar_t * from, const wchar_t * from_end, const wchar_t* & from_next,
- char * to, char * to_end, char * & to_next ) const
- {
- UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
-
- int count;
- if ( (count = ::WideCharToMultiByte( codepage, WC_NO_BEST_FIT_CHARS, from,
- from_end - from, to, to_end - to, 0, 0 )) == 0 )
- {
- return error; // conversion failed
- }
-
- from_next = from_end;
- to_next = to + count;
- *to_next = '\0';
- return ok;
- }
-# endif // BOOST_WINDOWS_API
//------------------------------------------------------------------------------------//
// locale helpers //
@@ -697,11 +689,15 @@
{
# ifdef BOOST_WINDOWS_API
std::locale global_loc = std::locale();
- std::locale loc( global_loc, new windows_file_api_codecvt_facet );
+ std::locale loc( global_loc, new windows_file_codecvt );
return loc;
# else
// ISO C calls this "the locale-specific native environment":
- return std::locale("");
+# if !defined(macintosh) && !defined(__APPLE__) && !defined(__APPLE_CC__)
+ return std::locale("");
+# else
+ return std::locale(); // std::locale("") throws on Mac OS
+# endif
# endif
}
@@ -712,16 +708,6 @@
return loc;
}
- const std::codecvt<wchar_t, char, std::mbstate_t> *&
- wchar_t_codecvt_facet()
- {
- static const std::codecvt<wchar_t, char, std::mbstate_t> *
- facet(
- &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
- ( path_locale() ) );
- return facet;
- }
-
} // unnamed namespace
//--------------------------------------------------------------------------------------//
@@ -733,6 +719,16 @@
namespace filesystem
{
+ const path::codecvt_type *&
+ path::wchar_t_codecvt_facet()
+ {
+ static const std::codecvt<wchar_t, char, std::mbstate_t> *
+ facet(
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ ( path_locale() ) );
+ return facet;
+ }
+
std::locale path::imbue( const std::locale & loc )
{
std::locale temp( path_locale() );
@@ -742,160 +738,5 @@
return temp;
}
- std::locale path::imbue( const std::locale & loc, system::error_code & ec )
- {
- try
- {
- std::locale temp( path_locale() );
- path_locale() = loc;
- wchar_t_codecvt_facet() = &std::use_facet
- <std::codecvt<wchar_t, char, std::mbstate_t> >( path_locale() );
- if ( &ec != &boost::throws() ) ec.clear();
- return temp;
- }
- catch (...)
- {
- assert( 0 && "not implemented yet" ); // TODO
- return path_locale();
- }
- }
-
-//--------------------------------------------------------------------------------------//
-// detail implementation //
-//--------------------------------------------------------------------------------------//
-
-namespace detail
-{
-# ifdef BOOST_WINDOWS_API
-# define APPEND_DIRECTION in
-# define CONVERT_DIRECTION out
-# else
-# define APPEND_DIRECTION out
-# define CONVERT_DIRECTION in
-# endif
-
- //------------------------------------------------------------------------------------//
- // append //
- //------------------------------------------------------------------------------------//
-
- // actual append done here to factor it out from messy buffer management code;
- // this function just assumes the buffer is large enough.
- inline void do_append(
- const interface_value_type * from, const interface_value_type * from_end,
- value_type * to, value_type * to_end,
- string_type & target, error_code & ec )
- {
- //std::cout << std::hex
- // << " from=" << std::size_t(from)
- // << " from_end=" << std::size_t(from_end)
- // << " to=" << std::size_t(to)
- // << " to_end=" << std::size_t(to_end)
- // << std::endl;
-
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const interface_value_type * from_next;
- value_type * to_next;
-
- std::codecvt_base::result res;
-
- if ( (res=wchar_t_codecvt_facet()->APPEND_DIRECTION( state, from, from_end, from_next,
- to, to_end, to_next )) != std::codecvt_base::ok )
- {
- //std::cout << " result is " << static_cast<int>(res) << std::endl;
- assert( 0 && "append error handling not implemented yet" );
- throw "append error handling not implemented yet";
- }
- if ( &ec != &boost::throws() ) ec.clear();
- target.append( to, to_next );
- }
-
- BOOST_FILESYSTEM_DECL
- void append( const interface_value_type * begin, const interface_value_type * end,
- string_type & target, error_code & ec )
- {
- if ( !end )
- {
- // compute strlen by hand since interface_value_type may not be char
- end = begin;
- while (*end) ++end;
- }
-
- if ( begin == end )
- {
- if ( &ec != &boost::throws() ) ec.clear();
- return;
- }
-
- std::size_t buf_size = (end - begin) * 3; // perhaps too large, but that's OK
-
- // dynamically allocate a buffer only if source is unusually large
- if ( buf_size > default_codecvt_buf_size )
- {
- boost::scoped_array< value_type > buf( new value_type [buf_size] );
- do_append( begin, end, buf.get(), buf.get()+buf_size, target, ec );
- }
- else
- {
- value_type buf[default_codecvt_buf_size];
- do_append( begin, end, buf, buf+default_codecvt_buf_size, target, ec );
- }
- }
-
- //------------------------------------------------------------------------------------//
- // convert //
- //------------------------------------------------------------------------------------//
-
- // actual convert done here to factor it out from messy buffer management code;
- // this function just assumes the buffer is large enough.
- inline interface_string_type do_convert(
- const value_type * from, const value_type * from_end,
- interface_value_type * to, interface_value_type * to_end,
- error_code & ec )
- {
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const value_type * from_next;
- interface_value_type * to_next;
-
- if ( wchar_t_codecvt_facet()->CONVERT_DIRECTION( state, from, from_end,
- from_next, to, to_end, to_next ) != std::codecvt_base::ok )
- {
- assert( 0 && "convert error handling not implemented yet" );
- throw "convert error handling not implemented yet";
- }
- if ( &ec != &boost::throws() ) ec.clear();
- return interface_string_type( to, to_next );
- }
-
- BOOST_FILESYSTEM_DECL
- interface_string_type convert_to_string( const string_type & src, error_code & ec )
- {
- if ( src.empty() )
- {
- if ( &ec != &boost::throws() ) ec.clear();
- return interface_string_type();
- }
-
- // The codecvt length functions may not be implemented, and I don't really
- // understand them either. Thus this code is just a guess; if it turns
- // out the buffer is too small then an error will be reported and the code
- // will have to be fixed.
- std::size_t buf_size = src.size() * 4;
- buf_size += 4; // encodings like shift-JIS need some prefix space
-
- // dynamically allocate a buffer only if source is unusually large
- if ( buf_size > default_codecvt_buf_size )
- {
- boost::scoped_array< interface_value_type > buf( new interface_value_type [buf_size] );
- return do_convert( src.c_str(), src.c_str()+src.size(),
- buf.get(), buf.get()+buf_size, ec );
- }
- else
- {
- interface_value_type buf[default_codecvt_buf_size];
- return do_convert( src.c_str(), src.c_str()+src.size(), buf, buf+buf_size, ec );
- }
- }
-
-} // namespace detail
} // namespace filesystem
} // namespace boost
Copied: sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp (from r55374, /sandbox/filesystem-v3/libs/filesystem/src/convert.cpp)
==============================================================================
--- /sandbox/filesystem-v3/libs/filesystem/src/convert.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,4 +1,4 @@
-// filesystem convert.cpp ------------------------------------------------------------//
+// filesystem path_traits.cpp --------------------------------------------------------//
// Copyright Beman Dawes 2008, 2009
@@ -7,12 +7,19 @@
// Library home page: http://www.boost.org/libs/filesystem
-#include <boost/filesystem/detail/convert.hpp>
+// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_FILESYSTEM_SOURCE
+
+#include <boost/filesystem/path_traits.hpp>
#include <boost/filesystem/config.hpp>
#include <boost/scoped_array.hpp>
+#include <locale> // for codecvt_base::result
#include <cstring> // for strlen
#include <cwchar> // for wcslen
+namespace pt = boost::filesystem::path_traits;
+
//--------------------------------------------------------------------------------------//
// configuration //
//--------------------------------------------------------------------------------------//
@@ -42,7 +49,7 @@
const char * from_end,
wchar_t * to, wchar_t * to_end,
std::wstring & target,
- const boost::filesystem::codecvt_type & cvt )
+ const pt::codecvt_type & cvt )
{
//std::cout << std::hex
// << " from=" << std::size_t(from)
@@ -76,7 +83,7 @@
const wchar_t * from_end,
char * to, char * to_end,
std::string & target,
- const boost::filesystem::codecvt_type & cvt )
+ const pt::codecvt_type & cvt )
{
//std::cout << std::hex
// << " from=" << std::size_t(from)
@@ -103,7 +110,11 @@
} // unnamed namespace
-namespace boost { namespace filesystem { namespace detail {
+//--------------------------------------------------------------------------------------//
+// path_traits //
+//--------------------------------------------------------------------------------------//
+
+namespace boost { namespace filesystem { namespace path_traits {
//--------------------------------------------------------------------------------------//
// convert const char * to wstring //
@@ -177,4 +188,4 @@
convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt );
}
}
-}}} // namespace boost::filesystem::detail
+}}} // namespace boost::filesystem::path_traits
Added: sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp
==============================================================================
--- (empty file)
+++ sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -0,0 +1,63 @@
+// filesystem windows_file_codecvt.cpp -----------------------------------------//
+
+// Copyright Beman Dawes 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_FILESYSTEM_SOURCE
+
+#include <boost/filesystem/config.hpp>
+
+#ifdef BOOST_WINDOWS_API
+
+#include "windows_file_codecvt.hpp"
+
+#define WINVER 0x0500 // MinGW for GCC 4.4 requires this
+#include <windows.h>
+
+ std::codecvt_base::result windows_file_codecvt::do_in(
+ std::mbstate_t & state,
+ const char * from, const char * from_end, const char *& from_next,
+ wchar_t * to, wchar_t * to_end, wchar_t *& to_next ) const
+ {
+ UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
+
+ int count;
+ if ( (count = ::MultiByteToWideChar( codepage, MB_PRECOMPOSED, from,
+ from_end - from, to, to_end - to )) == 0 )
+ {
+ return error; // conversion failed
+ }
+
+ from_next = from_end;
+ to_next = to + count;
+ *to_next = L'\0';
+ return ok;
+ }
+
+ std::codecvt_base::result windows_file_codecvt::do_out(
+ std::mbstate_t & state,
+ const wchar_t * from, const wchar_t * from_end, const wchar_t* & from_next,
+ char * to, char * to_end, char * & to_next ) const
+ {
+ UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
+
+ int count;
+ if ( (count = ::WideCharToMultiByte( codepage, WC_NO_BEST_FIT_CHARS, from,
+ from_end - from, to, to_end - to, 0, 0 )) == 0 )
+ {
+ return error; // conversion failed
+ }
+
+ from_next = from_end;
+ to_next = to + count;
+ *to_next = '\0';
+ return ok;
+ }
+
+ # endif // BOOST_WINDOWS_API
Added: sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp
==============================================================================
--- (empty file)
+++ sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -0,0 +1,55 @@
+// filesystem windows_file_codecvt.hpp -----------------------------------------------//
+
+// Copyright Beman Dawes 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+#ifndef BOOST_FILESYSTEM_WIN_FILE_CODECVT_HPP
+#define BOOST_FILESYSTEM_WIN_FILE_CODECVT_HPP
+
+#include <locale>
+
+ //------------------------------------------------------------------------------------//
+ // //
+ // class windows_file_codecvt //
+ // //
+ // Warning: partial implementation; even do_in and do_out only partially meet the //
+ // standard library specifications as the "to" buffer must hold the entire result. //
+ // //
+ //------------------------------------------------------------------------------------//
+
+ class BOOST_FILESYSTEM_DECL windows_file_codecvt
+ : public std::codecvt< wchar_t, char, std::mbstate_t >
+ {
+ public:
+ explicit windows_file_codecvt()
+ : std::codecvt<wchar_t, char, std::mbstate_t>() {}
+ protected:
+
+ virtual bool do_always_noconv() const throw() { return false; }
+
+ // seems safest to assume variable number of characters since we don't
+ // actually know what codepage is active
+ virtual int do_encoding() const throw() { return 0; }
+
+ virtual std::codecvt_base::result do_in( std::mbstate_t& state,
+ const char * from, const char * from_end, const char *& from_next,
+ wchar_t * to, wchar_t * to_end, wchar_t *& to_next ) const;
+
+ virtual std::codecvt_base::result do_out( std::mbstate_t & state,
+ const wchar_t * from, const wchar_t * from_end, const wchar_t *& from_next,
+ char * to, char * to_end, char *& to_next ) const;
+
+ virtual std::codecvt_base::result do_unshift( std::mbstate_t&,
+ char * from, char * /*to*/, char * & next) const { return ok; }
+
+ virtual int do_length( std::mbstate_t &,
+ const char * from, const char * from_end, std::size_t max ) const { return 0; }
+
+ virtual int do_max_length() const throw () { return 0; }
+ };
+
+#endif // BOOST_FILESYSTEM_WIN_FILE_CODECVT_HPP
Modified: sandbox/filesystem-v3/libs/filesystem/test/Jamfile.v2
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/Jamfile.v2 (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/Jamfile.v2 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -7,49 +7,26 @@
project
: requirements
<library>/boost/filesystem//boost_filesystem
+ <library>/boost/system//boost_system
<toolset>msvc:<asynch-exceptions>on
;
+
+# Some tests are run both statically and as shared libraries since it is helpful
+# to know if failures in shared library tests are related to sharing or not.
test-suite "filesystem" :
- [ run path_unit_test.cpp
- : : : <link>static
- ]
- [ run path_unit_test.cpp ../../system/build
- : : : : path_unit_test_dll
- ]
- [ run path_test.cpp
- : : : <link>static
- ]
- [ run path_test.cpp ../../system/build
- : : : : path_test_dll
- ]
- [ run operations_unit_test.cpp
- : : : <link>static
- ]
- [ run operations_unit_test.cpp ../../system/build
- : : : : operations_unit_test_dll
- ]
- [ run operations_test.cpp
- : : : <link>static
- ]
- [ run operations_test.cpp ../../system/build
- : : : : operations_test_dll
- ]
- [ run fstream_test.cpp
- : : : <link>static
- ]
- [ run convenience_test.cpp
- : : : <link>static
- ]
- [ run large_file_support_test.cpp
- : : : <link>static
- ]
- [ run wide_test.cpp
- : : : <link>static
- ]
-
- [ compile deprecated_test.cpp ]
- [ compile ../example/mbcopy.cpp ]
- [ compile ../example/mbpath.cpp ]
- [ compile ../example/simple_ls.cpp ]
+ [ run path_unit_test.cpp ]
+ [ run path_test.cpp ]
+ [ run operations_unit_test.cpp ]
+ [ run operations_unit_test.cpp : : : <link>static : operations_unit_test_static ]
+ [ run operations_test.cpp ]
+ [ run operations_test.cpp : : : <link>static : operations_test_static ]
+ [ run fstream_test.cpp ]
+ [ run convenience_test.cpp ]
+ [ run large_file_support_test.cpp ]
+ [ run deprecated_test.cpp ]
+ [ run ../example/simple_ls.cpp ]
+
+# [ compile ../example/mbcopy.cpp ]
+# [ compile ../example/mbpath.cpp ]
;
Modified: sandbox/filesystem-v3/libs/filesystem/test/convenience_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/convenience_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/convenience_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -18,7 +18,7 @@
using fs::path;
namespace sys = boost::system;
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
#include <boost/bind.hpp>
#include <fstream>
#include <iostream>
@@ -49,48 +49,48 @@
}
}
-// --------------------------------------------------------------------------//
+// ------------------------------------------------------------------------------------//
-int test_main( int, char*[] )
+int main( int, char*[] )
{
-// create_directories() tests ----------------------------------------------//
+// create_directories() tests --------------------------------------------------------//
- BOOST_CHECK( !fs::create_directories( "" ) ); // should be harmless
- BOOST_CHECK( !fs::create_directories( "/" ) ); // ditto
+ BOOST_TEST( !fs::create_directories( "" ) ); // should be harmless
+ BOOST_TEST( !fs::create_directories( "/" ) ); // ditto
fs::remove_all( "xx" ); // make sure slate is blank
- BOOST_CHECK( !fs::exists( "xx" ) ); // reality check
+ BOOST_TEST( !fs::exists( "xx" ) ); // reality check
- BOOST_CHECK( fs::create_directories( "xx" ) );
- BOOST_CHECK( fs::exists( "xx" ) );
- BOOST_CHECK( fs::is_directory( "xx" ) );
-
- BOOST_CHECK( fs::create_directories( "xx/yy/zz" ) );
- BOOST_CHECK( fs::exists( "xx" ) );
- BOOST_CHECK( fs::exists( "xx/yy" ) );
- BOOST_CHECK( fs::exists( "xx/yy/zz" ) );
- BOOST_CHECK( fs::is_directory( "xx" ) );
- BOOST_CHECK( fs::is_directory( "xx/yy" ) );
- BOOST_CHECK( fs::is_directory( "xx/yy/zz" ) );
+ BOOST_TEST( fs::create_directories( "xx" ) );
+ BOOST_TEST( fs::exists( "xx" ) );
+ BOOST_TEST( fs::is_directory( "xx" ) );
+
+ BOOST_TEST( fs::create_directories( "xx/yy/zz" ) );
+ BOOST_TEST( fs::exists( "xx" ) );
+ BOOST_TEST( fs::exists( "xx/yy" ) );
+ BOOST_TEST( fs::exists( "xx/yy/zz" ) );
+ BOOST_TEST( fs::is_directory( "xx" ) );
+ BOOST_TEST( fs::is_directory( "xx/yy" ) );
+ BOOST_TEST( fs::is_directory( "xx/yy/zz" ) );
path is_a_file( "xx/uu" );
{
std::ofstream f( is_a_file.string().c_str() );
- BOOST_CHECK( !!f );
+ BOOST_TEST( !!f );
}
- BOOST_CHECK( throws_fs_error(
+ BOOST_TEST( throws_fs_error(
boost::bind( fs::create_directories, is_a_file ) ) );
- BOOST_CHECK( throws_fs_error(
+ BOOST_TEST( throws_fs_error(
boost::bind( fs::create_directories, is_a_file / "aa" ) ) );
// recursive_directory_iterator tests ----------------------------------------//
sys::error_code ec;
fs::recursive_directory_iterator it( "/no-such-path", ec );
- BOOST_CHECK( ec );
+ BOOST_TEST( ec );
- BOOST_CHECK( throws_fs_error(
+ BOOST_TEST( throws_fs_error(
boost::bind( create_recursive_iterator, "/no-such-path" ) ) );
fs::remove( "xx/uu" );
@@ -100,7 +100,7 @@
// on Windows but not necessarily on other operating systems
{
std::ofstream f( "xx/yya" );
- BOOST_CHECK( !!f );
+ BOOST_TEST( !!f );
}
for ( it = fs::recursive_directory_iterator( "xx" );
@@ -108,58 +108,58 @@
{ std::cout << it->path() << '\n'; }
it = fs::recursive_directory_iterator( "xx" );
- BOOST_CHECK( it->path() == "xx/yy" );
- BOOST_CHECK( it.level() == 0 );
+ BOOST_TEST( it->path() == "xx/yy" );
+ BOOST_TEST( it.level() == 0 );
++it;
- BOOST_CHECK( it->path() == "xx/yy/zz" );
- BOOST_CHECK( it.level() == 1 );
+ BOOST_TEST( it->path() == "xx/yy/zz" );
+ BOOST_TEST( it.level() == 1 );
it.pop();
- BOOST_CHECK( it->path() == "xx/yya" );
- BOOST_CHECK( it.level() == 0 );
+ BOOST_TEST( it->path() == "xx/yya" );
+ BOOST_TEST( it.level() == 0 );
it++;
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
it = fs::recursive_directory_iterator( "xx" );
- BOOST_CHECK( it->path() == "xx/yy" );
+ BOOST_TEST( it->path() == "xx/yy" );
it.no_push();
++it;
- BOOST_CHECK( it->path() == "xx/yya" );
+ BOOST_TEST( it->path() == "xx/yya" );
++it;
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
fs::remove( "xx/yya" );
#endif
it = fs::recursive_directory_iterator( "xx/yy/zz" );
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
it = fs::recursive_directory_iterator( "xx" );
- BOOST_CHECK( it->path() == "xx/yy" );
- BOOST_CHECK( it.level() == 0 );
+ BOOST_TEST( it->path() == "xx/yy" );
+ BOOST_TEST( it.level() == 0 );
++it;
- BOOST_CHECK( it->path() == "xx/yy/zz" );
- BOOST_CHECK( it.level() == 1 );
+ BOOST_TEST( it->path() == "xx/yy/zz" );
+ BOOST_TEST( it.level() == 1 );
it++;
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
it = fs::recursive_directory_iterator( "xx" );
- BOOST_CHECK( it->path() == "xx/yy" );
+ BOOST_TEST( it->path() == "xx/yy" );
it.no_push();
++it;
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
it = fs::recursive_directory_iterator( "xx" );
- BOOST_CHECK( it->path() == "xx/yy" );
+ BOOST_TEST( it->path() == "xx/yy" );
++it;
it.pop();
- BOOST_CHECK( it == fs::recursive_directory_iterator() );
+ BOOST_TEST( it == fs::recursive_directory_iterator() );
ec.clear();
- BOOST_CHECK( !ec );
+ BOOST_TEST( !ec );
// check that two argument failed constructor creates the end iterator
- BOOST_CHECK( fs::recursive_directory_iterator("nosuchdir", ec)
+ BOOST_TEST( fs::recursive_directory_iterator("nosuchdir", ec)
== fs::recursive_directory_iterator() );
- BOOST_CHECK( ec );
+ BOOST_TEST( ec );
- return 0;
+ return ::boost::report_errors();
}
Modified: sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -3,17 +3,16 @@
// Copyright Beman Dawes 2002
// Copyright Vladimir Prus 2002
-// Use, modification, and distribution is subject to 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
// This test verifies that various deprecated names still compile. This is
// important to preserve existing code that uses the old names.
#include <boost/filesystem.hpp>
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
namespace fs = boost::filesystem;
using boost::filesystem::path;
@@ -24,130 +23,143 @@
{
std::string platform( BOOST_PLATFORM );
- int errors;
-
void check( const fs::path & source,
const std::string & expected, int line )
{
if ( source.string()== expected ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << '(' << line << ") source.string(): \"" << source.string()
<< "\" != expected: \"" << expected
<< "\"" << std::endl;
}
- void check_normalize()
+ //void check_normalize()
+ //{
+ // PATH_CHECK( path("").normalize(), "" );
+ // PATH_CHECK( path("/").normalize(), "/" );
+ // PATH_CHECK( path("//").normalize(), "//" );
+ // PATH_CHECK( path("///").normalize(), "/" );
+ // PATH_CHECK( path("f").normalize(), "f" );
+ // PATH_CHECK( path("foo").normalize(), "foo" );
+ // PATH_CHECK( path("foo/").normalize(), "foo/." );
+ // PATH_CHECK( path("f/").normalize(), "f/." );
+ // PATH_CHECK( path( "/foo" ).normalize(), "/foo" );
+ // PATH_CHECK( path( "foo/bar" ).normalize(), "foo/bar" );
+ // PATH_CHECK( path("..").normalize(), ".." );
+ // PATH_CHECK( path("../..").normalize(), "../.." );
+ // PATH_CHECK( path("/..").normalize(), "/.." );
+ // PATH_CHECK( path("/../..").normalize(), "/../.." );
+ // PATH_CHECK( path("../foo").normalize(), "../foo" );
+ // PATH_CHECK( path("foo/..").normalize(), "." );
+ // PATH_CHECK( path("foo/../").normalize(), "./." );
+ // PATH_CHECK( (path("foo") / "..").normalize() , "." );
+ // PATH_CHECK( path("foo/...").normalize(), "foo/..." );
+ // PATH_CHECK( path("foo/.../").normalize(), "foo/.../." );
+ // PATH_CHECK( path("foo/..bar").normalize(), "foo/..bar" );
+ // PATH_CHECK( path("../f").normalize(), "../f" );
+ // PATH_CHECK( path("/../f").normalize(), "/../f" );
+ // PATH_CHECK( path("f/..").normalize(), "." );
+ // PATH_CHECK( (path("f") / "..").normalize() , "." );
+ // PATH_CHECK( path("foo/../..").normalize(), ".." );
+ // PATH_CHECK( path("foo/../../").normalize(), "../." );
+ // PATH_CHECK( path("foo/../../..").normalize(), "../.." );
+ // PATH_CHECK( path("foo/../../../").normalize(), "../../." );
+ // PATH_CHECK( path("foo/../bar").normalize(), "bar" );
+ // PATH_CHECK( path("foo/../bar/").normalize(), "bar/." );
+ // PATH_CHECK( path("foo/bar/..").normalize(), "foo" );
+ // PATH_CHECK( path("foo/bar/../").normalize(), "foo/." );
+ // PATH_CHECK( path("foo/bar/../..").normalize(), "." );
+ // PATH_CHECK( path("foo/bar/../../").normalize(), "./." );
+ // PATH_CHECK( path("foo/bar/../blah").normalize(), "foo/blah" );
+ // PATH_CHECK( path("f/../b").normalize(), "b" );
+ // PATH_CHECK( path("f/b/..").normalize(), "f" );
+ // PATH_CHECK( path("f/b/../").normalize(), "f/." );
+ // PATH_CHECK( path("f/b/../a").normalize(), "f/a" );
+ // PATH_CHECK( path("foo/bar/blah/../..").normalize(), "foo" );
+ // PATH_CHECK( path("foo/bar/blah/../../bletch").normalize(), "foo/bletch" );
+ // PATH_CHECK( path( "//net" ).normalize(), "//net" );
+ // PATH_CHECK( path( "//net/" ).normalize(), "//net/" );
+ // PATH_CHECK( path( "//..net" ).normalize(), "//..net" );
+ // PATH_CHECK( path( "//net/.." ).normalize(), "//net/.." );
+ // PATH_CHECK( path( "//net/foo" ).normalize(), "//net/foo" );
+ // PATH_CHECK( path( "//net/foo/" ).normalize(), "//net/foo/." );
+ // PATH_CHECK( path( "//net/foo/.." ).normalize(), "//net/" );
+ // PATH_CHECK( path( "//net/foo/../" ).normalize(), "//net/." );
+
+ // PATH_CHECK( path( "/net/foo/bar" ).normalize(), "/net/foo/bar" );
+ // PATH_CHECK( path( "/net/foo/bar/" ).normalize(), "/net/foo/bar/." );
+ // PATH_CHECK( path( "/net/foo/.." ).normalize(), "/net" );
+ // PATH_CHECK( path( "/net/foo/../" ).normalize(), "/net/." );
+
+ // PATH_CHECK( path( "//net//foo//bar" ).normalize(), "//net/foo/bar" );
+ // PATH_CHECK( path( "//net//foo//bar//" ).normalize(), "//net/foo/bar/." );
+ // PATH_CHECK( path( "//net//foo//.." ).normalize(), "//net/" );
+ // PATH_CHECK( path( "//net//foo//..//" ).normalize(), "//net/." );
+
+ // PATH_CHECK( path( "///net///foo///bar" ).normalize(), "/net/foo/bar" );
+ // PATH_CHECK( path( "///net///foo///bar///" ).normalize(), "/net/foo/bar/." );
+ // PATH_CHECK( path( "///net///foo///.." ).normalize(), "/net" );
+ // PATH_CHECK( path( "///net///foo///..///" ).normalize(), "/net/." );
+
+ // if ( platform == "Windows" )
+ // {
+ // PATH_CHECK( path( "c:.." ).normalize(), "c:.." );
+ // PATH_CHECK( path( "c:foo/.." ).normalize(), "c:" );
+
+ // PATH_CHECK( path( "c:foo/../" ).normalize(), "c:." );
+
+ // PATH_CHECK( path( "c:/foo/.." ).normalize(), "c:/" );
+ // PATH_CHECK( path( "c:/foo/../" ).normalize(), "c:/." );
+ // PATH_CHECK( path( "c:/.." ).normalize(), "c:/.." );
+ // PATH_CHECK( path( "c:/../" ).normalize(), "c:/../." );
+ // PATH_CHECK( path( "c:/../.." ).normalize(), "c:/../.." );
+ // PATH_CHECK( path( "c:/../../" ).normalize(), "c:/../../." );
+ // PATH_CHECK( path( "c:/../foo" ).normalize(), "c:/../foo" );
+ // PATH_CHECK( path( "c:/../foo/" ).normalize(), "c:/../foo/." );
+ // PATH_CHECK( path( "c:/../../foo" ).normalize(), "c:/../../foo" );
+ // PATH_CHECK( path( "c:/../../foo/" ).normalize(), "c:/../../foo/." );
+ // PATH_CHECK( path( "c:/..foo" ).normalize(), "c:/..foo" );
+ // }
+ // else // POSIX
+ // {
+ // PATH_CHECK( path( "c:.." ).normalize(), "c:.." );
+ // PATH_CHECK( path( "c:foo/.." ).normalize(), "." );
+ // PATH_CHECK( path( "c:foo/../" ).normalize(), "./." );
+ // PATH_CHECK( path( "c:/foo/.." ).normalize(), "c:" );
+ // PATH_CHECK( path( "c:/foo/../" ).normalize(), "c:/." );
+ // PATH_CHECK( path( "c:/.." ).normalize(), "." );
+ // PATH_CHECK( path( "c:/../" ).normalize(), "./." );
+ // PATH_CHECK( path( "c:/../.." ).normalize(), ".." );
+ // PATH_CHECK( path( "c:/../../" ).normalize(), "../." );
+ // PATH_CHECK( path( "c:/../foo" ).normalize(), "foo" );
+ // PATH_CHECK( path( "c:/../foo/" ).normalize(), "foo/." );
+ // PATH_CHECK( path( "c:/../../foo" ).normalize(), "../foo" );
+ // PATH_CHECK( path( "c:/../../foo/" ).normalize(), "../foo/." );
+ // PATH_CHECK( path( "c:/..foo" ).normalize(), "c:/..foo" );
+ // }
+ //}
+
+ // Compile-only tests. Not intended to be executed.
+
+ void compile_only()
{
- PATH_CHECK( path("").normalize(), "" );
- PATH_CHECK( path("/").normalize(), "/" );
- PATH_CHECK( path("//").normalize(), "//" );
- PATH_CHECK( path("///").normalize(), "/" );
- PATH_CHECK( path("f").normalize(), "f" );
- PATH_CHECK( path("foo").normalize(), "foo" );
- PATH_CHECK( path("foo/").normalize(), "foo/." );
- PATH_CHECK( path("f/").normalize(), "f/." );
- PATH_CHECK( path( "/foo" ).normalize(), "/foo" );
- PATH_CHECK( path( "foo/bar" ).normalize(), "foo/bar" );
- PATH_CHECK( path("..").normalize(), ".." );
- PATH_CHECK( path("../..").normalize(), "../.." );
- PATH_CHECK( path("/..").normalize(), "/.." );
- PATH_CHECK( path("/../..").normalize(), "/../.." );
- PATH_CHECK( path("../foo").normalize(), "../foo" );
- PATH_CHECK( path("foo/..").normalize(), "." );
- PATH_CHECK( path("foo/../").normalize(), "./." );
- PATH_CHECK( (path("foo") / "..").normalize() , "." );
- PATH_CHECK( path("foo/...").normalize(), "foo/..." );
- PATH_CHECK( path("foo/.../").normalize(), "foo/.../." );
- PATH_CHECK( path("foo/..bar").normalize(), "foo/..bar" );
- PATH_CHECK( path("../f").normalize(), "../f" );
- PATH_CHECK( path("/../f").normalize(), "/../f" );
- PATH_CHECK( path("f/..").normalize(), "." );
- PATH_CHECK( (path("f") / "..").normalize() , "." );
- PATH_CHECK( path("foo/../..").normalize(), ".." );
- PATH_CHECK( path("foo/../../").normalize(), "../." );
- PATH_CHECK( path("foo/../../..").normalize(), "../.." );
- PATH_CHECK( path("foo/../../../").normalize(), "../../." );
- PATH_CHECK( path("foo/../bar").normalize(), "bar" );
- PATH_CHECK( path("foo/../bar/").normalize(), "bar/." );
- PATH_CHECK( path("foo/bar/..").normalize(), "foo" );
- PATH_CHECK( path("foo/bar/../").normalize(), "foo/." );
- PATH_CHECK( path("foo/bar/../..").normalize(), "." );
- PATH_CHECK( path("foo/bar/../../").normalize(), "./." );
- PATH_CHECK( path("foo/bar/../blah").normalize(), "foo/blah" );
- PATH_CHECK( path("f/../b").normalize(), "b" );
- PATH_CHECK( path("f/b/..").normalize(), "f" );
- PATH_CHECK( path("f/b/../").normalize(), "f/." );
- PATH_CHECK( path("f/b/../a").normalize(), "f/a" );
- PATH_CHECK( path("foo/bar/blah/../..").normalize(), "foo" );
- PATH_CHECK( path("foo/bar/blah/../../bletch").normalize(), "foo/bletch" );
- PATH_CHECK( path( "//net" ).normalize(), "//net" );
- PATH_CHECK( path( "//net/" ).normalize(), "//net/" );
- PATH_CHECK( path( "//..net" ).normalize(), "//..net" );
- PATH_CHECK( path( "//net/.." ).normalize(), "//net/.." );
- PATH_CHECK( path( "//net/foo" ).normalize(), "//net/foo" );
- PATH_CHECK( path( "//net/foo/" ).normalize(), "//net/foo/." );
- PATH_CHECK( path( "//net/foo/.." ).normalize(), "//net/" );
- PATH_CHECK( path( "//net/foo/../" ).normalize(), "//net/." );
-
- PATH_CHECK( path( "/net/foo/bar" ).normalize(), "/net/foo/bar" );
- PATH_CHECK( path( "/net/foo/bar/" ).normalize(), "/net/foo/bar/." );
- PATH_CHECK( path( "/net/foo/.." ).normalize(), "/net" );
- PATH_CHECK( path( "/net/foo/../" ).normalize(), "/net/." );
-
- PATH_CHECK( path( "//net//foo//bar" ).normalize(), "//net/foo/bar" );
- PATH_CHECK( path( "//net//foo//bar//" ).normalize(), "//net/foo/bar/." );
- PATH_CHECK( path( "//net//foo//.." ).normalize(), "//net/" );
- PATH_CHECK( path( "//net//foo//..//" ).normalize(), "//net/." );
-
- PATH_CHECK( path( "///net///foo///bar" ).normalize(), "/net/foo/bar" );
- PATH_CHECK( path( "///net///foo///bar///" ).normalize(), "/net/foo/bar/." );
- PATH_CHECK( path( "///net///foo///.." ).normalize(), "/net" );
- PATH_CHECK( path( "///net///foo///..///" ).normalize(), "/net/." );
-
- if ( platform == "Windows" )
- {
- PATH_CHECK( path( "c:.." ).normalize(), "c:.." );
- PATH_CHECK( path( "c:foo/.." ).normalize(), "c:" );
-
- PATH_CHECK( path( "c:foo/../" ).normalize(), "c:." );
-
- PATH_CHECK( path( "c:/foo/.." ).normalize(), "c:/" );
- PATH_CHECK( path( "c:/foo/../" ).normalize(), "c:/." );
- PATH_CHECK( path( "c:/.." ).normalize(), "c:/.." );
- PATH_CHECK( path( "c:/../" ).normalize(), "c:/../." );
- PATH_CHECK( path( "c:/../.." ).normalize(), "c:/../.." );
- PATH_CHECK( path( "c:/../../" ).normalize(), "c:/../../." );
- PATH_CHECK( path( "c:/../foo" ).normalize(), "c:/../foo" );
- PATH_CHECK( path( "c:/../foo/" ).normalize(), "c:/../foo/." );
- PATH_CHECK( path( "c:/../../foo" ).normalize(), "c:/../../foo" );
- PATH_CHECK( path( "c:/../../foo/" ).normalize(), "c:/../../foo/." );
- PATH_CHECK( path( "c:/..foo" ).normalize(), "c:/..foo" );
- }
- else // POSIX
- {
- PATH_CHECK( path( "c:.." ).normalize(), "c:.." );
- PATH_CHECK( path( "c:foo/.." ).normalize(), "." );
- PATH_CHECK( path( "c:foo/../" ).normalize(), "./." );
- PATH_CHECK( path( "c:/foo/.." ).normalize(), "c:" );
- PATH_CHECK( path( "c:/foo/../" ).normalize(), "c:/." );
- PATH_CHECK( path( "c:/.." ).normalize(), "." );
- PATH_CHECK( path( "c:/../" ).normalize(), "./." );
- PATH_CHECK( path( "c:/../.." ).normalize(), ".." );
- PATH_CHECK( path( "c:/../../" ).normalize(), "../." );
- PATH_CHECK( path( "c:/../foo" ).normalize(), "foo" );
- PATH_CHECK( path( "c:/../foo/" ).normalize(), "foo/." );
- PATH_CHECK( path( "c:/../../foo" ).normalize(), "../foo" );
- PATH_CHECK( path( "c:/../../foo/" ).normalize(), "../foo/." );
- PATH_CHECK( path( "c:/..foo" ).normalize(), "c:/..foo" );
- }
+ fs::path p;
+
+ fs::initial_path<fs::path>();
+ fs::initial_path<fs::wpath>();
+
+ p.file_string();
+ p.directory_string();
}
+
} // unnamed namespace
+
//----------------------------------------------------------------------------//
-int test_main( int /*argc*/, char * /*argv*/[] )
+int main( int /*argc*/, char * /*argv*/[] )
{
// The choice of platform is make at runtime rather than compile-time
// so that compile errors for all platforms will be detected even though
@@ -167,38 +179,38 @@
de.string();
fs::path ng( " no-way, Jose" );
- BOOST_CHECK( !fs::is_regular( ng ) ); // verify deprecated name still works
- BOOST_CHECK( !fs::symbolic_link_exists( "nosuchfileordirectory" ) );
+ BOOST_TEST( !fs::is_regular( ng ) ); // verify deprecated name still works
+ BOOST_TEST( !fs::symbolic_link_exists( "nosuchfileordirectory" ) );
- check_normalize();
+ //check_normalize();
// extension() tests ---------------------------------------------------------//
- BOOST_CHECK( fs::extension("a/b") == "" );
- BOOST_CHECK( fs::extension("a/b.txt") == ".txt" );
- BOOST_CHECK( fs::extension("a/b.") == "." );
- BOOST_CHECK( fs::extension("a.b.c") == ".c" );
- BOOST_CHECK( fs::extension("a.b.c.") == "." );
- BOOST_CHECK( fs::extension("") == "" );
- BOOST_CHECK( fs::extension("a/") == "." );
+ BOOST_TEST( fs::extension("a/b") == "" );
+ BOOST_TEST( fs::extension("a/b.txt") == ".txt" );
+ BOOST_TEST( fs::extension("a/b.") == "." );
+ BOOST_TEST( fs::extension("a.b.c") == ".c" );
+ BOOST_TEST( fs::extension("a.b.c.") == "." );
+ BOOST_TEST( fs::extension("") == "" );
+ BOOST_TEST( fs::extension("a/") == "." );
// basename() tests ----------------------------------------------------------//
- BOOST_CHECK( fs::basename("b") == "b" );
- BOOST_CHECK( fs::basename("a/b.txt") == "b" );
- BOOST_CHECK( fs::basename("a/b.") == "b" );
- BOOST_CHECK( fs::basename("a.b.c") == "a.b" );
- BOOST_CHECK( fs::basename("a.b.c.") == "a.b.c" );
- BOOST_CHECK( fs::basename("") == "" );
+ BOOST_TEST( fs::basename("b") == "b" );
+ BOOST_TEST( fs::basename("a/b.txt") == "b" );
+ BOOST_TEST( fs::basename("a/b.") == "b" );
+ BOOST_TEST( fs::basename("a.b.c") == "a.b" );
+ BOOST_TEST( fs::basename("a.b.c.") == "a.b.c" );
+ BOOST_TEST( fs::basename("") == "" );
// change_extension tests ---------------------------------------------------//
- BOOST_CHECK( fs::change_extension("a.txt", ".tex").string() == "a.tex" );
- BOOST_CHECK( fs::change_extension("a.", ".tex").string() == "a.tex" );
- BOOST_CHECK( fs::change_extension("a", ".txt").string() == "a.txt" );
- BOOST_CHECK( fs::change_extension("a.b.txt", ".tex").string() == "a.b.tex" );
+ BOOST_TEST( fs::change_extension("a.txt", ".tex").string() == "a.tex" );
+ BOOST_TEST( fs::change_extension("a.", ".tex").string() == "a.tex" );
+ BOOST_TEST( fs::change_extension("a", ".txt").string() == "a.txt" );
+ BOOST_TEST( fs::change_extension("a.b.txt", ".tex").string() == "a.b.tex" );
// see the rationale in html docs for explanation why this works
- BOOST_CHECK( fs::change_extension("", ".png").string() == ".png" );
+ BOOST_TEST( fs::change_extension("", ".png").string() == ".png" );
- return errors;
+ return ::boost::report_errors();
}
Modified: sandbox/filesystem-v3/libs/filesystem/test/fstream_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/fstream_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/fstream_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,11 +1,11 @@
-// fstream_test.cpp --------------------------------------------------------//
+// fstream_test.cpp ------------------------------------------------------------------//
-// Copyright Beman Dawes 2002.
-// Use, modification, and distribution is subject to 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)
+// Copyright Beman Dawes 2002
-// See library home page at http://www.boost.org/libs/filesystem
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
#include <boost/config/warning_disable.hpp>
@@ -20,10 +20,6 @@
#include "../src/utf8_codecvt_facet.hpp"
-#ifndef BOOST_FILESYSTEM_NARROW_ONLY
-# include "lpath.hpp"
-#endif
-
namespace fs = boost::filesystem;
#include <boost/config.hpp>
@@ -31,150 +27,129 @@
namespace std { using ::remove; }
#endif
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
namespace
{
bool cleanup = true;
- template< class Path >
- void test( const Path & p )
+ void test( const fs::path & p )
{
-# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open
{
std::cout << " in test 1\n";
fs::filebuf fb;
fb.open( p, std::ios_base::in );
- BOOST_CHECK( fb.is_open() == fs::exists( p ) );
+ BOOST_TEST( fb.is_open() == fs::exists( p ) );
}
{
std::cout << " in test 2\n";
fs::filebuf fb1;
fb1.open( p, std::ios_base::out );
- BOOST_CHECK( fb1.is_open() );
+ BOOST_TEST( fb1.is_open() );
}
{
std::cout << " in test 3\n";
fs::filebuf fb2;
fb2.open( p, std::ios_base::in );
- BOOST_CHECK( fb2.is_open() );
+ BOOST_TEST( fb2.is_open() );
}
-# else
- std::cout << "<note>\n";
- std::cout <<
- "VC++6.0 does not support boost::filesystem open()\n";
-# endif
{
std::cout << " in test 4\n";
fs::ifstream tfs( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 4.1\n";
fs::ifstream tfs( p / p.filename() ); // should fail
- BOOST_CHECK( !tfs.is_open() );
+ BOOST_TEST( !tfs.is_open() );
}
{
std::cout << " in test 5\n";
fs::ifstream tfs( p, std::ios_base::in );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open
{
std::cout << " in test 6\n";
fs::ifstream tfs;
tfs.open( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 7\n";
fs::ifstream tfs;
tfs.open( p, std::ios_base::in );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# endif
{
std::cout << " in test 8\n";
fs::ofstream tfs( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 9\n";
fs::ofstream tfs( p, std::ios_base::out );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open
{
std::cout << " in test 10\n";
fs::ofstream tfs;
tfs.open( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 11\n";
fs::ofstream tfs;
tfs.open( p, std::ios_base::out );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# endif
{
std::cout << " in test 12\n";
fs::fstream tfs( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 13\n";
fs::fstream tfs( p, std::ios_base::in|std::ios_base::out );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open
{
std::cout << " in test 14\n";
fs::fstream tfs;
tfs.open( p );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
{
std::cout << " in test 15\n";
fs::fstream tfs;
tfs.open( p, std::ios_base::in|std::ios_base::out );
- BOOST_CHECK( tfs.is_open() );
+ BOOST_TEST( tfs.is_open() );
}
-# endif
if ( cleanup ) fs::remove( p );
} // test
} // unnamed namespace
-int test_main( int argc, char*[] )
+int main( int argc, char*[] )
{
if ( argc > 1 ) cleanup = false;
- // test fs::path
- std::cout << "path tests:\n";
- test( fs::path( "fstream_test_foo" ) );
+ // test narrow characters
+ std::cout << "narrow character tests:\n";
+ test( "fstream_test_foo" );
-#ifndef BOOST_FILESYSTEM_NARROW_ONLY
// So that tests are run with known encoding, use Boost UTF-8 codecvt
std::locale global_loc = std::locale();
std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet );
- fs::wpath_traits::imbue( loc );
+ fs::path::imbue( loc );
- // test fs::wpath
- // x2780 is circled 1 against white background == e2 9e 80 in UTF-8
- // x2781 is circled 2 against white background == e2 9e 81 in UTF-8
- std::cout << "\nwpath tests:\n";
- test( fs::wpath( L"fstream_test_\x2780" ) );
-
- // test user supplied basic_path
- const long lname[] = { 'f', 's', 'r', 'e', 'a', 'm', '_', 't', 'e', 's',
- 't', '_', 'l', 'p', 'a', 't', 'h', 0 };
- std::cout << "\nlpath tests:\n";
- test( user::lpath( lname ) );
-
-#endif
+ // test with some wide characters
+ // \u2780 is circled 1 against white background == e2 9e 80 in UTF-8
+ // \u2781 is circled 2 against white background == e2 9e 81 in UTF-8
+ // \u263A is a white smiling face
+ std::cout << "\nwide character tests:\n";
+ test( L"fstream_test_\u2780\u263A" );
- return 0;
+ return ::boost::report_errors();
}
Deleted: sandbox/filesystem-v3/libs/filesystem/test/lpath.hpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/lpath.hpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
+++ (empty file)
@@ -1,101 +0,0 @@
-// Boost lpath.hpp ---------------------------------------------------------//
-
-// Copyright Beman Dawes 2005
-
-// Use, modification, and distribution is subject to 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 library home page at http://www.boost.org/libs/filesystem
-
-#include <boost/filesystem/path.hpp>
-#include <cwchar> // for std::mbstate_t
-#include <string>
-#include <ios> // for std::streamoff
-
-namespace std
-{
- // Note well: this specialization is meant only to support wide_test.cpp.
- // It is not fully functional, fully correct, or efficient.
- template<> struct char_traits<long>
- {
- typedef long char_type;
- typedef long int_type;
- typedef streamoff off_type;
- typedef streampos pos_type;
- typedef mbstate_t state_type;
- static void assign(char_type& c1, const char_type& c2){c1=c2;}
- static bool eq(const char_type& c1, const char_type& c2){return c1==c2;}
- static bool lt(const char_type& c1, const char_type& c2){return c1<c2;}
- static int compare(const char_type* s1, const char_type* s2, size_t n)
- {
- const char_type* e = s1 + n;
- for ( ;s1 != e && *s1 == *s2; ++s1, ++s2 ) {}
- return s1 == e ? 0 : (*s1<*s2 ? -1 : 1);
- }
- static size_t length(const char_type* s)
- { const char_type* b=s; for(;*s!=0L;++s){} return s-b; }
-
- static const char_type* find(const char_type* /*s*/, size_t /*n*/, const char_type& /*a*/)
- { return 0; }
-
- // copy semantics will do for wide_test
- static char_type* move(char_type* s1, const char_type* s2, size_t n)
- { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; }
-
- static char_type* copy(char_type* s1, const char_type* s2, size_t n)
- { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; }
-
- static char_type* assign(char_type* s, size_t n, char_type a)
- { char_type* b=s; for(char_type* e=s+n;s!=e;++s) *s=a; return b; }
-
- static int_type not_eof(const int_type& c);
- static char_type to_char_type(const int_type& c);
- static int_type to_int_type(const char_type& c);
- static bool eq_int_type(const int_type& c1, const int_type& c2);
- static int_type eof();
- };
-}
-
-namespace user
-{
- typedef std::basic_string<long> lstring;
- struct lpath_traits;
- typedef boost::filesystem::basic_path<lstring, lpath_traits> lpath;
-
- struct lpath_traits
- {
- typedef lstring internal_string_type;
- typedef std::string external_string_type;
-
- static external_string_type to_external( const lpath &,
- const internal_string_type & src )
- {
- external_string_type tmp;
- for ( internal_string_type::const_iterator it( src.begin() );
- it != src.end(); ++it )
- {
- tmp += static_cast<external_string_type::value_type>(*it);
- }
- return tmp;
- }
-
- static internal_string_type to_internal( const external_string_type & src )
- {
- internal_string_type tmp;
- for ( external_string_type::const_iterator it( src.begin() );
- it != src.end(); ++it ) tmp += *it;
- return tmp;
- }
- };
-
-} // namespace user
-
-namespace boost
-{
- namespace filesystem
- {
- template<> struct is_basic_path<user::lpath>
- { static const bool value = true; };
- }
-}
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -90,8 +90,6 @@
</Configuration>
<Configuration
Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
@@ -190,6 +188,14 @@
RelativePath="..\..\..\src\path.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -24,7 +24,13 @@
{FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wide_test", "wide_test\wide_test.vcproj", "{DE12E87D-87C1-4FF3-AF16-85097F2A5184}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fstream_test", "fstream_test\fstream_test.vcproj", "{A9939CD7-BE1C-4334-947C-4C320D49B3CA}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deprecated_test", "deprecated_test\deprecated_test.vcproj", "{D73BC50F-956E-4A44-BF9F-A8BB80DF0000}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proof_of_concept", "proof_of_concept\proof_of_concept.vcproj", "{440316C4-E19E-41DE-92A6-B78B3900E97F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple_ls", "simple_ls\simple_ls.vcproj", "{6B8EC880-702E-418A-BC63-CA46C6CC7B27}"
ProjectSection(ProjectDependencies) = postProject
{F94CCADD-A90B-480C-A304-C19D015D36B1} = {F94CCADD-A90B-480C-A304-C19D015D36B1}
{FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
@@ -36,40 +42,53 @@
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.ActiveCfg = Release|Win32
- {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.Build.0 = Release|Win32
+ {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.Build.0 = Debug|Win32
{3C77F610-2E31-4087-9DF2-7CD45198A02D}.Release|Win32.ActiveCfg = Release|Win32
{3C77F610-2E31-4087-9DF2-7CD45198A02D}.Release|Win32.Build.0 = Release|Win32
- {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.ActiveCfg = Release|Win32
- {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.Build.0 = Release|Win32
+ {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.Build.0 = Debug|Win32
{5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Release|Win32.ActiveCfg = Release|Win32
{5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Release|Win32.Build.0 = Release|Win32
- {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.ActiveCfg = Release|Win32
- {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.Build.0 = Release|Win32
+ {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.Build.0 = Debug|Win32
{8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Release|Win32.ActiveCfg = Release|Win32
{8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Release|Win32.Build.0 = Release|Win32
- {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.ActiveCfg = Release|Win32
- {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.Build.0 = Release|Win32
+ {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.Build.0 = Debug|Win32
{F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Release|Win32.ActiveCfg = Release|Win32
{F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Release|Win32.Build.0 = Release|Win32
- {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.ActiveCfg = Release|Win32
- {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.Build.0 = Release|Win32
+ {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.Build.0 = Debug|Win32
{F94CCADD-A90B-480C-A304-C19D015D36B1}.Release|Win32.ActiveCfg = Release|Win32
{F94CCADD-A90B-480C-A304-C19D015D36B1}.Release|Win32.Build.0 = Release|Win32
- {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.ActiveCfg = Release|Win32
- {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.Build.0 = Release|Win32
+ {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.Build.0 = Debug|Win32
{FFD738F7-96F0-445C-81EA-551665EF53D1}.Release|Win32.ActiveCfg = Release|Win32
{FFD738F7-96F0-445C-81EA-551665EF53D1}.Release|Win32.Build.0 = Release|Win32
- {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.ActiveCfg = Release|Win32
- {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.Build.0 = Release|Win32
+ {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.Build.0 = Debug|Win32
{08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Release|Win32.ActiveCfg = Release|Win32
{08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Release|Win32.Build.0 = Release|Win32
- {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.ActiveCfg = Release|Win32
- {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.Build.0 = Release|Win32
+ {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.ActiveCfg = Debug|Win32
+ {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.Build.0 = Debug|Win32
{54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Release|Win32.ActiveCfg = Release|Win32
{54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Release|Win32.Build.0 = Release|Win32
- {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Debug|Win32.ActiveCfg = Release|Win32
- {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Release|Win32.ActiveCfg = Release|Win32
+ {A9939CD7-BE1C-4334-947C-4C320D49B3CA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A9939CD7-BE1C-4334-947C-4C320D49B3CA}.Debug|Win32.Build.0 = Debug|Win32
+ {A9939CD7-BE1C-4334-947C-4C320D49B3CA}.Release|Win32.ActiveCfg = Release|Win32
+ {A9939CD7-BE1C-4334-947C-4C320D49B3CA}.Release|Win32.Build.0 = Release|Win32
+ {D73BC50F-956E-4A44-BF9F-A8BB80DF0000}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D73BC50F-956E-4A44-BF9F-A8BB80DF0000}.Debug|Win32.Build.0 = Debug|Win32
+ {D73BC50F-956E-4A44-BF9F-A8BB80DF0000}.Release|Win32.ActiveCfg = Release|Win32
+ {D73BC50F-956E-4A44-BF9F-A8BB80DF0000}.Release|Win32.Build.0 = Release|Win32
+ {440316C4-E19E-41DE-92A6-B78B3900E97F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {440316C4-E19E-41DE-92A6-B78B3900E97F}.Release|Win32.ActiveCfg = Release|Win32
+ {440316C4-E19E-41DE-92A6-B78B3900E97F}.Release|Win32.Build.0 = Release|Win32
+ {6B8EC880-702E-418A-BC63-CA46C6CC7B27}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6B8EC880-702E-418A-BC63-CA46C6CC7B27}.Debug|Win32.Build.0 = Debug|Win32
+ {6B8EC880-702E-418A-BC63-CA46C6CC7B27}.Release|Win32.ActiveCfg = Release|Win32
+ {6B8EC880-702E-418A-BC63-CA46C6CC7B27}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -183,6 +183,10 @@
>
</File>
<File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\portability.cpp"
>
</File>
@@ -190,6 +194,10 @@
RelativePath="..\..\..\src\utf8_codecvt_facet.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -187,6 +187,14 @@
RelativePath="..\..\..\src\path.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -190,6 +190,14 @@
RelativePath="..\..\..\src\path.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -189,9 +189,17 @@
>
</File>
<File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\portability.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -181,6 +181,10 @@
>
</File>
<File
+ RelativePath="..\..\..\src\path_traits.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\path_unit_test.cpp"
>
</File>
@@ -192,6 +196,10 @@
RelativePath="..\..\..\src\utf8_codecvt_facet.cpp"
>
</File>
+ <File
+ RelativePath="..\..\..\src\windows_file_codecvt.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,11 +1,11 @@
// Boost operations_test.cpp ---------------------------------------------------------//
-// Copyright Beman Dawes 2002.
+// Copyright Beman Dawes 2002, 2009.
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
#include <boost/config/warning_disable.hpp>
@@ -18,7 +18,7 @@
namespace fs = boost::filesystem;
#include <boost/config.hpp>
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
//#include <boost/concept_check.hpp>
using boost::system::error_code;
@@ -196,11 +196,11 @@
if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
// the stdcxx standard library apparently appends additional info
// to what(), so check only the initial portion:
- BOOST_CHECK( std::strncmp( x.what(),
+ BOOST_TEST( std::strncmp( x.what(),
"boost::filesystem::create_directory",
sizeof("boost::filesystem::create_directory")-1 ) == 0 );
}
- BOOST_CHECK( exception_thrown );
+ BOOST_TEST( exception_thrown );
// catch system_error
@@ -214,10 +214,10 @@
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_TEST( std::strcmp( x.what(),
"boost::filesystem::create_directory: The system cannot find the path specified" ) == 0 );
}
- BOOST_CHECK( exception_thrown );
+ BOOST_TEST( exception_thrown );
// catch filesystem_error by value
@@ -234,14 +234,14 @@
{
bool ok ( std::strcmp( x.what(),
"boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"" ) == 0 );
- BOOST_CHECK( ok );
+ BOOST_TEST( ok );
if ( !ok )
{
std::cout << "what returns \"" << x.what() << "\"" << std::endl;
}
}
}
- BOOST_CHECK( exception_thrown );
+ BOOST_TEST( exception_thrown );
// catch filesystem_error by const reference
@@ -258,14 +258,14 @@
{
bool ok ( std::strcmp( x.what(),
"boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"" ) == 0 );
- BOOST_CHECK( ok );
+ BOOST_TEST( ok );
if ( !ok )
{
std::cout << "what returns \"" << x.what() << "\"" << std::endl;
}
}
}
- BOOST_CHECK( exception_thrown );
+ BOOST_TEST( exception_thrown );
}
// directory_iterator_tests ----------------------------------------------//
@@ -277,98 +277,98 @@
bool dir_itr_exception(false);
try { fs::directory_iterator it( "" ); }
catch ( const fs::filesystem_error & ) { dir_itr_exception = true; }
- BOOST_CHECK( dir_itr_exception );
+ BOOST_TEST( dir_itr_exception );
dir_itr_exception = false;
try { fs::directory_iterator it( "nosuchdirectory" ); }
catch ( const fs::filesystem_error & ) { dir_itr_exception = true; }
- BOOST_CHECK( dir_itr_exception );
+ BOOST_TEST( dir_itr_exception );
dir_itr_exception = false;
try
{
error_code ec;
fs::directory_iterator it( "nosuchdirectory", ec );
- BOOST_CHECK( ec );
- BOOST_CHECK( ec == boost::system::errc::no_such_file_or_directory );
+ BOOST_TEST( ec );
+ BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory );
}
catch ( const fs::filesystem_error & ) { dir_itr_exception = true; }
- BOOST_CHECK( !dir_itr_exception );
+ BOOST_TEST( !dir_itr_exception );
{
// probe query function overloads
fs::directory_iterator dir_itr( dir );
- // BOOST_CHECK( fs::is_directory( *dir_itr ) );
- BOOST_CHECK( fs::is_directory( dir_itr->status() ) );
- // BOOST_CHECK( fs::is_directory( fs::symlink_status(*dir_itr) ) );
- BOOST_CHECK( fs::is_directory( dir_itr->symlink_status() ) );
- BOOST_CHECK( dir_itr->path().filename() == "d1" );
+ // BOOST_TEST( fs::is_directory( *dir_itr ) );
+ BOOST_TEST( fs::is_directory( dir_itr->status() ) );
+ // BOOST_TEST( fs::is_directory( fs::symlink_status(*dir_itr) ) );
+ BOOST_TEST( fs::is_directory( dir_itr->symlink_status() ) );
+ BOOST_TEST( dir_itr->path().filename() == "d1" );
}
// create a second directory named d2
d2 = dir / "d2";
fs::create_directory(d2 );
- BOOST_CHECK( fs::exists( d2 ) );
- BOOST_CHECK( fs::is_directory( d2 ) );
+ BOOST_TEST( fs::exists( d2 ) );
+ BOOST_TEST( fs::is_directory( d2 ) );
// test the basic operation of directory_iterators, and test that
// stepping one iterator doesn't affect a different iterator.
{
fs::directory_iterator dir_itr( dir );
- BOOST_CHECK( fs::exists(dir_itr->status()) );
- BOOST_CHECK( fs::is_directory(dir_itr->status()) );
- BOOST_CHECK( !fs::is_regular_file(dir_itr->status()) );
- BOOST_CHECK( !fs::is_other(dir_itr->status()) );
- BOOST_CHECK( !fs::is_symlink(dir_itr->status()) );
+ BOOST_TEST( fs::exists(dir_itr->status()) );
+ BOOST_TEST( fs::is_directory(dir_itr->status()) );
+ BOOST_TEST( !fs::is_regular_file(dir_itr->status()) );
+ BOOST_TEST( !fs::is_other(dir_itr->status()) );
+ BOOST_TEST( !fs::is_symlink(dir_itr->status()) );
fs::directory_iterator dir_itr2( dir );
- BOOST_CHECK( dir_itr->path().filename() == "d1"
+ BOOST_TEST( dir_itr->path().filename() == "d1"
|| dir_itr->path().filename() == "d2" );
- BOOST_CHECK( dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2" );
+ BOOST_TEST( dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2" );
if ( dir_itr->path().filename() == "d1" )
{
- BOOST_CHECK( (++dir_itr)->path().filename() == "d2" );
- BOOST_CHECK( dir_itr2->path().filename() == "d1" );
- BOOST_CHECK( (++dir_itr2)->path().filename() == "d2" );
+ BOOST_TEST( (++dir_itr)->path().filename() == "d2" );
+ BOOST_TEST( dir_itr2->path().filename() == "d1" );
+ BOOST_TEST( (++dir_itr2)->path().filename() == "d2" );
}
else
{
- BOOST_CHECK( dir_itr->path().filename() == "d2" );
- BOOST_CHECK( (++dir_itr)->path().filename() == "d1" );
- BOOST_CHECK( (dir_itr2)->path().filename() == "d2" );
- BOOST_CHECK( (++dir_itr2)->path().filename() == "d1" );
+ BOOST_TEST( dir_itr->path().filename() == "d2" );
+ BOOST_TEST( (++dir_itr)->path().filename() == "d1" );
+ BOOST_TEST( (dir_itr2)->path().filename() == "d2" );
+ BOOST_TEST( (++dir_itr2)->path().filename() == "d1" );
}
- BOOST_CHECK( ++dir_itr == fs::directory_iterator() );
- BOOST_CHECK( dir_itr2 != fs::directory_iterator() );
- BOOST_CHECK( ++dir_itr2 == fs::directory_iterator() );
+ BOOST_TEST( ++dir_itr == fs::directory_iterator() );
+ BOOST_TEST( dir_itr2 != fs::directory_iterator() );
+ BOOST_TEST( ++dir_itr2 == fs::directory_iterator() );
}
{ // *i++ must work to meet the standard's InputIterator requirements
fs::directory_iterator dir_itr( dir );
- BOOST_CHECK( dir_itr->path().filename() == "d1"
+ BOOST_TEST( dir_itr->path().filename() == "d1"
|| dir_itr->path().filename() == "d2" );
if ( dir_itr->path().filename() == "d1" )
{
- BOOST_CHECK( (*dir_itr++).path().filename() == "d1" );
- BOOST_CHECK( dir_itr->path().filename() == "d2" );
+ BOOST_TEST( (*dir_itr++).path().filename() == "d1" );
+ BOOST_TEST( dir_itr->path().filename() == "d2" );
}
else
{
// Check C++98 input iterator requirements
- BOOST_CHECK( (*dir_itr++).path().filename() == "d2" );
+ BOOST_TEST( (*dir_itr++).path().filename() == "d2" );
// input iterator requirements in the current WP would require this check:
- // BOOST_CHECK( implicit_cast<std::string const&>(*dir_itr++).filename() == "d1" );
+ // BOOST_TEST( implicit_cast<std::string const&>(*dir_itr++).filename() == "d1" );
- BOOST_CHECK( dir_itr->path().filename() == "d1" );
+ BOOST_TEST( dir_itr->path().filename() == "d1" );
}
// test case reported in comment to SourceForge bug tracker [937606]
fs::directory_iterator it( dir );
- const fs::path p1 = *it++;
- BOOST_CHECK( it != fs::directory_iterator() );
- const fs::path p2 = *it++;
- BOOST_CHECK( p1 != p2 );
- BOOST_CHECK( it == fs::directory_iterator() );
+ const fs::path p1 = (*it++).path();
+ BOOST_TEST( it != fs::directory_iterator() );
+ const fs::path p2 = (*it++).path();
+ BOOST_TEST( p1 != p2 );
+ BOOST_TEST( it == fs::directory_iterator() );
}
// Windows has a tricky special case when just the root-name is given,
@@ -378,15 +378,16 @@
{
fs::path root_name_path( fs::current_path().root_name() );
fs::directory_iterator it( root_name_path );
- BOOST_CHECK( it != fs::directory_iterator() );
- BOOST_CHECK( fs::exists( *it ) );
- BOOST_CHECK( it->path().parent_path() == root_name_path );
+ BOOST_TEST( it != fs::directory_iterator() );
+// BOOST_TEST( fs::exists( (*it).path() ) );
+ BOOST_TEST( fs::exists( it->path() ) );
+ BOOST_TEST( it->path().parent_path() == root_name_path );
bool found(false);
do
{
if ( it->path().filename() == temp_dir_name ) found = true;
} while ( ++it != fs::directory_iterator() );
- BOOST_CHECK( found );
+ BOOST_TEST( found );
}
// there was an inital bug in directory_iterator that caused premature
@@ -396,7 +397,7 @@
{
di = fs::directory_iterator( dir );
}
- BOOST_CHECK( ++di != fs::directory_iterator() );
+ BOOST_TEST( ++di != fs::directory_iterator() );
}
std::cout << " directory_iterator_tests complete" << std::endl;
@@ -411,8 +412,8 @@
fs::path from_ph( dir / "f3" );
fs::path file_ph( dir / "f1" );
- BOOST_CHECK( !fs::exists( from_ph ) );
- BOOST_CHECK( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::exists( from_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
bool create_hard_link_ok(true);
try { fs::create_hard_link( file_ph, from_ph ); }
catch ( const fs::filesystem_error & ex )
@@ -430,22 +431,22 @@
std::cout
<< " *** For information only ***\n"
" create_hard_link() succeeded\n";
- BOOST_CHECK( fs::exists( from_ph ) );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( fs::equivalent( from_ph, file_ph ) );
- BOOST_CHECK( fs::hard_link_count( from_ph ) == 2 );
- BOOST_CHECK( fs::hard_link_count( file_ph ) == 2 );
+ BOOST_TEST( fs::exists( from_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( fs::equivalent( from_ph, file_ph ) );
+ BOOST_TEST( fs::hard_link_count( from_ph ) == 2 );
+ BOOST_TEST( fs::hard_link_count( file_ph ) == 2 );
}
// Although tests may be running on a FAT or other file system that does
// not support hard links, that is unusual enough that it is considered
// a test failure.
- BOOST_CHECK( create_hard_link_ok );
+ BOOST_TEST( create_hard_link_ok );
error_code ec;
fs::create_hard_link( fs::path("doesnotexist"),
fs::path("shouldnotwork"), ec );
- BOOST_CHECK( ec );
+ BOOST_TEST( ec );
}
// create_symlink_tests --------------------------------------------------//
@@ -456,8 +457,8 @@
fs::path from_ph( dir / "f4" );
fs::path file_ph( dir / "f1" );
- BOOST_CHECK( !fs::exists( from_ph ) );
- BOOST_CHECK( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::exists( from_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
try { fs::create_symlink( file_ph, from_ph ); }
catch ( const fs::filesystem_error & ex )
{
@@ -474,45 +475,45 @@
std::cout
<< " *** For information only ***\n"
" create_symlink() succeeded\n";
- BOOST_CHECK( fs::exists( from_ph ) );
- BOOST_CHECK( fs::is_symlink( from_ph ) );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( fs::equivalent( from_ph, file_ph ) );
+ BOOST_TEST( fs::exists( from_ph ) );
+ BOOST_TEST( fs::is_symlink( from_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( fs::equivalent( from_ph, file_ph ) );
if ( platform == "POSIX" )
{
//std::cout << fs::read_symlink( from_ph ).string() << ", " << file_ph.string() << "\n";
- BOOST_CHECK( fs::read_symlink( from_ph ) == file_ph );
+ BOOST_TEST( fs::read_symlink( from_ph ) == file_ph );
}
fs::file_status stat = fs::symlink_status( from_ph );
- BOOST_CHECK( fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( !fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( fs::is_symlink( stat ) );
+ BOOST_TEST( fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( !fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( fs::is_symlink( stat ) );
stat = fs::status( from_ph );
- BOOST_CHECK( fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( !fs::is_symlink( stat ) );
+ BOOST_TEST( fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( !fs::is_symlink( stat ) );
// since create_symlink worked, copy_symlink should also work
fs::path symlink2_ph( dir / "symlink2" );
fs::copy_symlink( from_ph, symlink2_ph );
stat = fs::symlink_status( symlink2_ph );
- BOOST_CHECK( fs::is_symlink( stat ) );
- BOOST_CHECK( fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( !fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
+ BOOST_TEST( fs::is_symlink( stat ) );
+ BOOST_TEST( fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( !fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
}
error_code ec = error_code();
fs::create_symlink( "doesnotexist", "", ec );
- BOOST_CHECK( ec );
+ BOOST_TEST( ec );
}
// rename_tests ----------------------------------------------------------//
@@ -524,91 +525,91 @@
// rename() test case numbers refer to operations.htm#rename table
fs::path file_ph( dir / "f1" );
- BOOST_CHECK( fs::exists( file_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
// [case 1] make sure can't rename() a non-existent file
- BOOST_CHECK( !fs::exists( d1 / "f99" ) );
- BOOST_CHECK( !fs::exists( d1 / "f98" ) );
+ BOOST_TEST( !fs::exists( d1 / "f99" ) );
+ BOOST_TEST( !fs::exists( d1 / "f98" ) );
renamer n1a( d1 / "f99", d1 / "f98" );
- BOOST_CHECK( CHECK_EXCEPTION( n1a, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( n1a, ENOENT ) );
renamer n1b( fs::path(""), d1 / "f98" );
- BOOST_CHECK( CHECK_EXCEPTION( n1b, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( n1b, ENOENT ) );
// [case 2] rename() target.empty()
renamer n2( file_ph, "" );
- BOOST_CHECK( CHECK_EXCEPTION( n2, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( n2, ENOENT ) );
// [case 3] make sure can't rename() to an existent file or directory
- BOOST_CHECK( fs::exists( dir / "f1" ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( dir / "f1" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
renamer n3a( dir / "f1", d1 / "f2" );
- BOOST_CHECK( CHECK_EXCEPTION( n3a, EEXIST ) );
+ BOOST_TEST( CHECK_EXCEPTION( n3a, EEXIST ) );
// several POSIX implementations (cygwin, openBSD) report ENOENT instead of EEXIST,
// so we don't verify error type on the above test.
renamer n3b( dir, d1 );
- BOOST_CHECK( CHECK_EXCEPTION( n3b, 0 ) );
+ BOOST_TEST( CHECK_EXCEPTION( n3b, 0 ) );
// [case 4A] can't rename() file to a nonexistent parent directory
- BOOST_CHECK( !fs::is_directory( dir / "f1" ) );
- BOOST_CHECK( !fs::exists( dir / "d3/f3" ) );
+ BOOST_TEST( !fs::is_directory( dir / "f1" ) );
+ BOOST_TEST( !fs::exists( dir / "d3/f3" ) );
renamer n4a( dir / "f1", dir / "d3/f3" );
- BOOST_CHECK( CHECK_EXCEPTION( n4a, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( n4a, ENOENT ) );
// [case 4B] rename() file in same directory
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::exists( d1 / "f50" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::exists( d1 / "f50" ) );
fs::rename( d1 / "f2", d1 / "f50" );
- BOOST_CHECK( !fs::exists( d1 / "f2" ) );
- BOOST_CHECK( fs::exists( d1 / "f50" ) );
+ BOOST_TEST( !fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( d1 / "f50" ) );
fs::rename( d1 / "f50", d1 / "f2" );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::exists( d1 / "f50" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::exists( d1 / "f50" ) );
// [case 4C] rename() file d1/f2 to d2/f3
fs::rename( d1 / "f2", d2 / "f3" );
- BOOST_CHECK( !fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::exists( d2 / "f2" ) );
- BOOST_CHECK( fs::exists( d2 / "f3" ) );
- BOOST_CHECK( !fs::is_directory( d2 / "f3" ) );
+ BOOST_TEST( !fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::exists( d2 / "f2" ) );
+ BOOST_TEST( fs::exists( d2 / "f3" ) );
+ BOOST_TEST( !fs::is_directory( d2 / "f3" ) );
verify_file( d2 / "f3", "foobar1" );
fs::rename( d2 / "f3", d1 / "f2" );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
// [case 5A] rename() directory to nonexistent parent directory
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( !fs::exists( dir / "d3/d5" ) );
- BOOST_CHECK( !fs::exists( dir / "d3" ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( !fs::exists( dir / "d3/d5" ) );
+ BOOST_TEST( !fs::exists( dir / "d3" ) );
renamer n5a( d1, dir / "d3/d5" );
- BOOST_CHECK( CHECK_EXCEPTION( n5a, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( n5a, ENOENT ) );
// [case 5B] rename() on directory
fs::path d3( dir / "d3" );
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::exists( d3 ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::exists( d3 ) );
fs::rename( d1, d3 );
- BOOST_CHECK( !fs::exists( d1 ) );
- BOOST_CHECK( fs::exists( d3 ) );
- BOOST_CHECK( fs::is_directory( d3 ) );
- BOOST_CHECK( !fs::exists( d1 / "f2" ) );
- BOOST_CHECK( fs::exists( d3 / "f2" ) );
+ BOOST_TEST( !fs::exists( d1 ) );
+ BOOST_TEST( fs::exists( d3 ) );
+ BOOST_TEST( fs::is_directory( d3 ) );
+ BOOST_TEST( !fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( d3 / "f2" ) );
fs::rename( d3, d1 );
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::exists( d3 ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::exists( d3 ) );
// [case 5C] rename() rename and move d1 to d2 / "d20"
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( !fs::exists( d2 / "d20" ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( !fs::exists( d2 / "d20" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
fs::rename( d1, d2 / "d20" );
- BOOST_CHECK( !fs::exists( d1 ) );
- BOOST_CHECK( fs::exists( d2 / "d20" ) );
- BOOST_CHECK( fs::exists( d2 / "d20" / "f2" ) );
+ BOOST_TEST( !fs::exists( d1 ) );
+ BOOST_TEST( fs::exists( d2 / "d20" ) );
+ BOOST_TEST( fs::exists( d2 / "d20" / "f2" ) );
fs::rename( d2 / "d20", d1 );
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( !fs::exists( d2 / "d20" ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( !fs::exists( d2 / "d20" ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
}
// predicate_and_status_tests --------------------------------------------//
@@ -617,24 +618,24 @@
{
std::cout << "predicate_and_status_tests..." << std::endl;
- BOOST_CHECK( !fs::exists( ng ) );
- BOOST_CHECK( !fs::is_directory( ng ) );
- BOOST_CHECK( !fs::is_regular_file( ng ) );
- BOOST_CHECK( !fs::is_symlink( ng ) );
+ BOOST_TEST( !fs::exists( ng ) );
+ BOOST_TEST( !fs::is_directory( ng ) );
+ BOOST_TEST( !fs::is_regular_file( ng ) );
+ BOOST_TEST( !fs::is_symlink( ng ) );
fs::file_status stat( fs::status( ng ) );
- BOOST_CHECK( fs::status_known( stat ) );
- BOOST_CHECK( !fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( !fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( !fs::is_symlink( stat ) );
+ BOOST_TEST( fs::status_known( stat ) );
+ BOOST_TEST( !fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( !fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( !fs::is_symlink( stat ) );
stat = fs::status( "" );
- BOOST_CHECK( fs::status_known( stat ) );
- BOOST_CHECK( !fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( !fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( !fs::is_symlink( stat ) );
+ BOOST_TEST( fs::status_known( stat ) );
+ BOOST_TEST( !fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( !fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( !fs::is_symlink( stat ) );
}
// create_directory_tests ------------------------------------------------//
@@ -669,18 +670,18 @@
std::exit(1);
}
- BOOST_CHECK( fs::exists( dir ) );
- BOOST_CHECK( BOOST_FS_IS_EMPTY( dir ) );
- BOOST_CHECK( fs::is_directory( dir ) );
- BOOST_CHECK( !fs::is_regular_file( dir ) );
- BOOST_CHECK( !fs::is_other( dir ) );
- BOOST_CHECK( !fs::is_symlink( dir ) );
+ BOOST_TEST( fs::exists( dir ) );
+ BOOST_TEST( BOOST_FS_IS_EMPTY( dir ) );
+ BOOST_TEST( fs::is_directory( dir ) );
+ BOOST_TEST( !fs::is_regular_file( dir ) );
+ BOOST_TEST( !fs::is_other( dir ) );
+ BOOST_TEST( !fs::is_symlink( dir ) );
fs::file_status stat = fs::status( dir );
- BOOST_CHECK( fs::exists( stat ) );
- BOOST_CHECK( fs::is_directory( stat ) );
- BOOST_CHECK( !fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( !fs::is_symlink( stat ) );
+ BOOST_TEST( fs::exists( stat ) );
+ BOOST_TEST( fs::is_directory( stat ) );
+ BOOST_TEST( !fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( !fs::is_symlink( stat ) );
std::cout << " create_directory_tests complete" << std::endl;
}
@@ -693,21 +694,21 @@
// set the current directory, then check it for consistency
fs::path original_dir = fs::current_path();
- BOOST_CHECK( dir != original_dir );
+ BOOST_TEST( dir != original_dir );
fs::current_path( dir );
- BOOST_CHECK( fs::current_path() == dir );
- BOOST_CHECK( fs::current_path() != original_dir );
+ BOOST_TEST( fs::current_path() == dir );
+ BOOST_TEST( fs::current_path() != original_dir );
fs::current_path( original_dir );
- BOOST_CHECK( fs::current_path() == original_dir );
- BOOST_CHECK( fs::current_path() != dir );
+ BOOST_TEST( fs::current_path() == original_dir );
+ BOOST_TEST( fs::current_path() != dir );
// make sure the overloads work
fs::current_path( dir.string().c_str() );
- BOOST_CHECK( fs::current_path() == dir );
- BOOST_CHECK( fs::current_path() != original_dir );
+ BOOST_TEST( fs::current_path() == dir );
+ BOOST_TEST( fs::current_path() != original_dir );
fs::current_path( original_dir.string() );
- BOOST_CHECK( fs::current_path() == original_dir );
- BOOST_CHECK( fs::current_path() != dir );
+ BOOST_TEST( fs::current_path() == original_dir );
+ BOOST_TEST( fs::current_path() != dir );
}
// create_directories_tests ----------------------------------------------//
@@ -718,10 +719,10 @@
fs::path p = dir / "level1" / "level2";
- BOOST_CHECK( !fs::exists( p ) );
- BOOST_CHECK( fs::create_directories( p ) );
- BOOST_CHECK( fs::exists( p ) );
- BOOST_CHECK( fs::is_directory( p ) );
+ BOOST_TEST( !fs::exists( p ) );
+ BOOST_TEST( fs::create_directories( p ) );
+ BOOST_TEST( fs::exists( p ) );
+ BOOST_TEST( fs::is_directory( p ) );
}
// _tests ----------------------------------------------------//
@@ -735,11 +736,11 @@
//------------------------------------------------------------------------------------//
// //
- // test_main //
+ // main //
// //
//------------------------------------------------------------------------------------//
-int test_main( int argc, char * argv[] )
+int main( int argc, char * argv[] )
{
if ( argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='t' ) report_throws = true;
if ( argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='x' ) cleanup = false;
@@ -771,18 +772,18 @@
std::cout << "\ninitial_path().string() is\n \""
<< fs::initial_path().string()
<< "\"\n\n";
- BOOST_CHECK( fs::initial_path().is_complete() );
- BOOST_CHECK( fs::current_path().is_complete() );
- BOOST_CHECK( fs::initial_path().string()
+ BOOST_TEST( fs::initial_path().is_complete() );
+ BOOST_TEST( fs::current_path().is_complete() );
+ BOOST_TEST( fs::initial_path().string()
== fs::current_path().string() );
- BOOST_CHECK( fs::complete( "" ).empty() );
+ BOOST_TEST( fs::complete( "" ).empty() );
fs::path px1 = fs::complete( "/" );
fs::path px2 = fs::initial_path().root_path();
- BOOST_CHECK( px1 == px2 );
- BOOST_CHECK( fs::complete( "foo" ) == fs::initial_path().string()+"/foo" );
- BOOST_CHECK( fs::complete( "/foo" ) == fs::initial_path().root_path().string()+"foo" );
- BOOST_CHECK( fs::complete( "foo", fs::path( "//net/bar" ) )
+ BOOST_TEST( px1 == px2 );
+ BOOST_TEST( fs::complete( "foo" ) == fs::initial_path().string()+"/foo" );
+ BOOST_TEST( fs::complete( "/foo" ) == fs::initial_path().root_path().string()+"foo" );
+ BOOST_TEST( fs::complete( "foo", fs::path( "//net/bar" ) )
== "//net/bar/foo" );
predicate_and_status_tests();
@@ -794,7 +795,7 @@
std::cout << "remove residue from prior failed tests..." << std::endl;
fs::remove_all( dir );
}
- BOOST_CHECK( !fs::exists( dir ) );
+ BOOST_TEST( !fs::exists( dir ) );
create_directory_tests();
@@ -804,71 +805,76 @@
std::cout << "Window specific tests..."
"\n (may take several seconds)" << std::endl;
- BOOST_CHECK( !fs::exists( fs::path( "//share-not" ) ) );
- BOOST_CHECK( !fs::exists( fs::path( "//share-not/" ) ) );
- BOOST_CHECK( !fs::exists( fs::path( "//share-not/foo" ) ) );
- BOOST_CHECK( !fs::exists( "tools/jam/src/:sys:stat.h" ) ); // !exists() if ERROR_INVALID_NAME
- BOOST_CHECK( !fs::exists( ":sys:stat.h" ) ); // !exists() if ERROR_INVALID_PARAMETER
- BOOST_CHECK( dir.string().size() > 1
+ BOOST_TEST( !fs::exists( fs::path( "//share-not" ) ) );
+ BOOST_TEST( !fs::exists( fs::path( "//share-not/" ) ) );
+ BOOST_TEST( !fs::exists( fs::path( "//share-not/foo" ) ) );
+ BOOST_TEST( !fs::exists( "tools/jam/src/:sys:stat.h" ) ); // !exists() if ERROR_INVALID_NAME
+ BOOST_TEST( !fs::exists( ":sys:stat.h" ) ); // !exists() if ERROR_INVALID_PARAMETER
+ BOOST_TEST( dir.string().size() > 1
&& dir.string()[1] == ':' ); // verify path includes drive
- BOOST_CHECK( fs::system_complete( "" ).empty() );
- BOOST_CHECK( fs::system_complete( "/" ).string()
- == fs::initial_path().root_path().string() );
- BOOST_CHECK( fs::system_complete( "foo" )
+ BOOST_TEST( fs::system_complete( "" ).empty() );
+ BOOST_TEST( fs::system_complete( "/" ) == fs::initial_path().root_path() );
+ BOOST_TEST( fs::system_complete( "foo" )
== fs::initial_path() / "foo" );
- BOOST_CHECK( fs::system_complete( "/foo" ).string()
- == fs::initial_path().root_path().string()+"foo" );
- BOOST_CHECK( fs::complete( fs::path( "c:/" ) ).string()
+
+ fs::path p1( fs::system_complete( "/foo" ) );
+ BOOST_TEST_EQ( p1.size(), 6 ); // this failed during v3 development due to bug
+ std::string s1( p1.string() );
+ std::string s2( fs::initial_path().root_path().string()+"foo" );
+ BOOST_TEST_EQ( s1, s2 );
+
+ BOOST_TEST( fs::complete( fs::path( "c:/" ) ).string()
== "c:/" );
- BOOST_CHECK( fs::complete( fs::path( "c:/foo" ) ).string()
+ BOOST_TEST( fs::complete( fs::path( "c:/foo" ) ).string()
== "c:/foo" );
- BOOST_CHECK( fs::system_complete( fs::path( fs::initial_path().root_name() ) ).string() == fs::initial_path().string() );
- BOOST_CHECK( fs::system_complete( fs::path( fs::initial_path().root_name().string()
+ BOOST_TEST( fs::system_complete( fs::path( fs::initial_path().root_name() ) )
+ == fs::initial_path() );
+ BOOST_TEST( fs::system_complete( fs::path( fs::initial_path().root_name().string()
+ "foo" ) ).string() == fs::initial_path() / "foo" );
- BOOST_CHECK( fs::system_complete( fs::path( "c:/" ) ).generic()
+ BOOST_TEST( fs::system_complete( fs::path( "c:/" ) ).generic()
== "c:/" );
- BOOST_CHECK( fs::system_complete( fs::path( "c:/foo" ) ).generic()
+ BOOST_TEST( fs::system_complete( fs::path( "c:/foo" ) ).generic()
== "c:/foo" );
- BOOST_CHECK( fs::system_complete( fs::path( "//share" ) ).generic()
+ BOOST_TEST( fs::system_complete( fs::path( "//share" ) ).generic()
== "//share" );
} // Windows
else if ( platform == "POSIX" )
{
std::cout << "POSIX specific tests..." << std::endl;
- BOOST_CHECK( fs::system_complete( "" ).empty() );
- BOOST_CHECK( fs::initial_path().root_path().string() == "/" );
- BOOST_CHECK( fs::system_complete( "/" ).string() == "/" );
- BOOST_CHECK( fs::system_complete( "foo" ).string()
+ BOOST_TEST( fs::system_complete( "" ).empty() );
+ BOOST_TEST( fs::initial_path().root_path().string() == "/" );
+ BOOST_TEST( fs::system_complete( "/" ).string() == "/" );
+ BOOST_TEST( fs::system_complete( "foo" ).string()
== fs::initial_path().string()+"/foo" );
- BOOST_CHECK( fs::system_complete( "/foo" ).string()
+ BOOST_TEST( fs::system_complete( "/foo" ).string()
== fs::initial_path().root_path().string()+"foo" );
} // POSIX
// the bound functions should throw, so CHECK_EXCEPTION() should return true
- BOOST_CHECK( CHECK_EXCEPTION( bad_file_size, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_file_size, ENOENT ) );
// test path::exception members
try { fs::file_size( ng ); } // will throw
catch ( const fs::filesystem_error & ex )
{
- BOOST_CHECK( ex.path1().string() == " no-way, Jose" );
+ BOOST_TEST( ex.path1().string() == " no-way, Jose" );
}
// several functions give unreasonable results if uintmax_t isn't 64-bits
std::cout << "sizeof(boost::uintmax_t) = " << sizeof(boost::uintmax_t) << '\n';
- BOOST_CHECK( sizeof( boost::uintmax_t ) >= 8 );
+ BOOST_TEST( sizeof( boost::uintmax_t ) >= 8 );
current_directory_tests();
// make some reasonable assuptions for testing purposes
fs::space_info spi( fs::space( dir ) );
- BOOST_CHECK( spi.capacity > 1000000 );
- BOOST_CHECK( spi.free > 1000 );
- BOOST_CHECK( spi.capacity > spi.free );
- BOOST_CHECK( spi.free >= spi.available );
+ BOOST_TEST( spi.capacity > 1000000 );
+ BOOST_TEST( spi.free > 1000 );
+ BOOST_TEST( spi.capacity > spi.free );
+ BOOST_TEST( spi.free >= spi.available );
// it is convenient to display space, but older VC++ versions choke
# if !defined(BOOST_MSVC) || _MSC_VER >= 1300 // 1300 == VC++ 7.0
@@ -878,20 +884,20 @@
# endif
if ( platform == "Windows" )
- BOOST_CHECK( CHECK_EXCEPTION( bad_directory_size, ENOENT ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, ENOENT ) );
else
- BOOST_CHECK( CHECK_EXCEPTION( bad_directory_size, 0 ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, 0 ) );
- BOOST_CHECK( !fs::create_directory( dir ) );
+ BOOST_TEST( !fs::create_directory( dir ) );
- BOOST_CHECK( !fs::is_symlink( dir ) );
- BOOST_CHECK( !fs::is_symlink( "nosuchfileordirectory" ) );
+ BOOST_TEST( !fs::is_symlink( dir ) );
+ BOOST_TEST( !fs::is_symlink( "nosuchfileordirectory" ) );
d1 = dir / "d1";
- BOOST_CHECK( fs::create_directory( d1 ) );
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( fs::is_directory( d1 ) );
- BOOST_CHECK( BOOST_FS_IS_EMPTY( d1 ) );
+ BOOST_TEST( fs::create_directory( d1 ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( fs::is_directory( d1 ) );
+ BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) );
directory_iterator_tests();
create_directories_tests(); // must run AFTER directory_iterator_tests
@@ -899,44 +905,44 @@
// create an empty file named "f0"
fs::path file_ph( dir / "f0");
create_file( file_ph, "" );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::is_directory( file_ph ) );
- BOOST_CHECK( fs::is_regular_file( file_ph ) );
- BOOST_CHECK( BOOST_FS_IS_EMPTY( file_ph ) );
- BOOST_CHECK( fs::file_size( file_ph ) == 0 );
- BOOST_CHECK( fs::hard_link_count( file_ph ) == 1 );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::is_directory( file_ph ) );
+ BOOST_TEST( fs::is_regular_file( file_ph ) );
+ BOOST_TEST( BOOST_FS_IS_EMPTY( file_ph ) );
+ BOOST_TEST( fs::file_size( file_ph ) == 0 );
+ BOOST_TEST( fs::hard_link_count( file_ph ) == 1 );
bad_create_directory_path = file_ph;
- BOOST_CHECK( CHECK_EXCEPTION( bad_create_directory, EEXIST ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_create_directory, EEXIST ) );
fs::file_status stat = fs::status( file_ph );
- BOOST_CHECK( fs::status_known( stat ) );
- BOOST_CHECK( fs::exists( stat ) );
- BOOST_CHECK( !fs::is_directory( stat ) );
- BOOST_CHECK( fs::is_regular_file( stat ) );
- BOOST_CHECK( !fs::is_other( stat ) );
- BOOST_CHECK( !fs::is_symlink( stat ) );
+ BOOST_TEST( fs::status_known( stat ) );
+ BOOST_TEST( fs::exists( stat ) );
+ BOOST_TEST( !fs::is_directory( stat ) );
+ BOOST_TEST( fs::is_regular_file( stat ) );
+ BOOST_TEST( !fs::is_other( stat ) );
+ BOOST_TEST( !fs::is_symlink( stat ) );
// create a file named "f1"
file_ph = dir / "f1";
create_file( file_ph, "foobar1" );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::is_directory( file_ph ) );
- BOOST_CHECK( fs::is_regular_file( file_ph ) );
- BOOST_CHECK( fs::file_size( file_ph ) == 7 );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::is_directory( file_ph ) );
+ BOOST_TEST( fs::is_regular_file( file_ph ) );
+ BOOST_TEST( fs::file_size( file_ph ) == 7 );
verify_file( file_ph, "foobar1" );
// equivalence tests
- BOOST_CHECK( CHECK_EXCEPTION( bad_equivalent, ENOENT ) );
- BOOST_CHECK( fs::equivalent( file_ph, dir / "f1" ) );
- BOOST_CHECK( fs::equivalent( dir, d1 / ".." ) );
- BOOST_CHECK( !fs::equivalent( file_ph, dir ) );
- BOOST_CHECK( !fs::equivalent( dir, file_ph ) );
- BOOST_CHECK( !fs::equivalent( d1, d2 ) );
- BOOST_CHECK( !fs::equivalent( dir, ng ) );
- BOOST_CHECK( !fs::equivalent( ng, dir ) );
- BOOST_CHECK( !fs::equivalent( file_ph, ng ) );
- BOOST_CHECK( !fs::equivalent( ng, file_ph ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_equivalent, ENOENT ) );
+ BOOST_TEST( fs::equivalent( file_ph, dir / "f1" ) );
+ BOOST_TEST( fs::equivalent( dir, d1 / ".." ) );
+ BOOST_TEST( !fs::equivalent( file_ph, dir ) );
+ BOOST_TEST( !fs::equivalent( dir, file_ph ) );
+ BOOST_TEST( !fs::equivalent( d1, d2 ) );
+ BOOST_TEST( !fs::equivalent( dir, ng ) );
+ BOOST_TEST( !fs::equivalent( ng, dir ) );
+ BOOST_TEST( !fs::equivalent( file_ph, ng ) );
+ BOOST_TEST( !fs::equivalent( ng, file_ph ) );
create_hard_link_tests();
create_symlink_tests();
@@ -945,9 +951,9 @@
std::cout << "begin copy_file test..." << std::endl;
fs::copy_file( file_ph, d1 / "f2" );
std::cout << "copying complete" << std::endl;
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( fs::exists( d1 / "f2" ) );
- BOOST_CHECK( !fs::is_directory( d1 / "f2" ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( fs::exists( d1 / "f2" ) );
+ BOOST_TEST( !fs::is_directory( d1 / "f2" ) );
verify_file( d1 / "f2", "foobar1" );
std::cout << "copy_file test complete" << std::endl;
@@ -955,95 +961,95 @@
// remove() file
file_ph = dir / "shortlife";
- BOOST_CHECK( !fs::exists( file_ph ) );
+ BOOST_TEST( !fs::exists( file_ph ) );
create_file( file_ph, "" );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::is_directory( file_ph ) );
- BOOST_CHECK( fs::remove( file_ph ) );
- BOOST_CHECK( !fs::exists( file_ph ) );
- BOOST_CHECK( !fs::remove( "no-such-file" ) );
- BOOST_CHECK( !fs::remove( "no-such-directory/no-such-file" ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::is_directory( file_ph ) );
+ BOOST_TEST( fs::remove( file_ph ) );
+ BOOST_TEST( !fs::exists( file_ph ) );
+ BOOST_TEST( !fs::remove( "no-such-file" ) );
+ BOOST_TEST( !fs::remove( "no-such-directory/no-such-file" ) );
// remove() directory
d1 = dir / "shortlife_dir";
- BOOST_CHECK( !fs::exists( d1 ) );
+ BOOST_TEST( !fs::exists( d1 ) );
fs::create_directory( d1 );
- BOOST_CHECK( fs::exists( d1 ) );
- BOOST_CHECK( fs::is_directory( d1 ) );
- BOOST_CHECK( BOOST_FS_IS_EMPTY( d1 ) );
+ BOOST_TEST( fs::exists( d1 ) );
+ BOOST_TEST( fs::is_directory( d1 ) );
+ BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) );
bad_remove_dir = dir;
- BOOST_CHECK( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) );
- BOOST_CHECK( fs::remove( d1 ) );
- BOOST_CHECK( !fs::exists( d1 ) );
+ BOOST_TEST( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) );
+ BOOST_TEST( fs::remove( d1 ) );
+ BOOST_TEST( !fs::exists( d1 ) );
if ( create_symlink_ok ) // only if symlinks supported
{
// remove() dangling symbolic link
fs::path link( "dangling_link" );
fs::remove( link ); // remove any residue from past tests
- BOOST_CHECK( !fs::is_symlink( link ) );
- BOOST_CHECK( !fs::exists( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
+ BOOST_TEST( !fs::exists( link ) );
fs::create_symlink( "nowhere", link );
- BOOST_CHECK( !fs::exists( link ) );
- BOOST_CHECK( fs::is_symlink( link ) );
- BOOST_CHECK( fs::remove( link ) );
- BOOST_CHECK( !fs::is_symlink( link ) );
+ BOOST_TEST( !fs::exists( link ) );
+ BOOST_TEST( fs::is_symlink( link ) );
+ BOOST_TEST( fs::remove( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
// remove() self-refering symbolic link
link = "link_to_self";
fs::remove( link ); // remove any residue from past tests
- BOOST_CHECK( !fs::is_symlink( link ) );
- BOOST_CHECK( !fs::exists( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
+ BOOST_TEST( !fs::exists( link ) );
fs::create_symlink( link, link );
- BOOST_CHECK( fs::remove( link ) );
- BOOST_CHECK( !fs::exists( link ) );
- BOOST_CHECK( !fs::is_symlink( link ) );
+ BOOST_TEST( fs::remove( link ) );
+ BOOST_TEST( !fs::exists( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
// remove() cyclic symbolic link
link = "link_to_a";
fs::path link2( "link_to_b" );
fs::remove( link ); // remove any residue from past tests
fs::remove( link2 ); // remove any residue from past tests
- BOOST_CHECK( !fs::is_symlink( link ) );
- BOOST_CHECK( !fs::exists( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
+ BOOST_TEST( !fs::exists( link ) );
fs::create_symlink( link, link2 );
fs::create_symlink( link2, link );
- BOOST_CHECK( fs::remove( link ) );
- BOOST_CHECK( fs::remove( link2 ) );
- BOOST_CHECK( !fs::exists( link ) );
- BOOST_CHECK( !fs::exists( link2 ) );
- BOOST_CHECK( !fs::is_symlink( link ) );
+ BOOST_TEST( fs::remove( link ) );
+ BOOST_TEST( fs::remove( link2 ) );
+ BOOST_TEST( !fs::exists( link ) );
+ BOOST_TEST( !fs::exists( link2 ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
// remove() symbolic link to file
file_ph = "link_target";
fs::remove( file_ph ); // remove any residue from past tests
- BOOST_CHECK( !fs::exists( file_ph ) );
+ BOOST_TEST( !fs::exists( file_ph ) );
create_file( file_ph, "" );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::is_directory( file_ph ) );
- BOOST_CHECK( fs::is_regular_file( file_ph ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::is_directory( file_ph ) );
+ BOOST_TEST( fs::is_regular_file( file_ph ) );
link = "non_dangling_link";
fs::create_symlink( file_ph, link );
- BOOST_CHECK( fs::exists( link ) );
- BOOST_CHECK( !fs::is_directory( link ) );
- BOOST_CHECK( fs::is_regular_file( link ) );
- BOOST_CHECK( fs::is_symlink( link ) );
- BOOST_CHECK( fs::remove( link ) );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::exists( link ) );
- BOOST_CHECK( !fs::is_symlink( link ) );
- BOOST_CHECK( fs::remove( file_ph ) );
- BOOST_CHECK( !fs::exists( file_ph ) );
+ BOOST_TEST( fs::exists( link ) );
+ BOOST_TEST( !fs::is_directory( link ) );
+ BOOST_TEST( fs::is_regular_file( link ) );
+ BOOST_TEST( fs::is_symlink( link ) );
+ BOOST_TEST( fs::remove( link ) );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::exists( link ) );
+ BOOST_TEST( !fs::is_symlink( link ) );
+ BOOST_TEST( fs::remove( file_ph ) );
+ BOOST_TEST( !fs::exists( file_ph ) );
}
// write time tests
file_ph = dir / "foobar2";
create_file( file_ph, "foobar2" );
- BOOST_CHECK( fs::exists( file_ph ) );
- BOOST_CHECK( !fs::is_directory( file_ph ) );
- BOOST_CHECK( fs::is_regular_file( file_ph ) );
- BOOST_CHECK( fs::file_size( file_ph ) == 7 );
+ BOOST_TEST( fs::exists( file_ph ) );
+ BOOST_TEST( !fs::is_directory( file_ph ) );
+ BOOST_TEST( fs::is_regular_file( file_ph ) );
+ BOOST_TEST( fs::file_size( file_ph ) == 7 );
verify_file( file_ph, "foobar2" );
// Some file system report last write time as local (FAT), while
@@ -1062,7 +1068,7 @@
std::time_t ft2 = fs::last_write_time( file_ph );
std::cout << "last_write_time() for the file is now "
<< std::asctime(std::gmtime(&ft2)) << std::endl;
- BOOST_CHECK( ft != fs::last_write_time( file_ph ) );
+ BOOST_TEST( ft != fs::last_write_time( file_ph ) );
std::cout << "\nReset to current time" << std::endl;
@@ -1071,17 +1077,17 @@
std::cout
<< "original last_write_time() - current last_write_time() is "
<< time_diff << " seconds" << std::endl;
- BOOST_CHECK( time_diff >= -60.0 && time_diff <= 60.0 );
+ BOOST_TEST( time_diff >= -60.0 && time_diff <= 60.0 );
// post-test cleanup
if ( cleanup )
{
- BOOST_CHECK( fs::remove_all( dir ) != 0 );
+ BOOST_TEST( fs::remove_all( dir ) != 0 );
// above was added just to simplify testing, but it ended up detecting
// a bug (failure to close an internal search handle).
- BOOST_CHECK( !fs::exists( dir ) );
- BOOST_CHECK( fs::remove_all( dir ) == 0 );
+ BOOST_TEST( !fs::exists( dir ) );
+ BOOST_TEST( fs::remove_all( dir ) == 0 );
}
- return 0;
+ return ::boost::report_errors();
} // main
Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -2,14 +2,15 @@
// Copyright Beman Dawes 2008
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
#include <iostream>
#include <boost/filesystem/operations.hpp>
#include <boost/system/error_code.hpp>
+#include <boost/detail/lightweight_test.hpp>
using namespace boost::filesystem;
using namespace boost::system;
@@ -20,7 +21,6 @@
namespace
{
- int errors;
std::string this_file;
@@ -28,7 +28,7 @@
{
if ( ok ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file << '(' << line << "): test failed\n";
}
@@ -53,7 +53,7 @@
CHECK( !is_directory( this_file ) );
CHECK( is_regular_file( this_file ) );
- CHECK( !is_empty( this_file ) );
+ CHECK( !boost::filesystem::is_empty( this_file ) );
CHECK( !is_other( this_file ) );
}
@@ -87,15 +87,13 @@
CHECK( !is_symlink( it->symlink_status() ) );
}
-
for ( ; it != end; ++it )
{
// cout << " " << it->path().string() << "\n";
}
std::cout << "directory_iterator_test complete" << std::endl;
-}
-
+ }
// operations_test -------------------------------------------------------//
@@ -122,16 +120,25 @@
std::time_t ft = last_write_time( "." );
last_write_time( ".", std::time_t(-1), ec );
+ }
+
+ // directory_entry_overload_test ---------------------------------------------------//
+ void directory_entry_overload_test()
+ {
+ std::cout << "directory_entry overload test..." << std::endl;
+
+ directory_iterator it( "." );
+ path p( *it );
}
} // unnamed namespace
- //------------------------------------------------------------------------------------//
- // //
- // test_main //
- // //
- //------------------------------------------------------------------------------------//
+//--------------------------------------------------------------------------------------//
+// //
+// main //
+// //
+//--------------------------------------------------------------------------------------//
int main( int argc, char * argv[] )
{
@@ -142,13 +149,20 @@
// error handling tests
bool threw( false );
- try { file_size( "no-such-file" ); }
- catch ( const filesystem_error & ex )
+ try
+ {
+ file_size( "no-such-file" );
+ }
+ catch ( const boost::filesystem::filesystem_error & ex )
{
threw = true;
cout << "\nas expected, attempt to get size of non-existent file threw a filesystem_error\n"
"what() returns " << ex.what() << "\n";
}
+ catch ( ... )
+ {
+ cout << "\nunexpected exception type caught" << std::endl;
+ }
CHECK( threw );
@@ -158,7 +172,7 @@
query_test();
directory_iterator_test();
operations_test();
+ directory_entry_overload_test();
- cout << errors << " errors detected\n";
- return errors;
+ return ::boost::report_errors();
}
Modified: sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -30,7 +30,7 @@
using boost::next;
using boost::prior;
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
#define PATH_CHECK( a, b ) check( a, b, __FILE__, __LINE__ )
#define DIR_CHECK( a, b ) check_dir( a, b, __FILE__, __LINE__ )
@@ -41,19 +41,17 @@
{
std::string platform( BOOST_PLATFORM );
- int errors;
-
void check( const fs::path & source,
const std::string & expected, const char* file, int line )
{
if ( source.string()== expected ) return;
- ++errors;
-
std::cout << file
<< '(' << line << "): source.string(): \"" << source.string()
<< "\" != expected: \"" << expected
<< "\"" << std::endl;
+
+ BOOST_ERROR(0); // increment error count
}
void check_dir( const fs::path & source,
@@ -61,7 +59,7 @@
{
if ( source.string() == expected ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file << '(' << line << "): source.directory_string(): \""
<< source.string()
@@ -74,7 +72,7 @@
{
if ( source == expected ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file << '(' << line << "): source: \"" << source.string()
<< "\" != expected: \"" << expected
@@ -98,20 +96,20 @@
catch ( const fs::filesystem_error & ex )
{
//std::cout << ex.what() << "*" << std::endl;
- //BOOST_CHECK( std::strcmp( ex.what(),
+ //BOOST_TEST( std::strcmp( ex.what(),
// "string-1: Unknown error" ) == 0 );
- BOOST_CHECK( ex.code() == ec );
+ BOOST_TEST( ex.code() == ec );
}
try { throw fs::filesystem_error( str_1, "p1", "p2", ec ); }
catch ( const fs::filesystem_error & ex )
{
//std::cout << ex.what() << "*" << std::endl;
- //BOOST_CHECK( std::strcmp( ex.what(),
+ //BOOST_TEST( std::strcmp( ex.what(),
// "string-1: Unknown error: \"p1\", \"p2\"" ) == 0 );
- BOOST_CHECK( ex.code() == ec );
- BOOST_CHECK( ex.path1().string() == "p1" );
- BOOST_CHECK( ex.path2().string() == "p2" );
+ BOOST_TEST( ex.code() == ec );
+ BOOST_TEST( ex.path1().string() == "p1" );
+ BOOST_TEST( ex.path2().string() == "p2" );
}
}
@@ -148,35 +146,35 @@
path itr_ck = "";
path::const_iterator itr = itr_ck.begin();
- BOOST_CHECK( itr == itr_ck.end() );
+ BOOST_TEST( itr == itr_ck.end() );
itr_ck = "/";
itr = itr_ck.begin();
- BOOST_CHECK( *itr == std::string( "/" ) );
- BOOST_CHECK( ++itr == itr_ck.end() );
- BOOST_CHECK( *--itr == std::string( "/" ) );
+ BOOST_TEST( *itr == std::string( "/" ) );
+ BOOST_TEST( ++itr == itr_ck.end() );
+ BOOST_TEST( *--itr == std::string( "/" ) );
itr_ck = "foo";
- BOOST_CHECK( *itr_ck.begin() == std::string( "foo" ) );
- BOOST_CHECK( next( itr_ck.begin() ) == itr_ck.end() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_CHECK( prior( itr_ck.end() ) == itr_ck.begin() );
+ BOOST_TEST( *itr_ck.begin() == std::string( "foo" ) );
+ BOOST_TEST( next( itr_ck.begin() ) == itr_ck.end() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "foo" ) );
+ BOOST_TEST( prior( itr_ck.end() ) == itr_ck.begin() );
itr_ck = path( "/foo" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "/" ) );
- BOOST_CHECK( *next( itr_ck.begin() ) == std::string( "foo" ) );
- BOOST_CHECK( next(next( itr_ck.begin() )) == itr_ck.end() );
- BOOST_CHECK( next( itr_ck.begin() ) == prior( itr_ck.end() ) );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_CHECK( *prior(prior( itr_ck.end() )) == std::string( "/" ) );
- BOOST_CHECK( prior(prior( itr_ck.end() )) == itr_ck.begin() );
+ BOOST_TEST( *itr_ck.begin() == std::string( "/" ) );
+ BOOST_TEST( *next( itr_ck.begin() ) == std::string( "foo" ) );
+ BOOST_TEST( next(next( itr_ck.begin() )) == itr_ck.end() );
+ BOOST_TEST( next( itr_ck.begin() ) == prior( itr_ck.end() ) );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "foo" ) );
+ BOOST_TEST( *prior(prior( itr_ck.end() )) == std::string( "/" ) );
+ BOOST_TEST( prior(prior( itr_ck.end() )) == itr_ck.begin() );
itr_ck = "/foo/bar";
itr = itr_ck.begin();
- BOOST_CHECK( *itr == std::string( "/" ) );
- BOOST_CHECK( *++itr == std::string( "foo" ) );
- BOOST_CHECK( *++itr == std::string( "bar" ) );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( *itr == std::string( "/" ) );
+ BOOST_TEST( *++itr == std::string( "foo" ) );
+ BOOST_TEST( *++itr == std::string( "bar" ) );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "bar" );
CHECK_EQUAL( *--itr, "foo" );
CHECK_EQUAL( *--itr, "/" );
@@ -185,7 +183,7 @@
itr = itr_ck.begin();
CHECK_EQUAL( *itr, ".." );
CHECK_EQUAL( *++itr, "f" );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "f" );
CHECK_EQUAL( *--itr, ".." );
@@ -196,7 +194,7 @@
CHECK_EQUAL( *++itr, "foo" );
CHECK_EQUAL( *++itr, "bar" );
CHECK_EQUAL( *++itr, "." );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "." );
CHECK_EQUAL( *--itr, "bar" );
CHECK_EQUAL( *--itr, "foo" );
@@ -209,7 +207,7 @@
CHECK_EQUAL( *++itr, "f" );
CHECK_EQUAL( *++itr, "b" );
CHECK_EQUAL( *++itr, "." );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "." );
CHECK_EQUAL( *--itr, "b" );
CHECK_EQUAL( *--itr, "f" );
@@ -220,14 +218,14 @@
// two leading slashes are permitted by POSIX (as implementation defined),
// while for Windows it is always well defined (as a network name)
CHECK_EQUAL( *itr, "//net" );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "//net" );
itr_ck = "//net/";
itr = itr_ck.begin();
CHECK_EQUAL( *itr, "//net" );
CHECK_EQUAL( *++itr, "/" );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "/" );
CHECK_EQUAL( *--itr, "//net" );
@@ -237,7 +235,7 @@
CHECK_EQUAL( *++itr, "/" );
CHECK_EQUAL( *++itr, "bar" );
CHECK_EQUAL( *++itr, "." );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "." );
CHECK_EQUAL( *--itr, "bar" );
CHECK_EQUAL( *--itr, "/" );
@@ -250,7 +248,7 @@
CHECK_EQUAL( *++itr, "foo" );
CHECK_EQUAL( *++itr, "bar" );
CHECK_EQUAL( *++itr, "." );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "." );
CHECK_EQUAL( *--itr, "bar" );
CHECK_EQUAL( *--itr, "foo" );
@@ -262,19 +260,19 @@
itr = itr_ck.begin();
CHECK_EQUAL( *itr, "c:" );
CHECK_EQUAL( *++itr, "/" );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "/" );
CHECK_EQUAL( *--itr, "c:" );
itr_ck = "c:\\foo";
itr = itr_ck.begin();
- BOOST_CHECK( *itr == std::string( "c:" ) );
- BOOST_CHECK( *++itr == std::string( "/" ) );
- BOOST_CHECK( *++itr == std::string( "foo" ) );
- BOOST_CHECK( ++itr == itr_ck.end() );
- BOOST_CHECK( *--itr == std::string( "foo" ) );
- BOOST_CHECK( *--itr == std::string( "/" ) );
- BOOST_CHECK( *--itr == std::string( "c:" ) );
+ BOOST_TEST( *itr == std::string( "c:" ) );
+ BOOST_TEST( *++itr == std::string( "/" ) );
+ BOOST_TEST( *++itr == std::string( "foo" ) );
+ BOOST_TEST( ++itr == itr_ck.end() );
+ BOOST_TEST( *--itr == std::string( "foo" ) );
+ BOOST_TEST( *--itr == std::string( "/" ) );
+ BOOST_TEST( *--itr == std::string( "c:" ) );
itr_ck = "\\\\\\foo\\\\\\bar\\\\\\";
itr = itr_ck.begin();
@@ -283,7 +281,7 @@
CHECK_EQUAL( *++itr, "foo" );
CHECK_EQUAL( *++itr, "bar" );
CHECK_EQUAL( *++itr, "." );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
CHECK_EQUAL( *--itr, "." );
CHECK_EQUAL( *--itr, "bar" );
CHECK_EQUAL( *--itr, "foo" );
@@ -291,90 +289,90 @@
itr_ck = "c:foo";
itr = itr_ck.begin();
- BOOST_CHECK( *itr == std::string( "c:" ) );
- BOOST_CHECK( *++itr == std::string( "foo" ) );
- BOOST_CHECK( ++itr == itr_ck.end() );
- BOOST_CHECK( *--itr == std::string( "foo" ) );
- BOOST_CHECK( *--itr == std::string( "c:" ) );
+ BOOST_TEST( *itr == std::string( "c:" ) );
+ BOOST_TEST( *++itr == std::string( "foo" ) );
+ BOOST_TEST( ++itr == itr_ck.end() );
+ BOOST_TEST( *--itr == std::string( "foo" ) );
+ BOOST_TEST( *--itr == std::string( "c:" ) );
itr_ck = "c:foo/";
itr = itr_ck.begin();
- BOOST_CHECK( *itr == std::string( "c:" ) );
- BOOST_CHECK( *++itr == std::string( "foo" ) );
- BOOST_CHECK( *++itr == std::string( "." ) );
- BOOST_CHECK( ++itr == itr_ck.end() );
- BOOST_CHECK( *--itr == std::string( "." ) );
- BOOST_CHECK( *--itr == std::string( "foo" ) );
- BOOST_CHECK( *--itr == std::string( "c:" ) );
+ BOOST_TEST( *itr == std::string( "c:" ) );
+ BOOST_TEST( *++itr == std::string( "foo" ) );
+ BOOST_TEST( *++itr == std::string( "." ) );
+ BOOST_TEST( ++itr == itr_ck.end() );
+ BOOST_TEST( *--itr == std::string( "." ) );
+ BOOST_TEST( *--itr == std::string( "foo" ) );
+ BOOST_TEST( *--itr == std::string( "c:" ) );
itr_ck = path( "c:" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "c:" ) );
- BOOST_CHECK( next( itr_ck.begin() ) == itr_ck.end() );
- BOOST_CHECK( prior( itr_ck.end() ) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "c:" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "c:" ) );
+ BOOST_TEST( next( itr_ck.begin() ) == itr_ck.end() );
+ BOOST_TEST( prior( itr_ck.end() ) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "c:" ) );
itr_ck = path( "c:/" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "c:" ) );
- BOOST_CHECK( *next( itr_ck.begin() ) == std::string( "/" ) );
- BOOST_CHECK( next( next( itr_ck.begin() )) == itr_ck.end() );
- BOOST_CHECK( prior( prior( itr_ck.end() )) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "/" ) );
- BOOST_CHECK( *prior( prior( itr_ck.end() )) == std::string( "c:" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "c:" ) );
+ BOOST_TEST( *next( itr_ck.begin() ) == std::string( "/" ) );
+ BOOST_TEST( next( next( itr_ck.begin() )) == itr_ck.end() );
+ BOOST_TEST( prior( prior( itr_ck.end() )) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "/" ) );
+ BOOST_TEST( *prior( prior( itr_ck.end() )) == std::string( "c:" ) );
itr_ck = path( "c:foo" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "c:" ) );
- BOOST_CHECK( *next( itr_ck.begin() ) == std::string( "foo" ) );
- BOOST_CHECK( next(next( itr_ck.begin() )) == itr_ck.end() );
- BOOST_CHECK( prior(prior( itr_ck.end() )) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_CHECK( *prior(prior( itr_ck.end() )) == std::string( "c:" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "c:" ) );
+ BOOST_TEST( *next( itr_ck.begin() ) == std::string( "foo" ) );
+ BOOST_TEST( next(next( itr_ck.begin() )) == itr_ck.end() );
+ BOOST_TEST( prior(prior( itr_ck.end() )) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "foo" ) );
+ BOOST_TEST( *prior(prior( itr_ck.end() )) == std::string( "c:" ) );
itr_ck = path( "c:/foo" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "c:" ) );
- BOOST_CHECK( *next( itr_ck.begin() ) == std::string( "/" ) );
- BOOST_CHECK( *next( next( itr_ck.begin() )) == std::string( "foo" ) );
- BOOST_CHECK( next( next( next( itr_ck.begin() ))) == itr_ck.end() );
- BOOST_CHECK( prior( prior( prior( itr_ck.end() ))) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_CHECK( *prior( prior( itr_ck.end() )) == std::string( "/" ) );
- BOOST_CHECK( *prior( prior( prior( itr_ck.end() ))) == std::string( "c:" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "c:" ) );
+ BOOST_TEST( *next( itr_ck.begin() ) == std::string( "/" ) );
+ BOOST_TEST( *next( next( itr_ck.begin() )) == std::string( "foo" ) );
+ BOOST_TEST( next( next( next( itr_ck.begin() ))) == itr_ck.end() );
+ BOOST_TEST( prior( prior( prior( itr_ck.end() ))) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "foo" ) );
+ BOOST_TEST( *prior( prior( itr_ck.end() )) == std::string( "/" ) );
+ BOOST_TEST( *prior( prior( prior( itr_ck.end() ))) == std::string( "c:" ) );
itr_ck = path( "//net" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "//net" ) );
- BOOST_CHECK( next( itr_ck.begin() ) == itr_ck.end() );
- BOOST_CHECK( prior( itr_ck.end() ) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "//net" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "//net" ) );
+ BOOST_TEST( next( itr_ck.begin() ) == itr_ck.end() );
+ BOOST_TEST( prior( itr_ck.end() ) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "//net" ) );
itr_ck = path( "//net/" );
CHECK_EQUAL( *itr_ck.begin(), "//net" );
CHECK_EQUAL( *next( itr_ck.begin() ), "/" );
- BOOST_CHECK( next(next( itr_ck.begin() )) == itr_ck.end() );
- BOOST_CHECK( prior(prior( itr_ck.end() )) == itr_ck.begin() );
+ BOOST_TEST( next(next( itr_ck.begin() )) == itr_ck.end() );
+ BOOST_TEST( prior(prior( itr_ck.end() )) == itr_ck.begin() );
CHECK_EQUAL( *prior( itr_ck.end() ), "/" );
CHECK_EQUAL( *prior(prior( itr_ck.end() )), "//net" );
itr_ck = path( "//net/foo" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "//net" ) );
- BOOST_CHECK( *next( itr_ck.begin() ) == std::string( "/" ) );
- BOOST_CHECK( *next(next( itr_ck.begin() )) == std::string( "foo" ) );
- BOOST_CHECK( next(next(next( itr_ck.begin() ))) == itr_ck.end() );
- BOOST_CHECK( prior(prior(prior( itr_ck.end() ))) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_CHECK( *prior(prior( itr_ck.end() )) == std::string( "/" ) );
- BOOST_CHECK( *prior(prior(prior( itr_ck.end() ))) == std::string( "//net" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "//net" ) );
+ BOOST_TEST( *next( itr_ck.begin() ) == std::string( "/" ) );
+ BOOST_TEST( *next(next( itr_ck.begin() )) == std::string( "foo" ) );
+ BOOST_TEST( next(next(next( itr_ck.begin() ))) == itr_ck.end() );
+ BOOST_TEST( prior(prior(prior( itr_ck.end() ))) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "foo" ) );
+ BOOST_TEST( *prior(prior( itr_ck.end() )) == std::string( "/" ) );
+ BOOST_TEST( *prior(prior(prior( itr_ck.end() ))) == std::string( "//net" ) );
itr_ck = path( "prn:" );
- BOOST_CHECK( *itr_ck.begin() == std::string( "prn:" ) );
- BOOST_CHECK( next( itr_ck.begin() ) == itr_ck.end() );
- BOOST_CHECK( prior( itr_ck.end() ) == itr_ck.begin() );
- BOOST_CHECK( *prior( itr_ck.end() ) == std::string( "prn:" ) );
+ BOOST_TEST( *itr_ck.begin() == std::string( "prn:" ) );
+ BOOST_TEST( next( itr_ck.begin() ) == itr_ck.end() );
+ BOOST_TEST( prior( itr_ck.end() ) == itr_ck.begin() );
+ BOOST_TEST( *prior( itr_ck.end() ) == std::string( "prn:" ) );
}
else
{
itr_ck = "///";
itr = itr_ck.begin();
CHECK_EQUAL( *itr, "/" );
- BOOST_CHECK( ++itr == itr_ck.end() );
+ BOOST_TEST( ++itr == itr_ck.end() );
}
}
@@ -405,22 +403,22 @@
// swap
a.swap( b );
- BOOST_CHECK( a.string() == "b" );
- BOOST_CHECK( b.string() == "a" );
+ BOOST_TEST( a.string() == "b" );
+ BOOST_TEST( b.string() == "a" );
fs::swap( a, b );
- BOOST_CHECK( a.string() == "a" );
- BOOST_CHECK( b.string() == "b" );
+ BOOST_TEST( a.string() == "a" );
+ BOOST_TEST( b.string() == "b" );
// probe operator /
PATH_CHECK( path("") / ".", "." );
PATH_CHECK( path("") / "..", ".." );
if ( platform == "Windows" )
{
- BOOST_CHECK( (b / a).string() == "b\\a" );
- BOOST_CHECK( (bs / a).string() == "b\\a" );
- BOOST_CHECK( (bcs / a).string() == "b\\a" );
- BOOST_CHECK( (b / as).string() == "b\\a" );
- BOOST_CHECK( (b / acs).string() == "b\\a" );
+ BOOST_TEST( (b / a).string() == "b\\a" );
+ BOOST_TEST( (bs / a).string() == "b\\a" );
+ BOOST_TEST( (bcs / a).string() == "b\\a" );
+ BOOST_TEST( (b / as).string() == "b\\a" );
+ BOOST_TEST( (b / acs).string() == "b\\a" );
PATH_CHECK( path("a") / "b", "a\\b" );
PATH_CHECK( path("..") / "", "..\\" );
PATH_CHECK( path("foo") / path("bar"), "foo\\bar" ); // path arg
@@ -463,11 +461,11 @@
}
else
{
- BOOST_CHECK( (b / a).string() == "b/a" );
- BOOST_CHECK( (bs / a).string() == "b/a" );
- BOOST_CHECK( (bcs / a).string() == "b/a" );
- BOOST_CHECK( (b / as).string() == "b/a" );
- BOOST_CHECK( (b / acs).string() == "b/a" );
+ BOOST_TEST( (b / a).string() == "b/a" );
+ BOOST_TEST( (bs / a).string() == "b/a" );
+ BOOST_TEST( (bcs / a).string() == "b/a" );
+ BOOST_TEST( (b / as).string() == "b/a" );
+ BOOST_TEST( (b / acs).string() == "b/a" );
PATH_CHECK( path("a") / "b", "a/b" );
PATH_CHECK( path("..") / "", ".." );
PATH_CHECK( path("") / "..", ".." );
@@ -511,89 +509,89 @@
}
// probe operator <
- BOOST_CHECK( !(e < e2) );
- BOOST_CHECK( !(es < e2) );
- BOOST_CHECK( !(ecs < e2) );
- BOOST_CHECK( !(e < es2) );
- BOOST_CHECK( !(e < ecs2) );
-
- BOOST_CHECK( e < a );
- BOOST_CHECK( es < a );
- BOOST_CHECK( ecs < a );
- BOOST_CHECK( e < as );
- BOOST_CHECK( e < acs );
-
- BOOST_CHECK( a < b );
- BOOST_CHECK( as < b );
- BOOST_CHECK( acs < b );
- BOOST_CHECK( a < bs );
- BOOST_CHECK( a < bcs );
-
- BOOST_CHECK( !(a < a2) );
- BOOST_CHECK( !(as < a2) );
- BOOST_CHECK( !(acs < a2) );
- BOOST_CHECK( !(a < as2) );
- BOOST_CHECK( !(a < acs2) );
+ BOOST_TEST( !(e < e2) );
+ BOOST_TEST( !(es < e2) );
+ BOOST_TEST( !(ecs < e2) );
+ BOOST_TEST( !(e < es2) );
+ BOOST_TEST( !(e < ecs2) );
+
+ BOOST_TEST( e < a );
+ BOOST_TEST( es < a );
+ BOOST_TEST( ecs < a );
+ BOOST_TEST( e < as );
+ BOOST_TEST( e < acs );
+
+ BOOST_TEST( a < b );
+ BOOST_TEST( as < b );
+ BOOST_TEST( acs < b );
+ BOOST_TEST( a < bs );
+ BOOST_TEST( a < bcs );
+
+ BOOST_TEST( !(a < a2) );
+ BOOST_TEST( !(as < a2) );
+ BOOST_TEST( !(acs < a2) );
+ BOOST_TEST( !(a < as2) );
+ BOOST_TEST( !(a < acs2) );
// make sure basic_path overloads don't conflict with std::string overloads
- BOOST_CHECK( !(as < as) );
- BOOST_CHECK( !(as < acs) );
- BOOST_CHECK( !(acs < as) );
+ BOOST_TEST( !(as < as) );
+ BOOST_TEST( !(as < acs) );
+ BOOST_TEST( !(acs < as) );
// reality check character set is as expected
- BOOST_CHECK( std::string("a.b") < std::string("a/b") );
+ BOOST_TEST( std::string("a.b") < std::string("a/b") );
// verify compare is actually lexicographical
- BOOST_CHECK( path("a/b") < path("a.b") );
+ BOOST_TEST( path("a/b") < path("a.b") );
// make sure the derivative operators also work
- BOOST_CHECK( a == a2 );
- BOOST_CHECK( as == a2 );
- BOOST_CHECK( acs == a2 );
- BOOST_CHECK( a == as2 );
- BOOST_CHECK( a == acs2 );
-
- BOOST_CHECK( a != b );
- BOOST_CHECK( as != b );
- BOOST_CHECK( acs != b );
- BOOST_CHECK( a != bs );
- BOOST_CHECK( a != bcs );
-
- BOOST_CHECK( b > a );
- BOOST_CHECK( b > as );
- BOOST_CHECK( b > acs );
- BOOST_CHECK( bs > a);
- BOOST_CHECK( bcs > a);
-
- BOOST_CHECK( !(a2 > a) );
- BOOST_CHECK( !(a2 > as) );
- BOOST_CHECK( !(a2 > acs) );
- BOOST_CHECK( !(as2 > a) );
- BOOST_CHECK( !(acs2 > a) );
-
- BOOST_CHECK( a <= b );
- BOOST_CHECK( as <= b );
- BOOST_CHECK( acs <= b );
- BOOST_CHECK( a <= bs );
- BOOST_CHECK( a <= bcs );
-
- BOOST_CHECK( a <= a2 );
- BOOST_CHECK( as <= a2 );
- BOOST_CHECK( acs <= a2 );
- BOOST_CHECK( a <= as2 );
- BOOST_CHECK( a <= acs2 );
-
- BOOST_CHECK( b >= a );
- BOOST_CHECK( bs >= a );
- BOOST_CHECK( bcs >= a );
- BOOST_CHECK( b >= as );
- BOOST_CHECK( b >= acs );
-
- BOOST_CHECK( a2 >= a );
- BOOST_CHECK( as2 >= a );
- BOOST_CHECK( acs2 >= a );
- BOOST_CHECK( a2 >= as );
- BOOST_CHECK( a2 >= acs );
+ BOOST_TEST( a == a2 );
+ BOOST_TEST( as == a2 );
+ BOOST_TEST( acs == a2 );
+ BOOST_TEST( a == as2 );
+ BOOST_TEST( a == acs2 );
+
+ BOOST_TEST( a != b );
+ BOOST_TEST( as != b );
+ BOOST_TEST( acs != b );
+ BOOST_TEST( a != bs );
+ BOOST_TEST( a != bcs );
+
+ BOOST_TEST( b > a );
+ BOOST_TEST( b > as );
+ BOOST_TEST( b > acs );
+ BOOST_TEST( bs > a);
+ BOOST_TEST( bcs > a);
+
+ BOOST_TEST( !(a2 > a) );
+ BOOST_TEST( !(a2 > as) );
+ BOOST_TEST( !(a2 > acs) );
+ BOOST_TEST( !(as2 > a) );
+ BOOST_TEST( !(acs2 > a) );
+
+ BOOST_TEST( a <= b );
+ BOOST_TEST( as <= b );
+ BOOST_TEST( acs <= b );
+ BOOST_TEST( a <= bs );
+ BOOST_TEST( a <= bcs );
+
+ BOOST_TEST( a <= a2 );
+ BOOST_TEST( as <= a2 );
+ BOOST_TEST( acs <= a2 );
+ BOOST_TEST( a <= as2 );
+ BOOST_TEST( a <= acs2 );
+
+ BOOST_TEST( b >= a );
+ BOOST_TEST( bs >= a );
+ BOOST_TEST( bcs >= a );
+ BOOST_TEST( b >= as );
+ BOOST_TEST( b >= acs );
+
+ BOOST_TEST( a2 >= a );
+ BOOST_TEST( as2 >= a );
+ BOOST_TEST( acs2 >= a );
+ BOOST_TEST( a2 >= as );
+ BOOST_TEST( a2 >= acs );
}
// query_and_decomposition_tests -----------------------------------------//
@@ -605,37 +603,37 @@
path p;
p = "";
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( !p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( !p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "/";
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "/" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "/" );
- BOOST_CHECK( p.root_path().string() == "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "/" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "/" );
+ BOOST_TEST( p.root_path().string() == "/" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
p = "//";
CHECK_EQUAL( p.relative_path().string(), "" );
@@ -644,13 +642,13 @@
CHECK_EQUAL( p.root_name(), "//" );
CHECK_EQUAL( p.root_directory(), "" );
CHECK_EQUAL( p.root_path().string(), "//" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "///";
@@ -660,61 +658,61 @@
CHECK_EQUAL( p.root_name(), "" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
p = ".";
- BOOST_CHECK( p.relative_path().string() == "." );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "." );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "." );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "." );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "..";
- BOOST_CHECK( p.relative_path().string() == ".." );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == ".." );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == ".." );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == ".." );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "foo";
- BOOST_CHECK( p.relative_path().string() == "foo" );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "foo" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "foo" );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "foo" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "/foo";
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -723,16 +721,16 @@
CHECK_EQUAL( p.root_name(), "" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
p = "/foo/";
CHECK_EQUAL( p.relative_path().string(), "foo/" );
@@ -741,16 +739,16 @@
CHECK_EQUAL( p.root_name(), "" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
p = "///foo";
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -759,46 +757,46 @@
CHECK_EQUAL( p.root_name(), "" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
p = "foo/bar";
- BOOST_CHECK( p.relative_path().string() == "foo/bar" );
- BOOST_CHECK( p.parent_path().string() == "foo" );
- BOOST_CHECK( p.filename() == "bar" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "foo/bar" );
+ BOOST_TEST( p.parent_path().string() == "foo" );
+ BOOST_TEST( p.filename() == "bar" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "../foo";
- BOOST_CHECK( p.relative_path().string() == "../foo" );
- BOOST_CHECK( p.parent_path().string() == ".." );
- BOOST_CHECK( p.filename() == "foo" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "../foo" );
+ BOOST_TEST( p.parent_path().string() == ".." );
+ BOOST_TEST( p.filename() == "foo" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "" );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "..///foo";
CHECK_EQUAL( p.relative_path().string(), "..///foo" );
@@ -807,31 +805,31 @@
CHECK_EQUAL( p.root_name(), "" );
CHECK_EQUAL( p.root_directory(), "" );
CHECK_EQUAL( p.root_path().string(), "" );
- BOOST_CHECK( !p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = "/foo/bar";
- BOOST_CHECK( p.relative_path().string() == "foo/bar" );
- BOOST_CHECK( p.parent_path().string() == "/foo" );
- BOOST_CHECK( p.filename() == "bar" );
- BOOST_CHECK( p.root_name() == "" );
- BOOST_CHECK( p.root_directory() == "/" );
- BOOST_CHECK( p.root_path().string() == "/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( !p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
+ BOOST_TEST( p.relative_path().string() == "foo/bar" );
+ BOOST_TEST( p.parent_path().string() == "/foo" );
+ BOOST_TEST( p.filename() == "bar" );
+ BOOST_TEST( p.root_name() == "" );
+ BOOST_TEST( p.root_directory() == "/" );
+ BOOST_TEST( p.root_path().string() == "/" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( !p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
if ( platform == "POSIX" )
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.is_complete() );
else
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( !p.is_complete() );
// Both POSIX and Windows allow two leading slashs
// (POSIX meaning is implementation defined)
@@ -847,43 +845,43 @@
CHECK_EQUAL( p.root_name(), "//net" );
CHECK_EQUAL( p.root_directory(), "" );
CHECK_EQUAL( p.root_path().string(), "//net" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = path( "//net/" );
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "//net" );
- BOOST_CHECK( p.filename() == "/" );
- BOOST_CHECK( p.root_name() == "//net" );
- BOOST_CHECK( p.root_directory() == "/" );
- BOOST_CHECK( p.root_path().string() == "//net/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "//net" );
+ BOOST_TEST( p.filename() == "/" );
+ BOOST_TEST( p.root_name() == "//net" );
+ BOOST_TEST( p.root_directory() == "/" );
+ BOOST_TEST( p.root_path().string() == "//net/" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "//net/foo" );
- BOOST_CHECK( p.relative_path().string() == "foo" );
- BOOST_CHECK( p.parent_path().string() == "//net/" );
- BOOST_CHECK( p.filename() == "foo" );
- BOOST_CHECK( p.root_name() == "//net" );
- BOOST_CHECK( p.root_directory() == "/" );
- BOOST_CHECK( p.root_path().string() == "//net/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "foo" );
+ BOOST_TEST( p.parent_path().string() == "//net/" );
+ BOOST_TEST( p.filename() == "foo" );
+ BOOST_TEST( p.root_name() == "//net" );
+ BOOST_TEST( p.root_directory() == "/" );
+ BOOST_TEST( p.root_path().string() == "//net/" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "//net///foo" );
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -892,76 +890,76 @@
CHECK_EQUAL( p.root_name(), "//net" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "//net/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
if ( platform == "Windows" )
{
p = path( "c:" );
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "c:" );
- BOOST_CHECK( p.root_name() == "c:" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "c:" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "c:" );
+ BOOST_TEST( p.root_name() == "c:" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "c:" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = path( "c:foo" );
- BOOST_CHECK( p.relative_path().string() == "foo" );
- BOOST_CHECK( p.parent_path().string() == "c:" );
- BOOST_CHECK( p.filename() == "foo" );
- BOOST_CHECK( p.root_name() == "c:" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "c:" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "foo" );
+ BOOST_TEST( p.parent_path().string() == "c:" );
+ BOOST_TEST( p.filename() == "foo" );
+ BOOST_TEST( p.root_name() == "c:" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "c:" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = path( "c:/" );
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "c:" );
- BOOST_CHECK( p.filename() == "/" );
- BOOST_CHECK( p.root_name() == "c:" );
- BOOST_CHECK( p.root_directory() == "/" );
- BOOST_CHECK( p.root_path().string() == "c:/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "c:" );
+ BOOST_TEST( p.filename() == "/" );
+ BOOST_TEST( p.root_name() == "c:" );
+ BOOST_TEST( p.root_directory() == "/" );
+ BOOST_TEST( p.root_path().string() == "c:/" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "c:.." );
- BOOST_CHECK( p.relative_path().string() == ".." );
- BOOST_CHECK( p.parent_path().string() == "c:" );
- BOOST_CHECK( p.filename() == ".." );
- BOOST_CHECK( p.root_name() == "c:" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "c:" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == ".." );
+ BOOST_TEST( p.parent_path().string() == "c:" );
+ BOOST_TEST( p.filename() == ".." );
+ BOOST_TEST( p.root_name() == "c:" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "c:" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = path( "c:/foo" );
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -970,13 +968,13 @@
CHECK_EQUAL( p.root_name(), "c:" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "c:/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "c://foo" );
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -985,13 +983,13 @@
CHECK_EQUAL( p.root_name(), "c:" );
CHECK_EQUAL( p.root_directory(), "/" );
CHECK_EQUAL( p.root_path().string(), "c:/" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "c:\\foo\\bar" );
CHECK_EQUAL( p.relative_path().string(), "foo\\bar" );
@@ -1000,28 +998,28 @@
CHECK_EQUAL( p.root_name(), "c:" );
CHECK_EQUAL( p.root_directory(), "\\" );
CHECK_EQUAL( p.root_path().string(), "c:\\" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
p = path( "prn:" );
- BOOST_CHECK( p.relative_path().string() == "" );
- BOOST_CHECK( p.parent_path().string() == "" );
- BOOST_CHECK( p.filename() == "prn:" );
- BOOST_CHECK( p.root_name() == "prn:" );
- BOOST_CHECK( p.root_directory() == "" );
- BOOST_CHECK( p.root_path().string() == "prn:" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( !p.has_root_directory() );
- BOOST_CHECK( !p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( !p.has_parent_path() );
- BOOST_CHECK( !p.is_complete() );
+ BOOST_TEST( p.relative_path().string() == "" );
+ BOOST_TEST( p.parent_path().string() == "" );
+ BOOST_TEST( p.filename() == "prn:" );
+ BOOST_TEST( p.root_name() == "prn:" );
+ BOOST_TEST( p.root_directory() == "" );
+ BOOST_TEST( p.root_path().string() == "prn:" );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( !p.has_root_directory() );
+ BOOST_TEST( !p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( !p.has_parent_path() );
+ BOOST_TEST( !p.is_complete() );
p = path( "\\\\net\\\\\\foo" );
CHECK_EQUAL( p.relative_path().string(), "foo" );
@@ -1030,13 +1028,13 @@
CHECK_EQUAL( p.root_name(), "\\\\net" );
CHECK_EQUAL( p.root_directory(), "\\" );
CHECK_EQUAL( p.root_path().string(), "\\\\net\\" );
- BOOST_CHECK( p.has_root_path() );
- BOOST_CHECK( p.has_root_name() );
- BOOST_CHECK( p.has_root_directory() );
- BOOST_CHECK( p.has_relative_path() );
- BOOST_CHECK( p.has_filename() );
- BOOST_CHECK( p.has_parent_path() );
- BOOST_CHECK( p.is_complete() );
+ BOOST_TEST( p.has_root_path() );
+ BOOST_TEST( p.has_root_name() );
+ BOOST_TEST( p.has_root_directory() );
+ BOOST_TEST( p.has_relative_path() );
+ BOOST_TEST( p.has_filename() );
+ BOOST_TEST( p.has_parent_path() );
+ BOOST_TEST( p.is_complete() );
} // Windows
else
@@ -1046,7 +1044,7 @@
DIR_CHECK( path( "///foo///bar///" ), "///foo///bar///" );
p = path( "/usr/local/bin:/usr/bin:/bin" );
- BOOST_CHECK( p.string() == "/usr/local/bin:/usr/bin:/bin" );
+ BOOST_TEST( p.string() == "/usr/local/bin:/usr/bin:/bin" );
} // POSIX
}
@@ -1194,81 +1192,81 @@
{
std::cout << "name_function_tests..." << std::endl;
- BOOST_CHECK( fs::portable_posix_name( std::string( "x" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "x" ) ) );
- BOOST_CHECK( fs::portable_name( std::string( "x" ) ) );
- BOOST_CHECK( fs::portable_directory_name( std::string( "x" ) ) );
- BOOST_CHECK( fs::portable_file_name( std::string( "x" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( "." ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "." ) ) );
- BOOST_CHECK( fs::portable_name( std::string( "." ) ) );
- BOOST_CHECK( fs::portable_directory_name( std::string( "." ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "." ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( ".." ) ) );
- BOOST_CHECK( fs::windows_name( std::string( ".." ) ) );
- BOOST_CHECK( fs::portable_name( std::string( ".." ) ) );
- BOOST_CHECK( fs::portable_directory_name( std::string( ".." ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( ".." ) ) );
-
- BOOST_CHECK( !fs::native( std::string( "" ) ) );
- BOOST_CHECK( !fs::portable_posix_name( std::string( "" ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( "" ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( "" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "" ) ) );
-
- BOOST_CHECK( !fs::native( std::string( " " ) ) );
- BOOST_CHECK( !fs::portable_posix_name( std::string( " " ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( " " ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( " " ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( " " ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( " " ) ) );
-
- BOOST_CHECK( !fs::portable_posix_name( std::string( ":" ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( ":" ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( ":" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( ":" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( ":" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( "-" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "-" ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( "-" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "-" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "-" ) ) );
-
- BOOST_CHECK( !fs::portable_posix_name( std::string( "foo bar" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "foo bar" ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( " bar" ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( "foo " ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( "foo bar" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "foo bar" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "foo bar" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( "foo.bar" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "foo.bar" ) ) );
- BOOST_CHECK( fs::portable_name( std::string( "foo.bar" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "foo.bar" ) ) );
- BOOST_CHECK( fs::portable_file_name( std::string( "foo.bar" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( "foo.barf" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( "foo.barf" ) ) );
- BOOST_CHECK( fs::portable_name( std::string( "foo.barf" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "foo.barf" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "foo.barf" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( ".foo" ) ) );
- BOOST_CHECK( fs::windows_name( std::string( ".foo" ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( ".foo" ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( ".foo" ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( ".foo" ) ) );
-
- BOOST_CHECK( fs::portable_posix_name( std::string( "foo." ) ) );
- BOOST_CHECK( !fs::windows_name( std::string( "foo." ) ) );
- BOOST_CHECK( !fs::portable_name( std::string( "foo." ) ) );
- BOOST_CHECK( !fs::portable_directory_name( std::string( "foo." ) ) );
- BOOST_CHECK( !fs::portable_file_name( std::string( "foo." ) ) );
+ BOOST_TEST( fs::portable_posix_name( std::string( "x" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "x" ) ) );
+ BOOST_TEST( fs::portable_name( std::string( "x" ) ) );
+ BOOST_TEST( fs::portable_directory_name( std::string( "x" ) ) );
+ BOOST_TEST( fs::portable_file_name( std::string( "x" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( "." ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "." ) ) );
+ BOOST_TEST( fs::portable_name( std::string( "." ) ) );
+ BOOST_TEST( fs::portable_directory_name( std::string( "." ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "." ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( ".." ) ) );
+ BOOST_TEST( fs::windows_name( std::string( ".." ) ) );
+ BOOST_TEST( fs::portable_name( std::string( ".." ) ) );
+ BOOST_TEST( fs::portable_directory_name( std::string( ".." ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( ".." ) ) );
+
+ BOOST_TEST( !fs::native( std::string( "" ) ) );
+ BOOST_TEST( !fs::portable_posix_name( std::string( "" ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( "" ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( "" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "" ) ) );
+
+ BOOST_TEST( !fs::native( std::string( " " ) ) );
+ BOOST_TEST( !fs::portable_posix_name( std::string( " " ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( " " ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( " " ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( " " ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( " " ) ) );
+
+ BOOST_TEST( !fs::portable_posix_name( std::string( ":" ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( ":" ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( ":" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( ":" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( ":" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( "-" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "-" ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( "-" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "-" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "-" ) ) );
+
+ BOOST_TEST( !fs::portable_posix_name( std::string( "foo bar" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "foo bar" ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( " bar" ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( "foo " ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( "foo bar" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "foo bar" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "foo bar" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( "foo.bar" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "foo.bar" ) ) );
+ BOOST_TEST( fs::portable_name( std::string( "foo.bar" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "foo.bar" ) ) );
+ BOOST_TEST( fs::portable_file_name( std::string( "foo.bar" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( "foo.barf" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( "foo.barf" ) ) );
+ BOOST_TEST( fs::portable_name( std::string( "foo.barf" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "foo.barf" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "foo.barf" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( ".foo" ) ) );
+ BOOST_TEST( fs::windows_name( std::string( ".foo" ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( ".foo" ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( ".foo" ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( ".foo" ) ) );
+
+ BOOST_TEST( fs::portable_posix_name( std::string( "foo." ) ) );
+ BOOST_TEST( !fs::windows_name( std::string( "foo." ) ) );
+ BOOST_TEST( !fs::portable_name( std::string( "foo." ) ) );
+ BOOST_TEST( !fs::portable_directory_name( std::string( "foo." ) ) );
+ BOOST_TEST( !fs::portable_file_name( std::string( "foo." ) ) );
}
// stem_tests ---------------------------------------------------//
@@ -1277,12 +1275,12 @@
{
std::cout << "stem_tests..." << std::endl;
- BOOST_CHECK( path("b").stem() == "b" );
- BOOST_CHECK( path("a/b.txt").stem() == "b" );
- BOOST_CHECK( path("a/b.").stem() == "b" );
- BOOST_CHECK( path("a.b.c").stem() == "a.b" );
- BOOST_CHECK( path("a.b.c.").stem() == "a.b.c" );
- BOOST_CHECK( path("").stem() == "" );
+ BOOST_TEST( path("b").stem() == "b" );
+ BOOST_TEST( path("a/b.txt").stem() == "b" );
+ BOOST_TEST( path("a/b.").stem() == "b" );
+ BOOST_TEST( path("a.b.c").stem() == "a.b" );
+ BOOST_TEST( path("a.b.c.").stem() == "a.b.c" );
+ BOOST_TEST( path("").stem() == "" );
}
// extension_tests ---------------------------------------------------//
@@ -1291,13 +1289,13 @@
{
std::cout << "extension_tests..." << std::endl;
- BOOST_CHECK( path("a/b").extension() == "" );
- BOOST_CHECK( path("a/b.txt").extension() == ".txt" );
- BOOST_CHECK( path("a/b.").extension() == "." );
- BOOST_CHECK( path("a.b.c").extension() == ".c" );
- BOOST_CHECK( path("a.b.c.").extension() == "." );
- BOOST_CHECK( path("").extension() == "" );
- BOOST_CHECK( path("a/").extension() == "." );
+ BOOST_TEST( path("a/b").extension() == "" );
+ BOOST_TEST( path("a/b.txt").extension() == ".txt" );
+ BOOST_TEST( path("a/b.").extension() == "." );
+ BOOST_TEST( path("a.b.c").extension() == ".c" );
+ BOOST_TEST( path("a.b.c.").extension() == "." );
+ BOOST_TEST( path("").extension() == "" );
+ BOOST_TEST( path("a/").extension() == "." );
}
// replace_extension_tests ---------------------------------------------------//
@@ -1306,35 +1304,35 @@
{
std::cout << "replace_extension_tests..." << std::endl;
- BOOST_CHECK( path().replace_extension().empty() );
- BOOST_CHECK( path().replace_extension("a").empty() );
- BOOST_CHECK( path().replace_extension("a.") == "." );
- BOOST_CHECK( path().replace_extension("a.txt") == ".txt" );
+ BOOST_TEST( path().replace_extension().empty() );
+ BOOST_TEST( path().replace_extension("a").empty() );
+ BOOST_TEST( path().replace_extension("a.") == "." );
+ BOOST_TEST( path().replace_extension("a.txt") == ".txt" );
// see the rationale in html docs for explanation why this works:
- BOOST_CHECK( path().replace_extension(".txt") == ".txt" );
+ BOOST_TEST( path().replace_extension(".txt") == ".txt" );
- BOOST_CHECK( path("a.txt").replace_extension() == "a" );
- BOOST_CHECK( path("a.txt").replace_extension("") == "a" );
- BOOST_CHECK( path("a.txt").replace_extension(".") == "a." );
- BOOST_CHECK( path("a.txt").replace_extension(".tex") == "a.tex" );
- BOOST_CHECK( path("a.txt").replace_extension("tex") == "a" );
- BOOST_CHECK( path("a.").replace_extension(".tex") == "a.tex" );
- BOOST_CHECK( path("a.").replace_extension("tex") == "a" );
- BOOST_CHECK( path("a").replace_extension(".txt") == "a.txt" );
- BOOST_CHECK( path("a").replace_extension("txt") == "a" );
- BOOST_CHECK( path("a.b.txt" ).replace_extension(".tex") == "a.b.tex" );
- BOOST_CHECK( path("a.b.txt" ).replace_extension("tex") == "a.b" );
+ BOOST_TEST( path("a.txt").replace_extension() == "a" );
+ BOOST_TEST( path("a.txt").replace_extension("") == "a" );
+ BOOST_TEST( path("a.txt").replace_extension(".") == "a." );
+ BOOST_TEST( path("a.txt").replace_extension(".tex") == "a.tex" );
+ BOOST_TEST( path("a.txt").replace_extension("tex") == "a" );
+ BOOST_TEST( path("a.").replace_extension(".tex") == "a.tex" );
+ BOOST_TEST( path("a.").replace_extension("tex") == "a" );
+ BOOST_TEST( path("a").replace_extension(".txt") == "a.txt" );
+ BOOST_TEST( path("a").replace_extension("txt") == "a" );
+ BOOST_TEST( path("a.b.txt" ).replace_extension(".tex") == "a.b.tex" );
+ BOOST_TEST( path("a.b.txt" ).replace_extension("tex") == "a.b" );
}
} // unnamed namespace
- //------------------------------------------------------------------------------------//
- // //
- // test_main //
- // //
- //------------------------------------------------------------------------------------//
+//--------------------------------------------------------------------------------------//
+// //
+// main //
+// //
+//--------------------------------------------------------------------------------------//
-int test_main( int, char*[] )
+int main( int, char*[] )
{
// The choice of platform is make at runtime rather than compile-time
// so that compile errors for all platforms will be detected even though
@@ -1344,14 +1342,14 @@
: "POSIX";
std::cout << "Platform is " << platform << '\n';
- BOOST_CHECK( p1.string() != p3.string() );
+ BOOST_TEST( p1.string() != p3.string() );
p3 = p2;
- BOOST_CHECK( p1.string() == p3.string() );
+ BOOST_TEST( p1.string() == p3.string() );
path p4( "foobar" );
- BOOST_CHECK( p4.string() == "foobar" );
+ BOOST_TEST( p4.string() == "foobar" );
p4 = p4; // self-assignment
- BOOST_CHECK( p4.string() == "foobar" );
+ BOOST_TEST( p4.string() == "foobar" );
construction_tests();
overload_tests();
@@ -1416,15 +1414,15 @@
# endif
- BOOST_CHECK( p1 != p4 );
- BOOST_CHECK( p1.string() == p2.string() );
- BOOST_CHECK( p1.string() == p3.string() );
- BOOST_CHECK( path( "foo" ).filename() == "foo" );
- BOOST_CHECK( path( "foo" ).parent_path().string() == "" );
- BOOST_CHECK( p1.filename() == "fum" );
- BOOST_CHECK( p1.parent_path().string() == "fe/fi/fo" );
- BOOST_CHECK( path( "" ).empty() == true );
- BOOST_CHECK( path( "foo" ).empty() == false );
+ BOOST_TEST( p1 != p4 );
+ BOOST_TEST( p1.string() == p2.string() );
+ BOOST_TEST( p1.string() == p3.string() );
+ BOOST_TEST( path( "foo" ).filename() == "foo" );
+ BOOST_TEST( path( "foo" ).parent_path().string() == "" );
+ BOOST_TEST( p1.filename() == "fum" );
+ BOOST_TEST( p1.parent_path().string() == "fe/fi/fo" );
+ BOOST_TEST( path( "" ).empty() == true );
+ BOOST_TEST( path( "foo" ).empty() == false );
// inserter and extractor tests
# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // bypass VC++ 7.0 and earlier
@@ -1433,11 +1431,9 @@
ss << fs::path( "foo/bar" ) << std::endl;
fs::path round_trip;
ss >> round_trip;
- BOOST_CHECK( round_trip.string() == "foo/bar" );
+ BOOST_TEST( round_trip.string() == "foo/bar" );
std::cout << round_trip.string() << "..." << round_trip << " complete\n";
# endif
- std::cout << errors << " errors detected\n";
-
- return errors;
+ return ::boost::report_errors();
}
Modified: sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
@@ -1,11 +1,11 @@
-// filesystem3 path_unit_test.cpp -------------------------------------------------- //
+// filesystem path_unit_test.cpp --------------------------------------------------- //
-// Copyright Beman Dawes 2008
+// Copyright Beman Dawes 2008, 2009
-// 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)
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
-// See library home page at http://www.boost.org/libs/filesystem
+// Library home page: http://www.boost.org/libs/filesystem
// ---------------------------------------------------------------------------------- //
//
@@ -21,6 +21,7 @@
#include <boost/filesystem/path.hpp>
#include "../src/utf8_codecvt_facet.hpp" // for imbue tests
+#include <boost/detail/lightweight_test.hpp>
#include <iostream>
#include <sstream>
@@ -38,7 +39,6 @@
namespace
{
- int errors;
boost::system::error_code ec;
const boost::system::error_code ok;
@@ -51,7 +51,7 @@
{
if ( source == expected ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file;
std::wcout << L'(' << line << L"): source.wstring(): \"" << source.wstring()
@@ -65,7 +65,7 @@
{
if ( value == expected ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file;
@@ -78,15 +78,13 @@
{
if ( ok ) return;
- ++errors;
+ ++::boost::detail::test_errors();
std::cout << file << '(' << line << "): test failed\n";
}
- path x;
- path y;
- string s("string iterators");
- wstring ws(L"wstring iterators");
+ string s("string");
+ wstring ws(L"wstring");
// test_constructors ---------------------------------------------------------------//
@@ -94,101 +92,141 @@
{
std::cout << "testing constructors..." << std::endl;
- path x0; // #1
+ path x0; // default constructor
PATH_IS(x0, L"");
+ BOOST_TEST_EQ( x0.size(), 0 );
- path x1("path x1"); // #3
- PATH_IS(x1, L"path x1");
-
- path x2(x1); // #2
- PATH_IS(x2, L"path x1");
-
- path x3(L"const wchar_t *"); // #3
- PATH_IS(x3, L"const wchar_t *");
-
- string s3a( "s3a.c_str()" );
- path x3a( s3a.c_str() ); // #3
- PATH_IS(x3a, L"s3a.c_str()");
-
- path x4(string("std::string::iterator").begin()); // #3
- PATH_IS(x4, L"std::string::iterator");
-
- path x5(wstring(L"std::wstring::iterator").begin()); // #3
- PATH_IS(x5, L"std::wstring::iterator");
-
- path x7(s.begin(), s.end()); // #4
- PATH_IS(x7, L"string iterators");
-
- path x8(ws.begin(), ws.end()); // #4
- PATH_IS(x8, L"wstring iterators");
-
- path x10(string("std::string")); // #5
- PATH_IS(x10, L"std::string");
-
- path x11(wstring(L"std::wstring")); // #5
- PATH_IS(x11, L"std::wstring");
+ path x1(s.begin(), s.end()); // iterator range char
+ PATH_IS(x1, L"string");
+ BOOST_TEST_EQ( x1.size(), 6 );
+
+ path x2(x1); // copy constructor
+ PATH_IS(x2, L"string");
+ BOOST_TEST_EQ( x2.size(), 6 );
+
+ path x3(ws.begin(), ws.end()); // iterator range wchar_t
+ PATH_IS(x3, L"wstring");
+ BOOST_TEST_EQ( x3.size(), 7 );
+
+ path x4(string("std::string")); // container char
+ PATH_IS(x4, L"std::string");
+ BOOST_TEST_EQ( x4.size(), 11 );
+
+ path x5(wstring(L"std::wstring")); // container wchar_t
+ PATH_IS(x5, L"std::wstring");
+ BOOST_TEST_EQ( x5.size(), 12 );
+
+ path x6("array char"); // array char
+ PATH_IS(x6, L"array char");
+ BOOST_TEST_EQ( x6.size(), 10 );
+
+ path x7(L"array wchar_t"); // array wchar_t
+ PATH_IS(x7, L"array wchar_t");
+ BOOST_TEST_EQ( x7.size(), 13 );
+
+ path x8( s.c_str() ); // const char * null terminated
+ PATH_IS(x8, L"string");
+ BOOST_TEST_EQ( x8.size(), 6 );
+
+ path x9( ws.c_str() ); // const wchar_t * null terminated
+ PATH_IS(x9, L"wstring");
+ BOOST_TEST_EQ( x9.size(), 7 );
}
- // test_assignments ----------------------------------------------------------------//
+ path x;
+ path y;
+ // test_assignments ----------------------------------------------------------------//
+
void test_assignments()
{
std::cout << "testing assignments..." << std::endl;
- y = "path y"; // #2
- PATH_IS(y, L"path y");
+ x = path("yet another path"); // another path
+ PATH_IS(x, L"yet another path");
+ BOOST_TEST_EQ( x.size(), 16 );
- x = y; // #1
- PATH_IS(x, L"path y");
+ x = x; // self-assignment
+ PATH_IS(x, L"yet another path");
+ BOOST_TEST_EQ( x.size(), 16 );
- x = "const char *"; // #2
- PATH_IS(x, L"const char *");
+ x.assign(s.begin(), s.end()); // iterator range char
+ PATH_IS(x, L"string");
- x = L"const wchar_t *"; // #2
- PATH_IS(x, L"const wchar_t *");
+ x.assign(ws.begin(), ws.end()); // iterator range wchar_t
+ PATH_IS(x, L"wstring");
- x = string("std::string::iterator").begin(); // #2 w/iterator
- PATH_IS(x, L"std::string::iterator");
-
- x = wstring(L"std::wstring::iterator").begin(); // #2 w/iterator
- PATH_IS(x, L"std::wstring::iterator");
-
- y.assign("path y w/o ec"); // #3 w/o ec
- PATH_IS(y, L"path y w/o ec");
+ x = string("std::string"); // container char
+ PATH_IS(x, L"std::string");
- ec = ng;
- y.assign("path y w/ec", ec); // #3 w/ec
- PATH_IS(y, L"path y w/ec");
- IS(ec, ok);
+ x = wstring(L"std::wstring"); // container wchar_t
+ PATH_IS(x, L"std::wstring");
- x.assign(s.begin(), s.end()); // #4
- PATH_IS(x, L"string iterators");
+ x = "array char"; // array char
+ PATH_IS(x, L"array char");
- ec = ng;
- x.assign(s.begin(), s.end(), ec); // #4 w/ec
- PATH_IS(x, L"string iterators");
- IS(ec, ok);
+ x = L"array wchar"; // array wchar_t
+ PATH_IS(x, L"array wchar");
- x.assign(ws.begin(), ws.end()); // #4
- PATH_IS(x, L"wstring iterators");
+ x = s.c_str(); // const char * null terminated
+ PATH_IS(x, L"string");
- x = string("std::string"); // #5
- PATH_IS(x, L"std::string");
+ x = ws.c_str(); // const wchar_t * null terminated
+ PATH_IS(x, L"wstring");
+ }
- x = wstring(L"std::wstring"); // #5
- PATH_IS(x, L"std::wstring");
+ // test_appends --------------------------------------------------------------------//
- x.assign(string("std::string")); // #6
- PATH_IS(x, L"std::string");
+ void test_appends()
+ {
+ std::cout << "testing appends..." << std::endl;
- x.assign(wstring(L"std::wstring")); // #6
- PATH_IS(x, L"std::wstring");
+# ifdef BOOST_WINDOWS_PATH
+# define BOOST_FS_FOO L"/foo\\"
+# else // POSIX paths
+# define BOOST_FS_FOO L"/foo/"
+# endif
- ec = ng;
- x.assign(string("std::string"), ec); // #6 w/ec
- PATH_IS(x, L"std::string");
- IS(ec, ok);
+ x = "/foo";
+ x /= path("yet another path"); // another path
+ PATH_IS(x, BOOST_FS_FOO L"yet another path");
+
+ //x = "/foo";
+ //x /= x; // self-assignment
+ //PATH_IS(x, BOOST_FS_FOO L"yet another path" BOOST_FS_FOO L"yet another path");
+
+ x = "/foo";
+ x.append(s.begin(), s.end()); // iterator range char
+ PATH_IS(x, BOOST_FS_FOO L"string");
+
+ x = "/foo";
+ x.append(ws.begin(), ws.end()); // iterator range wchar_t
+ PATH_IS(x, BOOST_FS_FOO L"wstring");
+
+ x = "/foo";
+ x /= string("std::string"); // container char
+ PATH_IS(x, BOOST_FS_FOO L"std::string");
+
+ x = "/foo";
+ x /= wstring(L"std::wstring"); // container wchar_t
+ PATH_IS(x, BOOST_FS_FOO L"std::wstring");
+
+ x = "/foo";
+ x /= "array char"; // array char
+ PATH_IS(x, BOOST_FS_FOO L"array char");
+
+ x = "/foo";
+ x /= L"array wchar"; // array wchar_t
+ PATH_IS(x, BOOST_FS_FOO L"array wchar");
+
+ x = "/foo";
+ x /= s.c_str(); // const char * null terminated
+ PATH_IS(x, BOOST_FS_FOO L"string");
+
+ x = "/foo";
+ x /= ws.c_str(); // const wchar_t * null terminated
+ PATH_IS(x, BOOST_FS_FOO L"wstring");
}
// test_observers ------------------------------------------------------------------//
@@ -197,6 +235,14 @@
{
std::cout << "testing observers..." << std::endl;
+ path p0( "abc" );
+
+ CHECK( p0.source().size() == 3 );
+ CHECK( p0.string() == "abc" );
+ CHECK( p0.string().size() == 3 );
+ CHECK( p0.wstring() == L"abc" );
+ CHECK( p0.wstring().size() == 3 );
+
# ifdef BOOST_WINDOWS_PATH
path p( "abc\\def/ghi" );
@@ -214,18 +260,11 @@
# else // BOOST_POSIX_PATH
+ ...
# endif
}
-// // test_appends --------------------------------------------------------------------//
-//
-// void test_appends()
-// {
-// std::cout << "testing appends..." << std::endl;
-//
-// }
-
// test_relationals ----------------------------------------------------------------//
void test_relationals()
@@ -456,7 +495,7 @@
// \u2722 and \xE2\x9C\xA2 are UTF-16 and UTF-8 FOUR TEARDROP-SPOKED ASTERISK
std::cout << " testing p0 ..." << std::endl;
- path p0( L"\u2722" ); // for tests that depend on detail::convert_to_string
+ path p0( L"\u2722" ); // for tests that depend on path_traits::convert
# ifdef BOOST_WINDOWS_PATH
CHECK( p0.string() != "\xE2\x9C\xA2" );
# endif
@@ -495,6 +534,8 @@
std::cout << " locale testing complete" << std::endl;
}
+# if 0
+
// // test_locales --------------------------------------------------------------------//
//
// void test_locales()
@@ -572,20 +613,43 @@
CHECK( s1 == usr );
}
+# endif
+
+ // test_overloads ------------------------------------------------------------------//
+
+ void test_overloads()
+ {
+ std::cout << "testing overloads..." << std::endl;
+ std::string s("hello");
+ const char a[] = "goodbye";
+ path p1( s );
+ path p2( s.c_str() );
+ path p3( a );
+ path p4( "foo" );
+
+ std::wstring ws(L"hello");
+ const wchar_t wa[] = L"goodbye";
+ path wp1( ws );
+ path wp2( ws.c_str() );
+ path wp3( wa );
+ path wp4( L"foo" );
+ }
+
} // unnamed namespace
- //------------------------------------------------------------------------------------//
- // //
- // test_main //
- // //
- //------------------------------------------------------------------------------------//
+//--------------------------------------------------------------------------------------//
+// //
+// main //
+// //
+//--------------------------------------------------------------------------------------//
int main( int, char*[] )
{
+ test_overloads();
test_constructors();
test_assignments();
+ test_appends();
test_observers();
- ////test_appends();
test_relationals();
test_inserter_and_extractor();
test_other_non_members();
@@ -594,16 +658,18 @@
test_decompositions();
test_queries();
test_imbue_locale();
- //test_convert_with_locale();
+
+# if 0
+
test_user_supplied_type();
+#endif
+
std::string foo("\\abc");
const char * bar = "/abc";
if ( foo == bar )
cout << "unintended consequence\n";
-
- cout << errors << " errors detected\n";
-
- return errors;
+
+ return ::boost::report_errors();
}
Deleted: sandbox/filesystem-v3/libs/filesystem/test/wide_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/wide_test.cpp 2009-08-12 10:30:15 EDT (Wed, 12 Aug 2009)
+++ (empty file)
@@ -1,172 +0,0 @@
-// Boost wide_test.cpp -----------------------------------------------------//
-
-// Copyright Beman Dawes 2005
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// Library home page: http://www.boost.org/libs/filesystem
-
-//--------------------------------------------------------------------------------------//
-/*
- TODO
-
- * Add test for scoped_path_locale.
- */
-//--------------------------------------------------------------------------------------//
-
-#include <boost/config/warning_disable.hpp>
-
-// See deprecated_test for tests of deprecated features
-#define BOOST_FILESYSTEM_NO_DEPRECATED
-
-#include <boost/filesystem/config.hpp>
-# ifdef BOOST_FILESYSTEM_NARROW_ONLY
-# error This compiler or standard library does not support wide-character strings or paths
-# endif
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include "../src/utf8_codecvt_facet.hpp"
-
-namespace fs = boost::filesystem;
-
-#include <iostream>
-#include <iomanip>
-#include <ios>
-#include <string>
-#include <cerrno>
-
-#include "lpath.hpp"
-
-namespace
-{
- bool cleanup = true;
-
- template< class Path >
- void create_file( const Path & ph, const std::string & contents )
- {
- // TODO: why missing symbol error on Darwin
-# ifndef __APPLE__
- fs::ofstream f( ph );
-# else
- std::ofstream f( ph.external_file_string().c_str() );
-# endif
- if ( !f )
- throw fs::basic_filesystem_error<Path>( "wide_test create_file",
- ph,
- boost::system::error_code( errno, boost::system::errno_ecat ) );
- if ( !contents.empty() ) f << contents;
- }
-
- template< class Path >
- void test( const Path & dir, const Path & file, const Path & dot )
- {
- Path tmp;
- tmp = file;
- BOOST_TEST( tmp == file );
- tmp = file.string();
- BOOST_TEST( tmp == file );
- tmp = file.string().c_str();
- BOOST_TEST( tmp == file );
- fs::initial_path<Path>();
- fs::current_path<Path>();
- fs::remove( dir / file );
- fs::remove( dir );
- BOOST_TEST( !fs::exists( dir / file ) );
- BOOST_TEST( !fs::exists( dir ) );
- BOOST_TEST( fs::create_directory( dir ) );
- BOOST_TEST( fs::exists( dir ) );
- BOOST_TEST( fs::is_directory( dir ) );
- BOOST_TEST( fs::is_empty( dir ) );
- create_file( dir / file, "wide_test file contents" );
- BOOST_TEST( fs::exists( dir / file ) );
- BOOST_TEST( !fs::is_directory( dir / file ) );
- BOOST_TEST( !fs::is_empty( dir / file ) );
- BOOST_TEST( fs::file_size( dir / file ) == 23 || fs::file_size( dir / file ) == 24 );
- BOOST_TEST( fs::equivalent( dir / file, dot / dir / file ) );
- BOOST_TEST( fs::last_write_time( dir / file ) );
- typedef fs::basic_directory_iterator<Path> it_t;
- int count(0);
- for ( it_t it( dir ); it != it_t(); ++it )
- {
- BOOST_TEST( it->path() == dir / file );
- BOOST_TEST( !fs::is_empty( it->path() ) );
- ++count;
- }
- BOOST_TEST( count == 1 );
- if ( cleanup )
- {
- fs::remove( dir / file );
- fs::remove( dir );
- }
- }
-
- // test boost::detail::utf8_codecvt_facet - even though it is not used by
- // Boost.Filesystem on Windows, early detection of problems is worthwhile.
- std::string to_external( const std::wstring & src )
- {
- fs::detail::utf8_codecvt_facet convertor;
- std::size_t work_size( convertor.max_length() * (src.size()+1) );
- boost::scoped_array<char> work( new char[ work_size ] );
- std::mbstate_t state;
- const wchar_t * from_next;
- char * to_next;
- if ( convertor.out(
- state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
- work.get()+work_size, to_next ) != std::codecvt_base::ok )
- boost::throw_exception( std::runtime_error("to_external conversion error") );
- *to_next = '\0';
- return std::string( work.get() );
- }
-
-} // unnamed namespace
-
- //------------------------------------------------------------------------------------//
- // //
- // main //
- // //
- //------------------------------------------------------------------------------------//
-
-int main( int argc, char * /*argv*/[] )
-{
-
- if ( argc > 1 ) cleanup = false;
-
- // So that tests are run with known encoding, use Boost UTF-8 codecvt
- std::locale global_loc = std::locale();
- std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet );
- fs::wpath_traits::imbue( loc );
-
- std::string s( to_external( L"\x2780" ) );
- for (std::size_t i = 0; i < s.size(); ++i )
- std::cout << std::hex << int( static_cast<unsigned char>(s[i]) ) << " ";
- std::cout << std::dec << std::endl;
- BOOST_TEST( to_external( L"\x2780" ).size() == 3 );
- BOOST_TEST( to_external( L"\x2780" ) == "\xE2\x9E\x80" );
-
- // test fs::path
- std::cout << "begin path test..." << std::endl;
- test( fs::path( "foo" ), fs::path( "bar" ), fs::path( "." ) );
- std::cout << "complete\n\n";
-
- // test fs::wpath
- // x2780 is circled 1 against white background == e2 9e 80 in UTF-8
- // x2781 is circled 2 against white background == e2 9e 81 in UTF-8
- std::cout << "begin wpath test..." << std::endl;
- test( fs::wpath( L"\x2780" ), fs::wpath( L"\x2781" ), fs::wpath( L"." ) );
- std::cout << "complete\n\n";
-
- // test user supplied basic_path
- const long dir[] = { 'b', 'o', 'o', 0 };
- const long file[] = { 'f', 'a', 'r', 0 };
- const long dot[] = { '.', 0 };
- std::cout << "begin lpath test..." << std::endl;
- test( ::user::lpath( dir ), ::user::lpath( file ), ::user::lpath( dot ) );
- std::cout << "complete\n\n";
-
- return ::boost::report_errors();
-}
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