|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57437 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc 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_test_dynamic_link libs/filesystem/test/msvc/path_unit_test libs/filesystem/test/msvc/system_dll
From: bdawes_at_[hidden]
Date: 2009-11-06 12:04:06
Author: bemandawes
Date: 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
New Revision: 57437
URL: http://svn.boost.org/trac/boost/changeset/57437
Log:
Fix status() semantics and correct resulting fallout. Continue code formatting. Clear VC++ /W4 compiler warnings.
Text files modified:
sandbox/filesystem-v3/boost/filesystem/operations.hpp | 21
sandbox/filesystem-v3/boost/filesystem/path_traits.hpp | 88
sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 7
sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp | 22
sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp | 8
sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 65
sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 362 +++---
sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp | 96
sandbox/filesystem-v3/libs/filesystem/src/portability.cpp | 40
sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp | 20
sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp | 22
sandbox/filesystem-v3/libs/filesystem/test/convenience_test.cpp | 134 +-
sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp | 268 ++--
sandbox/filesystem-v3/libs/filesystem/test/fstream_test.cpp | 85
sandbox/filesystem-v3/libs/filesystem/test/msvc/common.vsprops | 1
sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test_dynamic_link/path_test_dynamic_linkl.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj | 4
sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 1128 +++++++++---------
sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp | 96
sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp | 2280 ++++++++++++++++++++--------------------
sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 515 ++++----
27 files changed, 2656 insertions(+), 2634 deletions(-)
Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -74,7 +74,10 @@
enum file_type
{
- status_unknown,
+ status_error,
+# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
+ status_unknown = status_error,
+# endif
file_not_found,
regular_file,
directory_file,
@@ -91,9 +94,9 @@
class BOOST_FILESYSTEM_DECL file_status
{
public:
- explicit file_status(file_type v = status_unknown) : m_value(v) {}
+ explicit file_status(file_type v = status_error) : m_value(v) {}
- void type(file_type v) { m_value = v; }
+ void type(file_type v) { m_value = v; }
file_type type() const { return m_value; }
bool operator==(const file_status& rhs) const { return type() == rhs.type(); }
@@ -107,8 +110,8 @@
file_type m_value;
};
- inline bool status_known(file_status f) { return f.type() != status_unknown; }
- inline bool exists(file_status f) { return f.type() != status_unknown
+ inline bool status_known(file_status f) { return f.type() != status_error; }
+ inline bool exists(file_status f) { return f.type() != status_error
&& f.type() != file_not_found; }
inline bool is_regular_file(file_status f){ return f.type() == regular_file; }
inline bool is_directory(file_status f) { return f.type() == directory_file; }
@@ -535,12 +538,12 @@
namespace detail
{
BOOST_FILESYSTEM_DECL
- system::error_code dir_itr_close( // never throws()
+ system::error_code dir_itr_close(// never throws()
void *& handle
# if defined(BOOST_POSIX_API)
, void *& buffer
# endif
- );
+ );
struct BOOST_FILESYSTEM_DECL dir_itr_imp
{
@@ -563,7 +566,7 @@
# if defined(BOOST_POSIX_API)
, buffer
# endif
- );
+ );
}
};
@@ -695,7 +698,7 @@
return m_imp_ptr.get() ? m_imp_ptr->m_path2 : empty_path ;
}
- const char * what() const throw()
+ const char* what() const throw()
{
if (!m_imp_ptr.get())
return system::system_error::what();
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -41,86 +41,86 @@
// Pathable empty
template <class Container> inline
- bool empty( const Container & c )
+ bool empty(const Container & c)
{ return c.begin() == c.end(); }
template <class T> inline
- bool empty( T * const & c_str )
+ bool empty(T * const & c_str)
{
- BOOST_ASSERT( c_str );
+ BOOST_ASSERT(c_str);
return !*c_str;
}
template <typename T, size_t N> inline
- bool empty( T (&array)[N] )
+ bool empty(T (&)[N])
{ return N <= 1; }
// Pathable dispatch
template <class Container, class U> inline
- void dispatch( const Container & c, U & to, const codecvt_type & cvt )
+ 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 );
+ 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 )
+ void dispatch(T * const & c_str, U & to, const codecvt_type & cvt)
{
// std::cout << "dispatch() const T *\n";
- BOOST_ASSERT( c_str );
- convert( c_str, to, cvt );
+ BOOST_ASSERT(c_str);
+ 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
+ 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 );
+ convert(array, array + N - 1, to, cvt);
}
BOOST_FILESYSTEM_DECL
- void dispatch( const directory_entry & de,
+ void dispatch(const directory_entry & de,
# ifdef BOOST_WINDOWS_API
std::wstring & to,
# else
std::string & to,
# endif
- const codecvt_type & );
+ const codecvt_type &);
// value types differ ---------------------------------------------------------------//
//
// A from_end argument of 0 is less efficient than a known end, so use only if needed
BOOST_FILESYSTEM_DECL
- void convert( const char * from,
- const char * from_end, // 0 for null terminated MBCS
+ void convert(const char* from,
+ const char* from_end, // 0 for null terminated MBCS
std::wstring & to,
- const codecvt_type & cvt );
+ const codecvt_type & cvt);
BOOST_FILESYSTEM_DECL
- void convert( const wchar_t * from,
- const wchar_t * from_end, // 0 for null terminated MBCS
+ void convert(const wchar_t* from,
+ const wchar_t* from_end, // 0 for null terminated MBCS
std::string & to,
- const codecvt_type & cvt );
+ const codecvt_type & cvt);
inline
- void convert( const char * from,
+ void convert(const char* from,
std::wstring & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt)
{
- BOOST_ASSERT( from );
- convert( from, 0, to, cvt );
+ BOOST_ASSERT(from);
+ convert(from, 0, to, cvt);
}
inline
- void convert( const wchar_t * from,
+ void convert(const wchar_t* from,
std::string & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt)
{
- BOOST_ASSERT( from );
- convert( from, 0, to, cvt );
+ BOOST_ASSERT(from);
+ convert(from, 0, to, cvt);
}
// value types same -----------------------------------------------------------------//
@@ -128,40 +128,40 @@
// char
inline
- void convert( const char * from, const char * from_end, std::string & to,
- const codecvt_type & )
+ void convert(const char* from, const char* from_end, std::string & to,
+ const codecvt_type &)
{
- BOOST_ASSERT( from );
- BOOST_ASSERT( from_end );
- to.append( from, from_end );
+ BOOST_ASSERT(from);
+ BOOST_ASSERT(from_end);
+ to.append(from, from_end);
}
inline
- void convert( const char * from,
+ void convert(const char* from,
std::string & to,
- const codecvt_type & )
+ const codecvt_type &)
{
- BOOST_ASSERT( from );
+ BOOST_ASSERT(from);
to += from;
}
// wchar_t
inline
- void convert( const wchar_t * from, const wchar_t * from_end, std::wstring & to,
- const codecvt_type & )
+ void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
+ const codecvt_type &)
{
- BOOST_ASSERT( from );
- BOOST_ASSERT( from_end );
- to.append( from, from_end );
+ BOOST_ASSERT(from);
+ BOOST_ASSERT(from_end);
+ to.append(from, from_end);
}
inline
- void convert( const wchar_t * from,
+ void convert(const wchar_t* from,
std::wstring & to,
- const codecvt_type & )
+ const codecvt_type &)
{
- BOOST_ASSERT( from );
+ BOOST_ASSERT(from);
to += from;
}
Modified: sandbox/filesystem-v3/libs/filesystem/doc/reference.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/reference.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/reference.html 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -2241,16 +2241,15 @@
end note</i>]</p>
<p>For the <code>error_code&</code> overload:</p>
<ul>
- <li>If the underlying file system API reports no error during attribute
- determination, <code>ec.clear()</code>.<br>
+ <li>If, during attribute determination, the underlying file system API reports no error, <code>ec.clear()</code>.<br>
</li>
<li>Otherwise, <code>ec</code> is set according to the error reported by
the underlying file system API.</li>
</ul>
<blockquote>
<p>[<i>Note:</i> This allows users to inspect the specifics of underlying
- API errors even when the value returned by <code>status()</code> is <code>
- file_status(file_not_found)</code>. <i>--end note</i>]</p>
+ API errors even when the value returned by <code>status()</code> is not <code>
+ file_status(status_error)</code>. <i>--end note</i>]</p>
</blockquote>
</blockquote>
<p><i>Returns:</i></p>
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -18,12 +18,12 @@
namespace fs = boost::filesystem;
-int main( int argc, char* argv[] )
+int main(int argc, char* argv[])
{
- fs::path p( fs::initial_path() );
+ fs::path p(fs::initial_path());
- if ( argc > 1 )
- p = fs::system_complete( argv[1] );
+ if (argc > 1)
+ p = fs::system_complete(argv[1]);
else
std::cout << "\nusage: simple_ls [path]" << std::endl;
@@ -32,29 +32,29 @@
unsigned long other_count = 0;
unsigned long err_count = 0;
- if ( !fs::exists( p ) )
+ if (!fs::exists(p))
{
std::cout << "\nNot found: " << p.string() << std::endl;
return 1;
}
- if ( fs::is_directory( p ) )
+ if (fs::is_directory(p))
{
std::cout << "\nIn directory: "
<< p.string() << "\n\n";
fs::directory_iterator end_iter;
- for ( fs::directory_iterator dir_itr( p );
+ for (fs::directory_iterator dir_itr(p);
dir_itr != end_iter;
- ++dir_itr )
+ ++dir_itr)
{
try
{
- if ( fs::is_directory( dir_itr->status() ) )
+ if (fs::is_directory(dir_itr->status()))
{
++dir_count;
std::cout << dir_itr->path().filename() << " [directory]\n";
}
- else if ( fs::is_regular_file( dir_itr->status() ) )
+ else if (fs::is_regular_file(dir_itr->status()))
{
++file_count;
std::cout << dir_itr->path().filename() << "\n";
@@ -66,7 +66,7 @@
}
}
- catch ( const std::exception & ex )
+ catch (const std::exception & ex)
{
++err_count;
std::cout << dir_itr->path().filename() << " " << ex.what() << std::endl;
Modified: sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -30,16 +30,16 @@
{
public:
codecvt_error_cat(){}
- const char * name() const;
- std::string message( int ev ) const;
+ const char* name() const;
+ std::string message(int ev) const;
};
- const char * codecvt_error_cat::name() const
+ const char* codecvt_error_cat::name() const
{
return "codecvt";
}
- std::string codecvt_error_cat::message( int ev ) const
+ std::string codecvt_error_cat::message(int ev) const
{
std::string str;
switch (ev)
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -1,6 +1,6 @@
// operations.cpp --------------------------------------------------------------------//
-// Copyright 2002-2005 Beman Dawes
+// Copyright 2002-2009 Beman Dawes
// Copyright 2001 Dietmar Kuehl
// Distributed under the Boost Software License, Version 1.0.
@@ -387,13 +387,13 @@
}
inline std::size_t get_full_path_name(
- const path& src, std::size_t len, wchar_t * buf, wchar_t ** p)
+ const path& src, std::size_t len, wchar_t* buf, wchar_t** p)
{
return static_cast<std::size_t>(
::GetFullPathNameW(src.c_str(), static_cast<DWORD>(len), buf, p));
}
- BOOL resize_file_api(const wchar_t * p, boost::uintmax_t size)
+ BOOL resize_file_api(const wchar_t* p, boost::uintmax_t size)
{
HANDLE handle = CreateFileW(p, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
@@ -458,7 +458,7 @@
int oflag = O_CREAT | O_WRONLY;
if (fail_if_exists)oflag |= O_EXCL;
- if ( (outfile = ::open(to_p.c_str(), oflag, from_stat.st_mode))< 0)
+ if ((outfile = ::open(to_p.c_str(), oflag, from_stat.st_mode))< 0)
{
int open_errno = errno;
BOOST_ASSERT(infile >= 0);
@@ -504,7 +504,7 @@
//
//#else // BOOST_POSIX_API
//
-// int posix_remove(const char * p)
+// int posix_remove(const char* p)
// {
//# if defined(__QNXNTO__) || (defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)))
// // Some Metrowerks C library versions fail on directories because of a
@@ -1112,7 +1112,7 @@
{
error_code tmp_ec;
file_status sym_status = symlink_status(p, tmp_ec);
- if (error(!!tmp_ec, tmp_ec, p, ec, "boost::filesystem::remove"))
+ if (error(sym_status.type() == status_error, tmp_ec, p, ec, "boost::filesystem::remove"))
return false;
return remove_file_or_directory(p, sym_status, ec);
@@ -1123,10 +1123,10 @@
{
error_code tmp_ec;
file_status sym_status = symlink_status(p, tmp_ec);
- if (error(!!tmp_ec, tmp_ec, p, ec, "boost::filesystem::remove_all"))
+ if (error(sym_status.type() == status_error, tmp_ec, p, ec, "boost::filesystem::remove_all"))
return 0;
- return exists(sym_status)
+ return exists(sym_status) // exists() throws nothing
? remove_all_aux(p, sym_status, ec)
: 0;
}
@@ -1203,6 +1203,9 @@
file_status process_status_failure(const path& p, error_code* ec)
{
int errval(::GetLastError());
+ if (ec != 0) // always report errval, even though some
+ ec->assign(errval, system_category); // errval values are not status_errors
+
if ((errval == ERROR_FILE_NOT_FOUND)
|| (errval == ERROR_PATH_NOT_FOUND)
|| (errval == ERROR_INVALID_NAME)// "tools/jam/src/:sys:stat.h", "//foo"
@@ -1210,21 +1213,16 @@
|| (errval == ERROR_BAD_PATHNAME)// "//nosuch" on Win64
|| (errval == ERROR_BAD_NETPATH))// "//nosuch" on Win32
{
-
- if (ec != 0) ec->clear(); // these are not errors
return file_status(file_not_found);
}
else if ((errval == ERROR_SHARING_VIOLATION))
{
- if (ec != 0) ec->clear(); // these are not errors
return file_status(type_unknown);
}
if (ec == 0)
throw_exception(filesystem_error("boost::filesystem::status",
p, error_code(errval, system_category)));
- else
- ec->assign(errval, system_category);
- return file_status(status_unknown);
+ return file_status(status_error);
}
# endif
@@ -1258,7 +1256,7 @@
}
}
- if (ec != 0) ec->clear(); // these are not errors
+ if (ec != 0) ec->clear();
return (attr & FILE_ATTRIBUTE_DIRECTORY)
? file_status(directory_file)
: file_status(regular_file);
@@ -1268,18 +1266,17 @@
struct stat path_stat;
if (::stat(p.c_str(), &path_stat)!= 0)
{
+ if (ec != 0) // always report errno, even though some
+ ec->assign(errno, system_category); // errno values are not status_errors
+
if (errno == ENOENT || errno == ENOTDIR)
{
- if (ec != 0) ec->clear();;
return fs::file_status(fs::file_not_found);
}
- if (ec != 0)
- ec->assign(errno, system_category);
- else
+ if (ec == 0)
throw_exception(filesystem_error("boost::filesystem::status",
p, errno, system_category));
-
- return fs::file_status(fs::status_unknown);
+ return fs::file_status(fs::status_error);
}
if (ec != 0) ec->clear();;
if (S_ISDIR(path_stat.st_mode))
@@ -1310,10 +1307,11 @@
return detail::process_status_failure(p, ec);
}
+ if (ec != 0) ec->clear();
+
if (attr & FILE_ATTRIBUTE_REPARSE_POINT)// aka symlink
return file_status(symlink_file);
- if (ec != 0) ec->clear(); // these are not errors
return (attr & FILE_ATTRIBUTE_DIRECTORY)
? file_status(directory_file)
: file_status(regular_file);
@@ -1323,14 +1321,17 @@
struct stat path_stat;
if (::lstat(p.c_str(), &path_stat)!= 0)
{
+ if (ec != 0) // always report errno, even though some
+ ec->assign(errno, system_category); // errno values are not status_errors
+
if (errno == ENOENT || errno == ENOTDIR) // these are not errors
{
- if (ec != 0) ec->clear();
return fs::file_status(fs::file_not_found);
}
- if (ec != 0) ec->assign(errno, system_category);
- else
- return fs::file_status(fs::status_unknown);
+ if (ec == 0)
+ throw_exception(filesystem_error("boost::filesystem::status",
+ p, errno, system_category));
+ return fs::file_status(fs::status_error);
}
if (ec != 0) ec->clear();
if (S_ISREG(path_stat.st_mode))
@@ -1362,7 +1363,7 @@
return p;
}
wchar_t buf[buf_size];
- wchar_t * pfn;
+ wchar_t* pfn;
std::size_t len = get_full_path_name(p, buf_size, buf, &pfn);
if (error(len == 0, p, ec, "boost::filesystem::system_complete"))
@@ -1524,7 +1525,7 @@
}
error_code dir_itr_first(void *& handle, void *& buffer,
- const char * dir, string& target,
+ const char* dir, string& target,
fs::file_status &, fs::file_status &)
{
if ((handle = ::opendir(dir))== 0)
@@ -1590,7 +1591,7 @@
# ifdef BOOST_FILESYSTEM_STATUS_CACHE
if (entry->d_type == DT_UNKNOWN) // filesystem does not supply d_type value
{
- sf = symlink_sf = fs::file_status(fs::status_unknown);
+ sf = symlink_sf = fs::file_status(fs::status_error);
}
else // filesystem supplies d_type value
{
@@ -1600,13 +1601,13 @@
sf = symlink_sf = fs::file_status(fs::regular_file);
else if (entry->d_type == DT_LNK)
{
- sf = fs::file_status(fs::status_unknown);
+ sf = fs::file_status(fs::status_error);
symlink_sf = fs::file_status(fs::symlink_file);
}
- else sf = symlink_sf = fs::file_status(fs::status_unknown);
+ else sf = symlink_sf = fs::file_status(fs::status_error);
}
# else
- sf = symlink_sf = fs::file_status(fs::status_unknown);
+ sf = symlink_sf = fs::file_status(fs::status_error);
# endif
return ok;
}
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -65,27 +65,27 @@
const wchar_t separator = L'/';
const wchar_t preferred_separator = L'\\';
- const wchar_t * const separators = L"/\\";
- const wchar_t * separator_string = L"/";
- const wchar_t * preferred_separator_string = L"\\";
+ const wchar_t* const separators = L"/\\";
+ const wchar_t* separator_string = L"/";
+ const wchar_t* preferred_separator_string = L"\\";
const wchar_t colon = L':';
const wchar_t dot = L'.';
- const fs::path dot_path( L"." );
+ const fs::path dot_path(L".");
# else
const char separator = '/';
const char preferred_separator = '/';
- const char * const separators = "/";
- const char * separator_string = "/";
- const char * preferred_separator_string = "/";
+ const char* const separators = "/";
+ const char* separator_string = "/";
+ const char* preferred_separator_string = "/";
const char colon = ':';
const char dot = '.';
- const fs::path dot_path( "." );
+ const fs::path dot_path(".");
# endif
- inline bool is_separator( fs::path::value_type c )
+ inline bool is_separator(fs::path::value_type c)
{
return c == separator
# ifdef BOOST_WINDOWS_PATH
@@ -94,21 +94,21 @@
;
}
- bool is_non_root_separator( const string_type & str, size_type pos );
+ bool is_non_root_separator(const string_type & str, size_type pos);
// pos is position of the separator
- size_type filename_pos( const string_type & str,
- size_type end_pos ); // end_pos is past-the-end position
+ size_type filename_pos(const string_type & str,
+ size_type end_pos); // end_pos is past-the-end position
// Returns: 0 if str itself is filename (or empty)
- size_type root_directory_start( const string_type & path, size_type size );
+ size_type root_directory_start(const string_type & path, size_type size);
// Returns: npos if no root_directory found
void first_element(
const string_type & src,
size_type & element_pos,
size_type & element_size,
-# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1310 ) // VC++ 7.1
+# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310) // VC++ 7.1
size_type size = string_type::npos
# else
size_type size = -1
@@ -128,11 +128,11 @@
namespace filesystem
{
- path & path::operator/=( const path & p )
+ path & path::operator/=(const path & p)
{
- if ( p.empty() )
+ if (p.empty())
return *this;
- if ( !is_separator( *p.m_path.begin() ) )
+ if (!is_separator(*p.m_path.begin()))
m_append_separator_if_needed();
m_path += p.m_path;
return *this;
@@ -143,42 +143,42 @@
const std::string path::native_string() const
{
std::string tmp;
- if ( !m_path.empty() )
- path_traits::convert( &*m_path.begin(), &*m_path.begin()+m_path.size(),
- tmp, codecvt() );
+ if (!m_path.empty())
+ path_traits::convert(&*m_path.begin(), &*m_path.begin()+m_path.size(),
+ tmp, codecvt());
return tmp;
}
void path::m_portable()
{
- for ( string_type::iterator it = m_path.begin();
- it != m_path.end(); ++it )
+ for (string_type::iterator it = m_path.begin();
+ it != m_path.end(); ++it)
{
- if ( *it == L'\\' )
+ if (*it == L'\\')
*it = L'/';
}
}
const std::string path::string() const
{
- path tmp( *this );
+ path tmp(*this);
tmp.m_portable();
return tmp.native_string();
}
const std::wstring path::wstring() const
{
- path tmp( *this );
+ path tmp(*this);
tmp.m_portable();
return tmp.native_wstring();
}
path & path::localize()
{
- for ( string_type::iterator it = m_path.begin();
- it != m_path.end(); ++it )
+ for (string_type::iterator it = m_path.begin();
+ it != m_path.end(); ++it)
{
- if ( *it == L'/' )
+ if (*it == L'/')
*it = L'\\';
}
return *this;
@@ -190,13 +190,13 @@
path::string_type::size_type path::m_append_separator_if_needed()
{
- if ( !m_path.empty() &&
+ if (!m_path.empty() &&
# ifdef BOOST_WINDOWS_PATH
*(m_path.end()-1) != colon &&
# endif
- !is_separator( *(m_path.end()-1) ) )
+ !is_separator(*(m_path.end()-1)))
{
- string_type::size_type tmp( m_path.size() );
+ string_type::size_type tmp(m_path.size());
m_path += preferred_separator;
return tmp;
}
@@ -205,133 +205,133 @@
// m_erase_redundant_separator -----------------------------------------------------//
- void path::m_erase_redundant_separator( string_type::size_type sep_pos )
+ void path::m_erase_redundant_separator(string_type::size_type sep_pos)
{
- if ( sep_pos // a separator was added
+ if (sep_pos // a separator was added
&& sep_pos < m_path.size() // and something was appended
&& (m_path[sep_pos+1] == separator // and it was also separator
# ifdef BOOST_WINDOWS_PATH
|| m_path[sep_pos+1] == preferred_separator // or preferred_separator
# endif
- )) { m_path.erase( sep_pos, 1 ); } // erase the added separator
+)) { m_path.erase(sep_pos, 1); } // erase the added separator
}
// decomposition -------------------------------------------------------------------//
path path::root_path() const
{
- path temp( root_name() );
- if ( !root_directory().empty() ) temp.m_path += root_directory().c_str();
+ path temp(root_name());
+ if (!root_directory().empty()) temp.m_path += root_directory().c_str();
return temp;
}
path path::root_name() const
{
- iterator itr( begin() );
+ iterator itr(begin());
- return ( itr.m_pos != m_path.size()
+ return (itr.m_pos != m_path.size()
&& (
- ( itr.m_element.m_path.size() > 1
- && is_separator( itr.m_element.m_path[0] )
- && is_separator( itr.m_element.m_path[1] )
- )
+ (itr.m_element.m_path.size() > 1
+ && is_separator(itr.m_element.m_path[0])
+ && is_separator(itr.m_element.m_path[1])
+ )
# ifdef BOOST_WINDOWS_PATH
|| itr.m_element.m_path[itr.m_element.m_path.size()-1] == colon
# endif
- ) )
+ ))
? itr.m_element
: path();
}
path path::root_directory() const
{
- size_type pos( root_directory_start( m_path, m_path.size() ) );
+ size_type pos(root_directory_start(m_path, m_path.size()));
return pos == string_type::npos
? path()
- : path( m_path.c_str() + pos, m_path.c_str() + pos + 1 );
+ : path(m_path.c_str() + pos, m_path.c_str() + pos + 1);
}
path path::relative_path() const
{
- iterator itr( begin() );
+ iterator itr(begin());
- for ( ; itr.m_pos != m_path.size()
- && ( is_separator( itr.m_element.m_path[0] )
+ for (; itr.m_pos != m_path.size()
+ && (is_separator(itr.m_element.m_path[0])
# ifdef BOOST_WINDOWS_PATH
|| itr.m_element.m_path[itr.m_element.m_path.size()-1] == colon
# endif
- ); ++itr ) {}
+ ); ++itr) {}
- return path( m_path.c_str() + itr.m_pos );
+ return path(m_path.c_str() + itr.m_pos);
}
path path::parent_path() const
{
- size_type end_pos( filename_pos( m_path, m_path.size() ) );
+ size_type end_pos(filename_pos(m_path, m_path.size()));
- bool filename_was_separator( m_path.size()
- && is_separator( m_path[end_pos] ) );
+ bool filename_was_separator(m_path.size()
+ && is_separator(m_path[end_pos]));
// skip separators unless root directory
- size_type root_dir_pos( root_directory_start( m_path, end_pos ) );
- for ( ;
+ size_type root_dir_pos(root_directory_start(m_path, end_pos));
+ for (;
end_pos > 0
&& (end_pos-1) != root_dir_pos
- && is_separator( m_path[end_pos-1] )
+ && is_separator(m_path[end_pos-1])
;
- --end_pos ) {}
+ --end_pos) {}
return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator)
? path()
- : path( m_path.c_str(), m_path.c_str() + end_pos );
+ : path(m_path.c_str(), m_path.c_str() + end_pos);
}
path path::filename() const
{
- size_type pos( filename_pos( m_path, m_path.size() ) );
+ size_type pos(filename_pos(m_path, m_path.size()));
return (m_path.size()
&& pos
- && is_separator( m_path[pos] )
+ && is_separator(m_path[pos])
&& is_non_root_separator(m_path, pos))
? dot_path
- : path( m_path.c_str() + pos );
+ : path(m_path.c_str() + pos);
}
path path::stem() const
{
- path name( filename() );
- size_type pos( name.m_path.rfind( dot ) );
+ path name(filename());
+ size_type pos(name.m_path.rfind(dot));
return pos == string_type::npos
? name
- : path( name.m_path.c_str(), name.m_path.c_str() + pos );
+ : path(name.m_path.c_str(), name.m_path.c_str() + pos);
}
path path::extension() const
{
- path name( filename() );
- size_type pos( name.m_path.rfind( dot ) );
+ path name(filename());
+ size_type pos(name.m_path.rfind(dot));
return pos == string_type::npos
? path()
- : path( name.m_path.c_str() + pos );
+ : path(name.m_path.c_str() + pos);
}
path & path::remove_filename()
{
- m_path.erase( filename_pos( m_path, m_path.size() ) );
+ m_path.erase(filename_pos(m_path, m_path.size()));
return *this;
}
- path & path::replace_extension( const path & source )
+ path & path::replace_extension(const path & source)
{
// erase existing extension if any
- size_type pos( m_path.rfind( dot ) );
- if ( pos != string_type::npos )
- m_path.erase( pos );
+ size_type pos(m_path.rfind(dot));
+ if (pos != string_type::npos)
+ m_path.erase(pos);
// append source extension if any
- pos = source.m_path.rfind( dot );
- if ( pos != string_type::npos )
+ pos = source.m_path.rfind(dot);
+ if (pos != string_type::npos)
m_path += source.c_str() + pos;
return *this;
@@ -343,28 +343,28 @@
//
// path & path::m_normalize()
// {
-// if ( m_path.empty() ) return *this;
+// 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 )
+// 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
+// if (itr->size() == 1
// && (*itr)[0] == dot
// && itr != start
-// && itr != last ) continue;
+// && itr != last) continue;
//
// // ignore a name and following ".."
-// if ( !temp.empty()
+// if (!temp.empty()
// && itr->size() == 2
// && (*itr)[0] == dot
-// && (*itr)[1] == dot ) // dot dot
+// && (*itr)[1] == dot) // dot dot
// {
-// string_type lf( temp.filename() );
-// if ( lf.size() > 0
+// string_type lf(temp.filename());
+// if (lf.size() > 0
// && (lf.size() != 1
// || (lf[0] != dot
// && lf[0] != separator))
@@ -380,21 +380,21 @@
// {
// temp.remove_filename();
// // if not root directory, must also remove "/" if any
-// if ( temp.m_path.size() > 0
+// if (temp.m_path.size() > 0
// && temp.m_path[temp.m_path.size()-1]
-// == separator )
+// == 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 ); }
+// 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;
+// iterator next(itr);
+// if (temp.empty() && ++next != stop
+// && next == last && *last == dot_str) temp /= dot_str;
// continue;
// }
// }
@@ -402,7 +402,7 @@
// temp /= *itr;
// };
//
-// if ( temp.empty() ) temp /= dot_str;
+// if (temp.empty()) temp /= dot_str;
// m_path = temp.m_path;
// return *this;
// }
@@ -421,19 +421,19 @@
// is_non_root_separator -------------------------------------------------//
- bool is_non_root_separator( const string_type & str, size_type pos )
+ bool is_non_root_separator(const string_type & str, size_type pos)
// pos is position of the separator
{
- BOOST_ASSERT( !str.empty() && is_separator( str[pos] )
- && "precondition violation" );
+ BOOST_ASSERT(!str.empty() && is_separator(str[pos])
+ && "precondition violation");
// subsequent logic expects pos to be for leftmost slash of a set
- while ( pos > 0 && is_separator( str[pos-1] ) )
+ while (pos > 0 && is_separator(str[pos-1]))
--pos;
return pos != 0
- && (pos <= 2 || !is_separator( str[1] )
- || str.find_first_of( separators, 2 ) != pos)
+ && (pos <= 2 || !is_separator(str[1])
+ || str.find_first_of(separators, 2) != pos)
# ifdef BOOST_WINDOWS_PATH
&& (pos !=2 || str[1] != colon)
# endif
@@ -442,63 +442,63 @@
// filename_pos ----------------------------------------------------------//
- size_type filename_pos( const string_type & str,
- size_type end_pos ) // end_pos is past-the-end position
+ size_type filename_pos(const string_type & str,
+ size_type end_pos) // end_pos is past-the-end position
// return 0 if str itself is filename (or empty)
{
// case: "//"
- if ( end_pos == 2
- && is_separator( str[0] )
- && is_separator( str[1] ) ) return 0;
+ if (end_pos == 2
+ && is_separator(str[0])
+ && is_separator(str[1])) return 0;
// case: ends in "/"
- if ( end_pos && is_separator( str[end_pos-1] ) )
+ if (end_pos && is_separator(str[end_pos-1]))
return end_pos-1;
// set pos to start of last element
- size_type pos( str.find_last_of( separators, end_pos-1 ) );
+ size_type pos(str.find_last_of(separators, end_pos-1));
# ifdef BOOST_WINDOWS_PATH
- if ( pos == string_type::npos )
- pos = str.find_last_of( colon, end_pos-2 );
+ if (pos == string_type::npos)
+ pos = str.find_last_of(colon, end_pos-2);
# endif
- return ( pos == string_type::npos // path itself must be a filename (or empty)
- || (pos == 1 && is_separator( str[0] )) ) // or net
+ return (pos == string_type::npos // path itself must be a filename (or empty)
+ || (pos == 1 && is_separator(str[0]))) // or net
? 0 // so filename is entire string
: pos + 1; // or starts after delimiter
}
// root_directory_start --------------------------------------------------//
- size_type root_directory_start( const string_type & path, size_type size )
+ size_type root_directory_start(const string_type & path, size_type size)
// return npos if no root_directory found
{
# ifdef BOOST_WINDOWS_PATH
// case "c:/"
- if ( size > 2
+ if (size > 2
&& path[1] == colon
- && is_separator( path[2] ) ) return 2;
+ && is_separator(path[2])) return 2;
# endif
// case "//"
- if ( size == 2
- && is_separator( path[0] )
- && is_separator( path[1] ) ) return string_type::npos;
+ if (size == 2
+ && is_separator(path[0])
+ && is_separator(path[1])) return string_type::npos;
// case "//net {/}"
- if ( size > 3
- && is_separator( path[0] )
- && is_separator( path[1] )
- && !is_separator( path[2] ) )
+ if (size > 3
+ && is_separator(path[0])
+ && is_separator(path[1])
+ && !is_separator(path[2]))
{
- string_type::size_type pos( path.find_first_of( separators, 2 ) );
+ string_type::size_type pos(path.find_first_of(separators, 2));
return pos < size ? pos : string_type::npos;
}
// case "/"
- if ( size > 0 && is_separator( path[0] ) ) return 0;
+ if (size > 0 && is_separator(path[0])) return 0;
return string_type::npos;
}
@@ -512,32 +512,32 @@
size_type & element_pos,
size_type & element_size,
size_type size
- )
+)
{
- if ( size == string_type::npos ) size = src.size();
+ if (size == string_type::npos) size = src.size();
element_pos = 0;
element_size = 0;
- if ( src.empty() ) return;
+ if (src.empty()) return;
string_type::size_type cur(0);
// deal with // [network]
- if ( size >= 2 && is_separator( src[0] )
- && is_separator( src[1] )
+ if (size >= 2 && is_separator(src[0])
+ && is_separator(src[1])
&& (size == 2
- || !is_separator( src[2] )) )
+ || !is_separator(src[2])))
{
cur += 2;
element_size += 2;
}
// leading (not non-network) separator
- else if ( is_separator( src[0] ) )
+ else if (is_separator(src[0]))
{
++element_size;
// bypass extra leading separators
- while ( cur+1 < size
- && is_separator( src[cur+1] ) )
+ while (cur+1 < size
+ && is_separator(src[cur+1]))
{
++cur;
++element_pos;
@@ -549,20 +549,20 @@
// or (on Windows only) a device name
// find the end
- while ( cur < size
+ while (cur < size
# ifdef BOOST_WINDOWS_PATH
&& src[cur] != colon
# endif
- && !is_separator( src[cur] ) )
+ && !is_separator(src[cur]))
{
++cur;
++element_size;
}
# ifdef BOOST_WINDOWS_PATH
- if ( cur == size ) return;
+ if (cur == size) return;
// include device delimiter
- if ( src[cur] == colon )
+ if (src[cur] == colon)
{ ++element_size; }
# endif
@@ -587,9 +587,9 @@
iterator itr;
itr.m_path_ptr = this;
size_type element_size;
- first_element( m_path, itr.m_pos, element_size );
- itr.m_element = m_path.substr( itr.m_pos, element_size );
- if ( itr.m_element.m_path == preferred_separator_string )
+ first_element(m_path, itr.m_pos, element_size);
+ itr.m_element = m_path.substr(itr.m_pos, element_size);
+ if (itr.m_element.m_path == preferred_separator_string)
itr.m_element.m_path = separator_string; // needed for Windows, harmless on POSIX
return itr;
}
@@ -602,31 +602,31 @@
return itr;
}
- void path::m_path_iterator_increment( path::iterator & it )
+ void path::m_path_iterator_increment(path::iterator & it)
{
- BOOST_ASSERT( it.m_pos < it.m_path_ptr->m_path.size() && "path::basic_iterator increment past end()" );
+ BOOST_ASSERT(it.m_pos < it.m_path_ptr->m_path.size() && "path::basic_iterator increment past end()");
// increment to position past current element
it.m_pos += it.m_element.m_path.size();
// if end reached, create end basic_iterator
- if ( it.m_pos == it.m_path_ptr->m_path.size() )
+ if (it.m_pos == it.m_path_ptr->m_path.size())
{
it.m_element.clear();
return;
}
// both POSIX and Windows treat paths that begin with exactly two separators specially
- bool was_net( it.m_element.m_path.size() > 2
- && is_separator( it.m_element.m_path[0] )
- && is_separator( it.m_element.m_path[1] )
- && !is_separator( it.m_element.m_path[2] ) );
+ bool was_net(it.m_element.m_path.size() > 2
+ && is_separator(it.m_element.m_path[0])
+ && is_separator(it.m_element.m_path[1])
+ && !is_separator(it.m_element.m_path[2]));
// process separator (Windows drive spec is only case not a separator)
- if ( is_separator( it.m_path_ptr->m_path[it.m_pos] ) )
+ if (is_separator(it.m_path_ptr->m_path[it.m_pos]))
{
// detect root directory
- if ( was_net
+ if (was_net
# ifdef BOOST_WINDOWS_PATH
// case "c:/"
|| it.m_element.m_path[it.m_element.m_path.size()-1] == colon
@@ -638,13 +638,13 @@
}
// bypass separators
- while ( it.m_pos != it.m_path_ptr->m_path.size()
- && is_separator( it.m_path_ptr->m_path[it.m_pos] ) )
+ while (it.m_pos != it.m_path_ptr->m_path.size()
+ && is_separator(it.m_path_ptr->m_path[it.m_pos]))
{ ++it.m_pos; }
// detect trailing separator, and treat it as ".", per POSIX spec
- if ( it.m_pos == it.m_path_ptr->m_path.size()
- && is_non_root_separator( it.m_path_ptr->m_path, it.m_pos-1 ) )
+ if (it.m_pos == it.m_path_ptr->m_path.size()
+ && is_non_root_separator(it.m_path_ptr->m_path, it.m_pos-1))
{
--it.m_pos;
it.m_element = dot_path;
@@ -653,22 +653,22 @@
}
// get next element
- size_type end_pos( it.m_path_ptr->m_path.find_first_of( separators, it.m_pos ) );
- if ( end_pos == string_type::npos ) end_pos = it.m_path_ptr->m_path.size();
- it.m_element = it.m_path_ptr->m_path.substr( it.m_pos, end_pos - it.m_pos );
+ size_type end_pos(it.m_path_ptr->m_path.find_first_of(separators, it.m_pos));
+ if (end_pos == string_type::npos) end_pos = it.m_path_ptr->m_path.size();
+ it.m_element = it.m_path_ptr->m_path.substr(it.m_pos, end_pos - it.m_pos);
}
- void path::m_path_iterator_decrement( path::iterator & it )
+ void path::m_path_iterator_decrement(path::iterator & it)
{
- BOOST_ASSERT( it.m_pos && "path::iterator decrement past begin()" );
+ BOOST_ASSERT(it.m_pos && "path::iterator decrement past begin()");
- size_type end_pos( it.m_pos );
+ size_type end_pos(it.m_pos);
// if at end and there was a trailing non-root '/', return "."
- if ( it.m_pos == it.m_path_ptr->m_path.size()
+ if (it.m_pos == it.m_path_ptr->m_path.size()
&& it.m_path_ptr->m_path.size() > 1
- && is_separator( it.m_path_ptr->m_path[it.m_pos-1] )
- && is_non_root_separator( it.m_path_ptr->m_path, it.m_pos-1 )
+ && is_separator(it.m_path_ptr->m_path[it.m_pos-1])
+ && is_non_root_separator(it.m_path_ptr->m_path, it.m_pos-1)
)
{
--it.m_pos;
@@ -676,30 +676,30 @@
return;
}
- size_type root_dir_pos( root_directory_start( it.m_path_ptr->m_path, end_pos ) );
+ size_type root_dir_pos(root_directory_start(it.m_path_ptr->m_path, end_pos));
// skip separators unless root directory
- for (
+ for (
;
end_pos > 0
&& (end_pos-1) != root_dir_pos
- && is_separator( it.m_path_ptr->m_path[end_pos-1] )
+ && is_separator(it.m_path_ptr->m_path[end_pos-1])
;
- --end_pos ) {}
+ --end_pos) {}
- it.m_pos = filename_pos( it.m_path_ptr->m_path, end_pos );
- it.m_element = it.m_path_ptr->m_path.substr( it.m_pos, end_pos - it.m_pos );
- if ( it.m_element.m_path == preferred_separator_string )
+ it.m_pos = filename_pos(it.m_path_ptr->m_path, end_pos);
+ it.m_element = it.m_path_ptr->m_path.substr(it.m_pos, end_pos - it.m_pos);
+ if (it.m_element.m_path == preferred_separator_string)
it.m_element.m_path = separator_string; // needed for Windows, harmless on POSIX
}
- bool path::m_path_lex_compare( iterator first1, iterator last1,
- iterator first2, iterator last2 )
+ bool path::m_path_lex_compare(iterator first1, iterator last1,
+ iterator first2, iterator last2)
{
- for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2)
+ for (; first1 != last1 && first2 != last2 ; ++first1, ++first2)
{
- if ( first1->m_path < first2->m_path ) return true;
- if ( first2->m_path < first1->m_path ) return false;
+ if (first1->m_path < first2->m_path) return true;
+ if (first2->m_path < first1->m_path) return false;
}
return first1 == last1 && first2 != last2;
}
@@ -729,7 +729,7 @@
{
# ifdef BOOST_WINDOWS_API
std::locale global_loc = std::locale();
- std::locale loc( global_loc, new windows_file_codecvt );
+ std::locale loc(global_loc, new windows_file_codecvt);
return loc;
# else
// ISO C calls this "the locale-specific native environment":
@@ -744,7 +744,7 @@
std::locale & path_locale()
{
// ISO C calls this "the locale-specific native environment":
- static std::locale loc( default_locale() );
+ static std::locale loc(default_locale());
return loc;
}
@@ -765,16 +765,16 @@
static const std::codecvt<wchar_t, char, std::mbstate_t> *
facet(
&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
- ( path_locale() ) );
+ (path_locale()));
return facet;
}
- std::locale path::imbue( const std::locale & loc )
+ std::locale path::imbue(const std::locale & loc)
{
- std::locale temp( path_locale() );
+ 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() );
+ <std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale());
return temp;
}
Modified: sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -45,15 +45,15 @@
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
-// convert_aux const char * to wstring //
+// convert_aux const char* to wstring //
//--------------------------------------------------------------------------------------//
void convert_aux(
- const char * from,
- const char * from_end,
- wchar_t * to, wchar_t * to_end,
+ const char* from,
+ const char* from_end,
+ wchar_t* to, wchar_t* to_end,
std::wstring & target,
- const pt::codecvt_type & cvt )
+ const pt::codecvt_type & cvt)
{
//std::cout << std::hex
// << " from=" << std::size_t(from)
@@ -63,31 +63,31 @@
// << std::endl;
std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const char * from_next;
- wchar_t * to_next;
+ 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 )
+ 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;
- boost::throw_exception( bs::system_error( res, fs::codecvt_error_category(),
- "boost::filesystem::path codecvt to wstring" ) );
+ boost::throw_exception(bs::system_error(res, fs::codecvt_error_category(),
+ "boost::filesystem::path codecvt to wstring"));
}
- target.append( to, to_next );
+ target.append(to, to_next);
}
//--------------------------------------------------------------------------------------//
-// convert_aux const wchar_t * to string //
+// convert_aux const wchar_t* to string //
//--------------------------------------------------------------------------------------//
void convert_aux(
- const wchar_t * from,
- const wchar_t * from_end,
- char * to, char * to_end,
+ const wchar_t* from,
+ const wchar_t* from_end,
+ char* to, char* to_end,
std::string & target,
- const pt::codecvt_type & cvt )
+ const pt::codecvt_type & cvt)
{
//std::cout << std::hex
// << " from=" << std::size_t(from)
@@ -97,19 +97,19 @@
// << std::endl;
std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const wchar_t * from_next;
- char * to_next;
+ 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 )
+ 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;
- boost::throw_exception( bs::system_error( res, fs::codecvt_error_category(),
- "boost::filesystem::path codecvt to string" ) );
+ boost::throw_exception(bs::system_error(res, fs::codecvt_error_category(),
+ "boost::filesystem::path codecvt to string"));
}
- target.append( to, to_next );
+ target.append(to, to_next);
}
} // unnamed namespace
@@ -121,57 +121,57 @@
namespace boost { namespace filesystem { namespace path_traits {
//--------------------------------------------------------------------------------------//
-// convert const char * to wstring //
+// convert const char* to wstring //
//--------------------------------------------------------------------------------------//
BOOST_FILESYSTEM_DECL
- void convert( const char * from,
- const char * from_end, // 0 for null terminated MBCS
+ void convert(const char* from,
+ const char* from_end, // 0 for null terminated MBCS
std::wstring & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt)
{
- BOOST_ASSERT( from );
+ BOOST_ASSERT(from);
- if ( !from_end ) // null terminated
+ if (!from_end) // null terminated
{
- from_end = from + std::strlen( from );
+ from_end = from + std::strlen(from);
}
- if ( from == from_end ) return;
+ 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 )
+ 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 );
+ 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_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
}
}
//--------------------------------------------------------------------------------------//
-// convert const wchar_t * to string //
+// 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
+ void convert(const wchar_t* from,
+ const wchar_t* from_end, // 0 for null terminated MBCS
std::string & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt)
{
- BOOST_ASSERT( from );
+ BOOST_ASSERT(from);
- if ( !from_end ) // null terminated
+ if (!from_end) // null terminated
{
- from_end = from + std::wcslen( from );
+ from_end = from + std::wcslen(from);
}
- if ( from == from_end ) return;
+ 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
@@ -181,15 +181,15 @@
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 )
+ 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 );
+ 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 );
+ convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
}
}
}}} // namespace boost::filesystem::path_traits
Modified: sandbox/filesystem-v3/libs/filesystem/src/portability.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/portability.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/portability.cpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -34,10 +34,10 @@
"<>:\"/\\|";
// note that the terminating '\0' is part of the string - thus the size below
// is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I
- const std::string windows_invalid_chars( invalid_chars, sizeof(invalid_chars) );
+ const std::string windows_invalid_chars(invalid_chars, sizeof(invalid_chars));
const std::string valid_posix(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-" );
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
} // unnamed namespace
@@ -49,12 +49,12 @@
// name_check functions ----------------------------------------------//
# ifdef BOOST_WINDOWS
- BOOST_FILESYSTEM_DECL bool native( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool native(const std::string & name)
{
- return windows_name( name );
+ return windows_name(name);
}
# else
- BOOST_FILESYSTEM_DECL bool native( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool native(const std::string & name)
{
return name.size() != 0
&& name[0] != ' '
@@ -62,52 +62,52 @@
}
# endif
- BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string & name)
{
return name.size() != 0
- && name.find_first_not_of( valid_posix ) == std::string::npos;
+ && name.find_first_not_of(valid_posix) == std::string::npos;
}
- BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool windows_name(const std::string & name)
{
return name.size() != 0
&& name[0] != ' '
- && name.find_first_of( windows_invalid_chars ) == std::string::npos
+ && name.find_first_of(windows_invalid_chars) == std::string::npos
&& *(name.end()-1) != ' '
&& (*(name.end()-1) != '.'
|| name.length() == 1 || name == "..");
}
- BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool portable_name(const std::string & name)
{
return
name.size() != 0
- && ( name == "."
+ && (name == "."
|| name == ".."
- || (windows_name( name )
- && portable_posix_name( name )
+ || (windows_name(name)
+ && portable_posix_name(name)
&& name[0] != '.' && name[0] != '-'));
}
- BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string & name)
{
return
name == "."
|| name == ".."
- || (portable_name( name )
+ || (portable_name(name)
&& name.find('.') == std::string::npos);
}
- BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name )
+ BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string & name)
{
std::string::size_type pos;
return
- portable_name( name )
+ portable_name(name)
&& name != "."
&& name != ".."
- && ( (pos = name.find( '.' )) == std::string::npos
- || (name.find( '.', pos+1 ) == std::string::npos
- && (pos + 5) > name.length() ))
+ && ((pos = name.find('.')) == std::string::npos
+ || (name.find('.', pos+1) == std::string::npos
+ && (pos + 5) > name.length()))
;
}
Modified: sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.cpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -21,15 +21,15 @@
#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
+ std::mbstate_t &,
+ 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 )
+ if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
+ from_end - from, to, to_end - to)) == 0)
{
return error; // conversion failed
}
@@ -41,15 +41,15 @@
}
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
+ std::mbstate_t &,
+ 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 )
+ if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from,
+ from_end - from, to, to_end - to, 0, 0)) == 0)
{
return error; // conversion failed
}
Modified: sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/windows_file_codecvt.hpp 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -35,19 +35,19 @@
// 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_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 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_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; }
};
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -26,134 +26,134 @@
namespace
{
template< typename F >
- bool throws_fs_error( F func )
+ bool throws_fs_error(F func)
{
try { func(); }
- catch ( const fs::filesystem_error & )
+ catch (const fs::filesystem_error &)
{
return true;
}
return false;
}
- void create_recursive_iterator( const fs::path & ph )
+ void create_recursive_iterator(const fs::path & ph)
{
- fs::recursive_directory_iterator it( ph );
+ fs::recursive_directory_iterator it(ph);
}
}
// ------------------------------------------------------------------------------------//
-int main( int, char*[] )
+int main(int, char*[])
{
// create_directories() tests --------------------------------------------------------//
- BOOST_TEST( !fs::create_directories( "" ) ); // should be harmless
- BOOST_TEST( !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_TEST( !fs::exists( "xx" ) ); // reality check
+ fs::remove_all("xx"); // make sure slate is blank
+ BOOST_TEST(!fs::exists("xx")); // reality check
- 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" ) );
+ 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" );
+ path is_a_file("xx/uu");
{
- std::ofstream f( is_a_file.string().c_str() );
- BOOST_TEST( !!f );
+ std::ofstream f(is_a_file.string().c_str());
+ BOOST_TEST(!!f);
}
- BOOST_TEST( throws_fs_error(
- boost::bind( fs::create_directories, is_a_file ) ) );
- BOOST_TEST( throws_fs_error(
- boost::bind( fs::create_directories, is_a_file / "aa" ) ) );
+ BOOST_TEST(throws_fs_error(
+ boost::bind(fs::create_directories, is_a_file)));
+ 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_TEST( ec );
+ fs::recursive_directory_iterator it("/no-such-path", ec);
+ BOOST_TEST(ec);
- BOOST_TEST( throws_fs_error(
- boost::bind( create_recursive_iterator, "/no-such-path" ) ) );
+ BOOST_TEST(throws_fs_error(
+ boost::bind(create_recursive_iterator, "/no-such-path")));
- fs::remove( "xx/uu" );
+ fs::remove("xx/uu");
#ifdef BOOST_WINDOWS_API
// These tests depends on ordering of directory entries, and that's guaranteed
// on Windows but not necessarily on other operating systems
{
- std::ofstream f( "xx/yya" );
- BOOST_TEST( !!f );
+ std::ofstream f("xx/yya");
+ BOOST_TEST(!!f);
}
- for ( it = fs::recursive_directory_iterator( "xx" );
- it != fs::recursive_directory_iterator(); ++it )
+ for (it = fs::recursive_directory_iterator("xx");
+ it != fs::recursive_directory_iterator(); ++it)
{ std::cout << it->path() << '\n'; }
- it = fs::recursive_directory_iterator( "xx" );
- BOOST_TEST( it->path() == "xx/yy" );
- BOOST_TEST( it.level() == 0 );
+ it = fs::recursive_directory_iterator("xx");
+ BOOST_TEST(it->path() == "xx/yy");
+ BOOST_TEST(it.level() == 0);
++it;
- BOOST_TEST( it->path() == "xx/yy/zz" );
- BOOST_TEST( it.level() == 1 );
+ BOOST_TEST(it->path() == "xx/yy/zz");
+ BOOST_TEST(it.level() == 1);
it.pop();
- BOOST_TEST( it->path() == "xx/yya" );
- BOOST_TEST( it.level() == 0 );
+ BOOST_TEST(it->path() == "xx/yya");
+ BOOST_TEST(it.level() == 0);
it++;
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ BOOST_TEST(it == fs::recursive_directory_iterator());
- it = fs::recursive_directory_iterator( "xx" );
- BOOST_TEST( it->path() == "xx/yy" );
+ it = fs::recursive_directory_iterator("xx");
+ BOOST_TEST(it->path() == "xx/yy");
it.no_push();
++it;
- BOOST_TEST( it->path() == "xx/yya" );
+ BOOST_TEST(it->path() == "xx/yya");
++it;
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ BOOST_TEST(it == fs::recursive_directory_iterator());
- fs::remove( "xx/yya" );
+ fs::remove("xx/yya");
#endif
- it = fs::recursive_directory_iterator( "xx/yy/zz" );
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ it = fs::recursive_directory_iterator("xx/yy/zz");
+ BOOST_TEST(it == fs::recursive_directory_iterator());
- it = fs::recursive_directory_iterator( "xx" );
- BOOST_TEST( it->path() == "xx/yy" );
- BOOST_TEST( it.level() == 0 );
+ it = fs::recursive_directory_iterator("xx");
+ BOOST_TEST(it->path() == "xx/yy");
+ BOOST_TEST(it.level() == 0);
++it;
- BOOST_TEST( it->path() == "xx/yy/zz" );
- BOOST_TEST( it.level() == 1 );
+ BOOST_TEST(it->path() == "xx/yy/zz");
+ BOOST_TEST(it.level() == 1);
it++;
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ BOOST_TEST(it == fs::recursive_directory_iterator());
- it = fs::recursive_directory_iterator( "xx" );
- BOOST_TEST( it->path() == "xx/yy" );
+ it = fs::recursive_directory_iterator("xx");
+ BOOST_TEST(it->path() == "xx/yy");
it.no_push();
++it;
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ BOOST_TEST(it == fs::recursive_directory_iterator());
- it = fs::recursive_directory_iterator( "xx" );
- BOOST_TEST( it->path() == "xx/yy" );
+ it = fs::recursive_directory_iterator("xx");
+ BOOST_TEST(it->path() == "xx/yy");
++it;
it.pop();
- BOOST_TEST( it == fs::recursive_directory_iterator() );
+ BOOST_TEST(it == fs::recursive_directory_iterator());
ec.clear();
- BOOST_TEST( !ec );
+ BOOST_TEST(!ec);
// check that two argument failed constructor creates the end iterator
- BOOST_TEST( fs::recursive_directory_iterator("nosuchdir", ec)
- == fs::recursive_directory_iterator() );
- BOOST_TEST( ec );
+ BOOST_TEST(fs::recursive_directory_iterator("nosuchdir", ec)
+ == fs::recursive_directory_iterator());
+ BOOST_TEST(ec);
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -19,16 +19,16 @@
namespace fs = boost::filesystem;
using boost::filesystem::path;
-#define PATH_CHECK( a, b ) check( a, b, __LINE__ )
+#define PATH_CHECK(a, b) check(a, b, __LINE__)
namespace
{
- std::string platform( BOOST_PLATFORM );
+ std::string platform(BOOST_PLATFORM);
- void check( const fs::path & source,
- const std::string & expected, int line )
+ void check(const fs::path & source,
+ const std::string & expected, int line)
{
- if ( source.string()== expected ) return;
+ if (source.string()== expected) return;
++::boost::detail::test_errors();
@@ -39,107 +39,107 @@
//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/." );
+ // 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" )
+ // if (platform == "Windows")
// {
- // PATH_CHECK( path( "c:.." ).normalize(), "c:.." );
- // PATH_CHECK( path( "c:foo/.." ).normalize(), "c:" );
+ // 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:/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" );
+ // 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" );
+ // 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");
// }
//}
@@ -160,19 +160,19 @@
void rename_test()
{
- fs::path p( "foo/bar/blah" );
+ fs::path p("foo/bar/blah");
- BOOST_TEST_EQ( path("foo/bar/blah").remove_leaf(), "foo/bar" );
- BOOST_TEST_EQ( p.leaf(), "blah" );
- BOOST_TEST_EQ( p.branch_path(), "foo/bar" );
- BOOST_TEST( p.has_leaf() );
- BOOST_TEST( p.has_branch_path() );
+ BOOST_TEST_EQ(path("foo/bar/blah").remove_leaf(), "foo/bar");
+ BOOST_TEST_EQ(p.leaf(), "blah");
+ BOOST_TEST_EQ(p.branch_path(), "foo/bar");
+ BOOST_TEST(p.has_leaf());
+ BOOST_TEST(p.has_branch_path());
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
- BOOST_TEST_EQ( path("foo\\bar\\blah").remove_leaf(), "foo\\bar" );
+ BOOST_TEST_EQ(path("foo\\bar\\blah").remove_leaf(), "foo\\bar");
p = "foo\\bar\\blah";
- BOOST_TEST_EQ( p.branch_path(), "foo\\bar" );
+ BOOST_TEST_EQ(p.branch_path(), "foo\\bar");
}
}
@@ -181,28 +181,28 @@
//--------------------------------------------------------------------------------------//
-int 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
// only the current platform is runtime tested.
- platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" )
+ platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
? "Windows"
: "POSIX";
std::cout << "Platform is " << platform << '\n';
- //path::default_name_check( fs::no_check );
+ //path::default_name_check(fs::no_check);
- fs::directory_entry de( "foo/bar" );
+ fs::directory_entry de("foo/bar");
- de.replace_leaf( "", fs::file_status(), fs::file_status() );
+ de.replace_leaf("", fs::file_status(), fs::file_status());
//de.leaf();
//de.string();
- fs::path ng( " no-way, Jose" );
- BOOST_TEST( !fs::is_regular( ng ) ); // verify deprecated name still works
- BOOST_TEST( !fs::symbolic_link_exists( "nosuchfileordirectory" ) );
+ fs::path ng(" no-way, Jose");
+ BOOST_TEST(!fs::is_regular(ng)); // verify deprecated name still works
+ BOOST_TEST(!fs::symbolic_link_exists("nosuchfileordirectory"));
rename_test();
@@ -210,31 +210,31 @@
// extension() tests ---------------------------------------------------------//
- 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/") == "." );
+ 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_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("") == "" );
+ 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_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" );
+ 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_TEST( fs::change_extension("", ".png").string() == ".png" );
+ BOOST_TEST(fs::change_extension("", ".png").string() == ".png");
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -29,127 +29,132 @@
#include <boost/detail/lightweight_test.hpp>
+#if defined(_MSC_VER)
+# pragma warning(push) // Save warning settings.
+# pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
+#endif
+
namespace
{
bool cleanup = true;
- void test( const fs::path & p )
+ void test(const fs::path & p)
{
{
std::cout << " in test 1\n";
fs::filebuf fb;
- fb.open( p, std::ios_base::in );
- BOOST_TEST( fb.is_open() == fs::exists( p ) );
+ fb.open(p, std::ios_base::in);
+ 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_TEST( fb1.is_open() );
+ fb1.open(p, std::ios_base::out);
+ BOOST_TEST(fb1.is_open());
}
{
std::cout << " in test 3\n";
fs::filebuf fb2;
- fb2.open( p, std::ios_base::in );
- BOOST_TEST( fb2.is_open() );
+ fb2.open(p, std::ios_base::in);
+ BOOST_TEST(fb2.is_open());
}
{
std::cout << " in test 4\n";
- fs::ifstream tfs( p );
- BOOST_TEST( tfs.is_open() );
+ fs::ifstream tfs(p);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 4.1\n";
- fs::ifstream tfs( p / p.filename() ); // should fail
- BOOST_TEST( !tfs.is_open() );
+ fs::ifstream tfs(p / p.filename()); // should fail
+ BOOST_TEST(!tfs.is_open());
}
{
std::cout << " in test 5\n";
- fs::ifstream tfs( p, std::ios_base::in );
- BOOST_TEST( tfs.is_open() );
+ fs::ifstream tfs(p, std::ios_base::in);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 6\n";
fs::ifstream tfs;
- tfs.open( p );
- BOOST_TEST( tfs.is_open() );
+ tfs.open(p);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 7\n";
fs::ifstream tfs;
- tfs.open( p, std::ios_base::in );
- BOOST_TEST( tfs.is_open() );
+ tfs.open(p, std::ios_base::in);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 8\n";
- fs::ofstream tfs( p );
- BOOST_TEST( tfs.is_open() );
+ fs::ofstream tfs(p);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 9\n";
- fs::ofstream tfs( p, std::ios_base::out );
- BOOST_TEST( tfs.is_open() );
+ fs::ofstream tfs(p, std::ios_base::out);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 10\n";
fs::ofstream tfs;
- tfs.open( p );
- BOOST_TEST( tfs.is_open() );
+ tfs.open(p);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 11\n";
fs::ofstream tfs;
- tfs.open( p, std::ios_base::out );
- BOOST_TEST( tfs.is_open() );
+ tfs.open(p, std::ios_base::out);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 12\n";
- fs::fstream tfs( p );
- BOOST_TEST( tfs.is_open() );
+ fs::fstream tfs(p);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 13\n";
- fs::fstream tfs( p, std::ios_base::in|std::ios_base::out );
- BOOST_TEST( tfs.is_open() );
+ fs::fstream tfs(p, std::ios_base::in|std::ios_base::out);
+ BOOST_TEST(tfs.is_open());
}
{
std::cout << " in test 14\n";
fs::fstream tfs;
- tfs.open( p );
- BOOST_TEST( tfs.is_open() );
+ tfs.open(p);
+ 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_TEST( tfs.is_open() );
+ tfs.open(p, std::ios_base::in|std::ios_base::out);
+ BOOST_TEST(tfs.is_open());
}
- if ( cleanup ) fs::remove( p );
+ if (cleanup) fs::remove(p);
} // test
} // unnamed namespace
-int main( int argc, char*[] )
+int main(int argc, char*[])
{
- if ( argc > 1 ) cleanup = false;
+ if (argc > 1) cleanup = false;
// test narrow characters
std::cout << "narrow character tests:\n";
- test( "fstream_test_foo" );
+ test("fstream_test_foo");
// 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::path::imbue( loc );
+ std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
+ fs::path::imbue(loc);
// 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" );
+ test(L"fstream_test_\u2780\u263A");
return ::boost::report_errors();
}
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/common.vsprops
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/common.vsprops (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/common.vsprops 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -11,6 +11,7 @@
AdditionalIncludeDirectories="../../../../.."
PreprocessorDefinitions="BOOST_SYSTEM_NO_DEPRECATED;BOOST_SYSTEM_NO_LIB;BOOST_FILESYSTEM_NO_LIB"
ExceptionHandling="2"
+ WarningLevel="4"
/>
<Tool
Name="VCLinkerTool"
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -45,7 +45,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -118,7 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -48,7 +48,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -122,7 +122,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -45,7 +45,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -117,7 +117,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -46,7 +46,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -120,7 +120,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -45,7 +45,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -118,7 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test_dynamic_link/path_test_dynamic_linkl.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test_dynamic_link/path_test_dynamic_linkl.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test_dynamic_link/path_test_dynamic_linkl.vcproj 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -48,7 +48,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -124,7 +124,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -45,7 +45,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -118,7 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj 2009-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -48,7 +48,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="4"
/>
<Tool
@@ -122,7 +122,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -32,20 +32,6 @@
#include <ctime>
#include <cstdlib> // for system()
-// VC++ 7.0 and earlier has a serious namespace bug that causes a clash
-// between boost::filesystem::is_empty and the unrelated type trait
-// boost::is_empty.
-#if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300
-# define BOOST_FS_IS_EMPTY fs::is_empty
-#else
-# define BOOST_FS_IS_EMPTY fs::_is_empty
-#endif
-
-# ifdef BOOST_NO_STDC_NAMESPACE
- namespace std { using ::asctime; using ::gmtime; using ::localtime;
- using ::difftime; using ::time; using ::tm; using ::mktime; using ::system; }
-# endif
-
#ifdef BOOST_WINDOWS_API
# include <windows.h>
#endif
@@ -55,59 +41,60 @@
namespace
{
typedef int errno_t;
- std::string platform( BOOST_PLATFORM );
+ std::string platform(BOOST_PLATFORM);
bool report_throws;
bool cleanup = true;
fs::directory_iterator end_itr;
fs::path dir;
fs::path d1;
fs::path d2;
- bool create_symlink_ok( true );
- fs::path ng( " no-way, Jose" );
+ bool create_symlink_ok(true);
+ fs::path ng(" no-way, Jose");
unsigned short language_id; // 0 except for Windows
- const char * temp_dir_name = "temp_fs_test_dir";
+ const char* temp_dir_name = "temp_fs_test_dir";
- void create_file( const fs::path & ph, const std::string & contents )
+ void create_file(const fs::path & ph, const std::string & contents)
{
- std::ofstream f( ph.string().c_str() );
- if ( !f )
- throw fs::filesystem_error( "operations_test create_file",
- ph, error_code(errno, system_category) );
- if ( !contents.empty() ) f << contents;
+ std::ofstream f(ph.string().c_str());
+ if (!f)
+ throw fs::filesystem_error("operations_test create_file",
+ ph, error_code(errno, system_category));
+ if (!contents.empty()) f << contents;
}
- void verify_file( const fs::path & ph, const std::string & expected )
+ void verify_file(const fs::path & ph, const std::string & expected)
{
- std::ifstream f( ph.string().c_str() );
- if ( !f )
- throw fs::filesystem_error( "operations_test verify_file",
- ph, error_code(errno, system_category) );
+ std::ifstream f(ph.string().c_str());
+ if (!f)
+ throw fs::filesystem_error("operations_test verify_file",
+ ph, error_code(errno, system_category));
std::string contents;
f >> contents;
- if ( contents != expected )
- throw fs::filesystem_error( "operations_test verify_file contents \""
- + contents + "\" != \"" + expected + "\"", ph, error_code() );
+ if (contents != expected)
+ throw fs::filesystem_error("operations_test verify_file contents \""
+ + contents + "\" != \"" + expected + "\"", ph, error_code());
}
template< typename F >
- bool throws_fs_error( F func, errno_t en, int line )
+ bool throws_fs_error(F func, errno_t en, int line)
{
try { func(); }
- catch ( const fs::filesystem_error & ex )
+ catch (const fs::filesystem_error & ex)
{
- if ( report_throws )
+ if (report_throws)
{
// use the what() convenience function to display exceptions
std::cout << "\n" << ex.what() << "\n";
}
- if ( en == 0
- || en == ex.code().default_error_condition().value() ) return true;
+ if (en == 0
+ || en == ex.code().default_error_condition().value()) return true;
std::cout
<< "\nWarning: line " << line
- << " exception reports default_error_condition().value() " << ex.code().default_error_condition().value()
+ << " exception reports default_error_condition().value() "
+ << ex.code().default_error_condition().value()
<< ", should be " << en
<< "\n value() is " << ex.code().value()
<< std::endl;
@@ -122,60 +109,60 @@
{
fs::path p;
std::string s;
- const char * a = 0;
- fs::copy_file( p, p );
- fs::copy_file( s, p );
- fs::copy_file( a, p );
- fs::copy_file( p, s );
- fs::copy_file( p, a );
- fs::copy_file( s, s );
- fs::copy_file( a, s );
- fs::copy_file( s, a );
- fs::copy_file( a, a );
+ const char* a = 0;
+ fs::copy_file(p, p);
+ fs::copy_file(s, p);
+ fs::copy_file(a, p);
+ fs::copy_file(p, s);
+ fs::copy_file(p, a);
+ fs::copy_file(s, s);
+ fs::copy_file(a, s);
+ fs::copy_file(s, a);
+ fs::copy_file(a, a);
}
void bad_file_size()
{
- fs::file_size( " No way, Jose" );
+ fs::file_size(" No way, Jose");
}
void bad_directory_size()
{
- fs::file_size( fs::current_path() );
+ fs::file_size(fs::current_path());
}
fs::path bad_create_directory_path;
void bad_create_directory()
{
- fs::create_directory( bad_create_directory_path );
+ fs::create_directory(bad_create_directory_path);
}
void bad_equivalent()
{
- fs::equivalent( "no-such-path", "another-not-present-path" );
+ fs::equivalent("no-such-path", "another-not-present-path");
}
fs::path bad_remove_dir;
void bad_remove()
{
- fs::remove( bad_remove_dir );
+ fs::remove(bad_remove_dir);
}
class renamer
{
public:
- renamer( const fs::path & p1, const fs::path & p2 )
+ renamer(const fs::path & p1, const fs::path & p2)
: from(p1), to(p2) {}
void operator()()
{
- fs::rename( from, to );
+ fs::rename(from, to);
}
private:
fs::path from;
fs::path to;
};
- // exception_tests() -----------------------------------------------------//
+ // exception_tests() ---------------------------------------------------------------//
void exception_tests()
{
@@ -188,20 +175,20 @@
exception_thrown = false;
try
{
- fs::create_directory( "no-such-dir/foo/bar" );
+ fs::create_directory("no-such-dir/foo/bar");
}
- catch ( std::runtime_error x )
+ catch (std::runtime_error x)
{
exception_thrown = true;
- if ( report_throws ) std::cout << x.what() << std::endl;
- if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
+ if (report_throws) std::cout << x.what() << std::endl;
+ 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_TEST( std::strncmp( x.what(),
+ BOOST_TEST(std::strncmp(x.what(),
"boost::filesystem::create_directory",
- sizeof("boost::filesystem::create_directory")-1 ) == 0 );
+ sizeof("boost::filesystem::create_directory")-1) == 0);
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
// catch system_error
@@ -209,17 +196,17 @@
exception_thrown = false;
try
{
- fs::create_directory( "no-such-dir/foo/bar" );
+ fs::create_directory("no-such-dir/foo/bar");
}
- catch ( system_error x )
+ catch (system_error x)
{
exception_thrown = true;
- if ( report_throws ) std::cout << x.what() << std::endl;
- if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
- BOOST_TEST( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified" ) == 0 );
+ if (report_throws) std::cout << x.what() << std::endl;
+ if (platform == "Windows" && language_id == 0x0409) // English (United States)
+ BOOST_TEST(std::strcmp(x.what(),
+ "boost::filesystem::create_directory: The system cannot find the path specified") == 0);
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
// catch filesystem_error by value
@@ -227,24 +214,24 @@
exception_thrown = false;
try
{
- fs::create_directory( "no-such-dir/foo/bar" );
+ fs::create_directory("no-such-dir/foo/bar");
}
- catch ( fs::filesystem_error x )
+ catch (fs::filesystem_error x)
{
exception_thrown = true;
- if ( report_throws ) std::cout << x.what() << std::endl;
- if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
+ if (report_throws) std::cout << x.what() << std::endl;
+ if (platform == "Windows" && language_id == 0x0409) // English (United States)
{
- bool ok ( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"" ) == 0 );
- BOOST_TEST( ok );
- if ( !ok )
+ bool ok (std::strcmp(x.what(),
+ "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
+ BOOST_TEST(ok);
+ if (!ok)
{
std::cout << "what returns \"" << x.what() << "\"" << std::endl;
}
}
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
// catch filesystem_error by const reference
@@ -252,148 +239,148 @@
exception_thrown = false;
try
{
- fs::create_directory( "no-such-dir/foo/bar" );
+ fs::create_directory("no-such-dir/foo/bar");
}
- catch ( const fs::filesystem_error & x )
+ catch (const fs::filesystem_error & x)
{
exception_thrown = true;
- if ( report_throws ) std::cout << x.what() << std::endl;
- if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
+ if (report_throws) std::cout << x.what() << std::endl;
+ if (platform == "Windows" && language_id == 0x0409) // English (United States)
{
- bool ok ( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"" ) == 0 );
- BOOST_TEST( ok );
- if ( !ok )
+ bool ok (std::strcmp(x.what(),
+ "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir/foo/bar\"") == 0);
+ BOOST_TEST(ok);
+ if (!ok)
{
std::cout << "what returns \"" << x.what() << "\"" << std::endl;
}
}
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
std::cout << " exception_test cleanup" << std::endl;
}
- // directory_iterator_tests ----------------------------------------------//
+ // directory_iterator_tests --------------------------------------------------------//
void directory_iterator_tests()
{
std::cout << "directory_iterator_tests..." << std::endl;
bool dir_itr_exception(false);
- try { fs::directory_iterator it( "" ); }
- catch ( const fs::filesystem_error & ) { dir_itr_exception = true; }
- BOOST_TEST( dir_itr_exception );
+ try { fs::directory_iterator it(""); }
+ catch (const fs::filesystem_error &) { dir_itr_exception = true; }
+ 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_TEST( dir_itr_exception );
+ try { fs::directory_iterator it("nosuchdirectory"); }
+ catch (const fs::filesystem_error &) { dir_itr_exception = true; }
+ BOOST_TEST(dir_itr_exception);
dir_itr_exception = false;
try
{
error_code ec;
- fs::directory_iterator it( "nosuchdirectory", ec );
- BOOST_TEST( ec );
- BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory );
+ fs::directory_iterator it("nosuchdirectory", ec);
+ BOOST_TEST(ec);
+ BOOST_TEST(ec == boost::system::errc::no_such_file_or_directory);
}
- catch ( const fs::filesystem_error & ) { dir_itr_exception = true; }
- BOOST_TEST( !dir_itr_exception );
+ catch (const fs::filesystem_error &) { dir_itr_exception = true; }
+ BOOST_TEST(!dir_itr_exception);
{
// probe query function overloads
- fs::directory_iterator dir_itr( dir );
- // 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" );
+ fs::directory_iterator dir_itr(dir);
+ // 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_TEST( fs::exists( d2 ) );
- BOOST_TEST( fs::is_directory( d2 ) );
+ fs::create_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_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_TEST( dir_itr->path().filename() == "d1"
- || dir_itr->path().filename() == "d2" );
- BOOST_TEST( dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2" );
- if ( dir_itr->path().filename() == "d1" )
+ fs::directory_iterator dir_itr(dir);
+ 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_TEST(dir_itr->path().filename() == "d1"
+ || dir_itr->path().filename() == "d2");
+ BOOST_TEST(dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2");
+ if (dir_itr->path().filename() == "d1")
{
- BOOST_TEST( (++dir_itr)->path().filename() == "d2" );
- BOOST_TEST( dir_itr2->path().filename() == "d1" );
- BOOST_TEST( (++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_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_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_TEST( ++dir_itr == fs::directory_iterator() );
- BOOST_TEST( dir_itr2 != fs::directory_iterator() );
- BOOST_TEST( ++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_TEST( dir_itr->path().filename() == "d1"
- || dir_itr->path().filename() == "d2" );
- if ( dir_itr->path().filename() == "d1" )
+ fs::directory_iterator dir_itr(dir);
+ BOOST_TEST(dir_itr->path().filename() == "d1"
+ || dir_itr->path().filename() == "d2");
+ if (dir_itr->path().filename() == "d1")
{
- BOOST_TEST( (*dir_itr++).path().filename() == "d1" );
- BOOST_TEST( 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_TEST( (*dir_itr++).path().filename() == "d2" );
+ BOOST_TEST((*dir_itr++).path().filename() == "d2");
// input iterator requirements in the current WP would require this check:
- // BOOST_TEST( implicit_cast<std::string const&>(*dir_itr++).filename() == "d1" );
+ // BOOST_TEST(implicit_cast<std::string const&>(*dir_itr++).filename() == "d1");
- BOOST_TEST( 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 );
+ fs::directory_iterator it(dir);
const fs::path p1 = (*it++).path();
- BOOST_TEST( it != fs::directory_iterator() );
+ BOOST_TEST(it != fs::directory_iterator());
const fs::path p2 = (*it++).path();
- BOOST_TEST( p1 != p2 );
- BOOST_TEST( it == fs::directory_iterator() );
+ BOOST_TEST(p1 != p2);
+ BOOST_TEST(it == fs::directory_iterator());
}
// Windows has a tricky special case when just the root-name is given,
// causing the rest of the path to default to the current directory.
// Reported as S/F bug [ 1259176 ]
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
- fs::path root_name_path( fs::current_path().root_name() );
- fs::directory_iterator it( 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 );
+ fs::path root_name_path(fs::current_path().root_name());
+ fs::directory_iterator it(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_TEST( found );
+ if (it->path().filename() == temp_dir_name) found = true;
+ } while (++it != fs::directory_iterator());
+ BOOST_TEST(found);
}
// there was an inital bug in directory_iterator that caused premature
@@ -401,28 +388,28 @@
{
fs::directory_iterator di;
{
- di = fs::directory_iterator( dir );
+ di = fs::directory_iterator(dir);
}
- BOOST_TEST( ++di != fs::directory_iterator() );
+ BOOST_TEST(++di != fs::directory_iterator());
}
std::cout << " directory_iterator_tests complete" << std::endl;
}
- // create_hard_link_tests ------------------------------------------------//
+ // create_hard_link_tests ----------------------------------------------------------//
void create_hard_link_tests()
{
std::cout << "create_hard_link_tests..." << std::endl;
- fs::path from_ph( dir / "f3" );
- fs::path file_ph( dir / "f1" );
+ fs::path from_ph(dir / "f3");
+ fs::path file_ph(dir / "f1");
- BOOST_TEST( !fs::exists( from_ph ) );
- BOOST_TEST( 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 )
+ try { fs::create_hard_link(file_ph, from_ph); }
+ catch (const fs::filesystem_error & ex)
{
create_hard_link_ok = false;
std::cout
@@ -432,41 +419,41 @@
" create_hard_link() may not be supported on this file system\n";
}
- if ( create_hard_link_ok )
+ if (create_hard_link_ok)
{
std::cout
<< " *** For information only ***\n"
" create_hard_link() succeeded\n";
- 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 );
+ 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_TEST( 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_TEST( ec );
+ fs::create_hard_link(fs::path("doesnotexist"),
+ fs::path("shouldnotwork"), ec);
+ BOOST_TEST(ec);
}
- // create_symlink_tests --------------------------------------------------//
+ // create_symlink_tests ------------------------------------------------------------//
void create_symlink_tests()
{
std::cout << "create_symlink_tests..." << std::endl;
- fs::path from_ph( dir / "f4" );
- fs::path file_ph( dir / "f1" );
- 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 )
+ fs::path from_ph(dir / "f4");
+ fs::path file_ph(dir / "f1");
+ 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)
{
create_symlink_ok = false;
std::cout
@@ -476,53 +463,53 @@
" create_symlink() may not be supported on this operating system or file system\n";
}
- if ( create_symlink_ok )
+ if (create_symlink_ok)
{
std::cout
<< " *** For information only ***\n"
" create_symlink() succeeded\n";
- 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 ) );
+ 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" )
+ if (platform == "POSIX")
{
- //std::cout << fs::read_symlink( from_ph ).string() << ", " << file_ph.string() << "\n";
- BOOST_TEST( fs::read_symlink( from_ph ) == file_ph );
+ //std::cout << fs::read_symlink(from_ph).string() << ", " << file_ph.string() << "\n";
+ BOOST_TEST(fs::read_symlink(from_ph) == file_ph);
}
- fs::file_status stat = fs::symlink_status( from_ph );
- 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_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 ) );
+ fs::file_status stat = fs::symlink_status(from_ph);
+ 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_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_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 ) );
+ fs::path symlink2_ph(dir / "symlink2");
+ fs::copy_symlink(from_ph, symlink2_ph);
+ stat = fs::symlink_status(symlink2_ph);
+ 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_TEST( ec );
+ fs::create_symlink("doesnotexist", "", ec);
+ BOOST_TEST(ec);
}
- // rename_tests ----------------------------------------------------------//
+ // rename_tests --------------------------------------------------------------------//
void rename_tests()
{
@@ -530,121 +517,121 @@
// rename() test case numbers refer to operations.htm#rename table
- fs::path file_ph( dir / "f1" );
- BOOST_TEST( fs::exists( file_ph ) );
+ fs::path file_ph(dir / "f1");
+ BOOST_TEST(fs::exists(file_ph));
// [case 1] make sure can't rename() a non-existent file
- BOOST_TEST( !fs::exists( d1 / "f99" ) );
- BOOST_TEST( !fs::exists( d1 / "f98" ) );
- renamer n1a( d1 / "f99", d1 / "f98" );
- BOOST_TEST( CHECK_EXCEPTION( n1a, ENOENT ) );
- renamer n1b( fs::path(""), d1 / "f98" );
- BOOST_TEST( CHECK_EXCEPTION( n1b, ENOENT ) );
+ BOOST_TEST(!fs::exists(d1 / "f99"));
+ BOOST_TEST(!fs::exists(d1 / "f98"));
+ renamer n1a(d1 / "f99", d1 / "f98");
+ BOOST_TEST(CHECK_EXCEPTION(n1a, ENOENT));
+ renamer n1b(fs::path(""), d1 / "f98");
+ BOOST_TEST(CHECK_EXCEPTION(n1b, ENOENT));
// [case 2] rename() target.empty()
- renamer n2( file_ph, "" );
- BOOST_TEST( CHECK_EXCEPTION( n2, ENOENT ) );
+ renamer n2(file_ph, "");
+ BOOST_TEST(CHECK_EXCEPTION(n2, ENOENT));
// [case 3] make sure can't rename() to an existent file or directory
- BOOST_TEST( fs::exists( dir / "f1" ) );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- renamer n3a( dir / "f1", d1 / "f2" );
- BOOST_TEST( CHECK_EXCEPTION( n3a, EEXIST ) );
+ BOOST_TEST(fs::exists(dir / "f1"));
+ BOOST_TEST(fs::exists(d1 / "f2"));
+ renamer n3a(dir / "f1", d1 / "f2");
+ 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_TEST( CHECK_EXCEPTION( n3b, 0 ) );
+ renamer n3b(dir, d1);
+ BOOST_TEST(CHECK_EXCEPTION(n3b, 0));
// [case 4A] can't rename() file to a nonexistent parent directory
- BOOST_TEST( !fs::is_directory( dir / "f1" ) );
- BOOST_TEST( !fs::exists( dir / "d3/f3" ) );
- renamer n4a( dir / "f1", dir / "d3/f3" );
- BOOST_TEST( CHECK_EXCEPTION( n4a, ENOENT ) );
+ BOOST_TEST(!fs::is_directory(dir / "f1"));
+ BOOST_TEST(!fs::exists(dir / "d3/f3"));
+ renamer n4a(dir / "f1", dir / "d3/f3");
+ BOOST_TEST(CHECK_EXCEPTION(n4a, ENOENT));
// [case 4B] rename() file in same directory
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- BOOST_TEST( !fs::exists( d1 / "f50" ) );
- fs::rename( d1 / "f2", d1 / "f50" );
- BOOST_TEST( !fs::exists( d1 / "f2" ) );
- BOOST_TEST( fs::exists( d1 / "f50" ) );
- fs::rename( d1 / "f50", d1 / "f2" );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- BOOST_TEST( !fs::exists( d1 / "f50" ) );
+ BOOST_TEST(fs::exists(d1 / "f2"));
+ BOOST_TEST(!fs::exists(d1 / "f50"));
+ fs::rename(d1 / "f2", d1 / "f50");
+ BOOST_TEST(!fs::exists(d1 / "f2"));
+ BOOST_TEST(fs::exists(d1 / "f50"));
+ fs::rename(d1 / "f50", d1 / "f2");
+ 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_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_TEST( fs::exists( d1 / "f2" ) );
+ fs::rename(d1 / "f2", 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_TEST(fs::exists(d1 / "f2"));
// [case 5A] rename() directory to nonexistent parent directory
- 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_TEST( CHECK_EXCEPTION( n5a, ENOENT ) );
+ 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_TEST(CHECK_EXCEPTION(n5a, ENOENT));
// [case 5B] rename() on directory
- fs::path d3( dir / "d3" );
- BOOST_TEST( fs::exists( d1 ) );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- BOOST_TEST( !fs::exists( d3 ) );
- fs::rename( d1, d3 );
- 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_TEST( fs::exists( d1 ) );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- BOOST_TEST( !fs::exists( d3 ) );
+ fs::path d3(dir / "d3");
+ BOOST_TEST(fs::exists(d1));
+ BOOST_TEST(fs::exists(d1 / "f2"));
+ BOOST_TEST(!fs::exists(d3));
+ fs::rename(d1, d3);
+ 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_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_TEST( fs::exists( d1 ) );
- BOOST_TEST( !fs::exists( d2 / "d20" ) );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- fs::rename( d1, d2 / "d20" );
- BOOST_TEST( !fs::exists( d1 ) );
- BOOST_TEST( fs::exists( d2 / "d20" ) );
- BOOST_TEST( fs::exists( d2 / "d20" / "f2" ) );
- fs::rename( d2 / "d20", d1 );
- BOOST_TEST( fs::exists( d1 ) );
- BOOST_TEST( !fs::exists( d2 / "d20" ) );
- BOOST_TEST( 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_TEST(!fs::exists(d1));
+ BOOST_TEST(fs::exists(d2 / "d20"));
+ BOOST_TEST(fs::exists(d2 / "d20" / "f2"));
+ fs::rename(d2 / "d20", d1);
+ BOOST_TEST(fs::exists(d1));
+ BOOST_TEST(!fs::exists(d2 / "d20"));
+ BOOST_TEST(fs::exists(d1 / "f2"));
}
- // predicate_and_status_tests --------------------------------------------//
+ // predicate_and_status_tests ------------------------------------------------------//
void predicate_and_status_tests()
{
std::cout << "predicate_and_status_tests..." << std::endl;
- 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_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_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 ) );
+ 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_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_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 ------------------------------------------------//
+ // create_directory_tests ----------------------------------------------------------//
void create_directory_tests()
{
@@ -655,10 +642,10 @@
// many subsequent tests will fail
try
{
- fs::create_directory( dir );
+ fs::create_directory(dir);
}
- catch ( const fs::filesystem_error & x )
+ catch (const fs::filesystem_error & x)
{
std::cout << x.what() << "\n\n"
"***** Creating directory " << dir.string() << " failed. *****\n"
@@ -667,7 +654,7 @@
std::exit(1);
}
- catch ( ... )
+ catch (...)
{
std::cout << "\n\n"
"***** Creating directory " << dir.string() << " failed. *****\n"
@@ -676,23 +663,23 @@
std::exit(1);
}
- 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_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 ) );
+ BOOST_TEST(fs::exists(dir));
+ BOOST_TEST(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_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;
}
- // current_directory_tests -----------------------------------------------//
+ // current_directory_tests ---------------------------------------------------------//
void current_directory_tests()
{
@@ -700,24 +687,24 @@
// set the current directory, then check it for consistency
fs::path original_dir = fs::current_path();
- BOOST_TEST( dir != original_dir );
- fs::current_path( dir );
- BOOST_TEST( fs::current_path() == dir );
- BOOST_TEST( fs::current_path() != original_dir );
- fs::current_path( original_dir );
- BOOST_TEST( fs::current_path() == original_dir );
- BOOST_TEST( fs::current_path() != dir );
+ BOOST_TEST(dir != original_dir);
+ fs::current_path(dir);
+ BOOST_TEST(fs::current_path() == dir);
+ BOOST_TEST(fs::current_path() != original_dir);
+ fs::current_path(original_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_TEST( fs::current_path() == dir );
- BOOST_TEST( fs::current_path() != original_dir );
- fs::current_path( original_dir.string() );
- BOOST_TEST( fs::current_path() == original_dir );
- BOOST_TEST( fs::current_path() != dir );
+ fs::current_path(dir.string().c_str());
+ BOOST_TEST(fs::current_path() == dir);
+ BOOST_TEST(fs::current_path() != original_dir);
+ fs::current_path(original_dir.string());
+ BOOST_TEST(fs::current_path() == original_dir);
+ BOOST_TEST(fs::current_path() != dir);
}
- // create_directories_tests ----------------------------------------------//
+ // create_directories_tests --------------------------------------------------------//
void create_directories_tests()
{
@@ -725,13 +712,13 @@
fs::path p = dir / "level1" / "level2";
- BOOST_TEST( !fs::exists( p ) );
- BOOST_TEST( fs::create_directories( p ) );
- BOOST_TEST( fs::exists( p ) );
- BOOST_TEST( 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));
}
- // resize_file_tests ----------------------------------------------------//
+ // resize_file_tests ---------------------------------------------------------------//
void resize_file_tests()
{
@@ -739,24 +726,44 @@
const std::string f ("resize_file_test.txt");
- fs::remove( f );
- create_file( f, "1234567890" );
+ fs::remove(f);
+ create_file(f, "1234567890");
- BOOST_TEST( fs::exists(f) );
- BOOST_TEST_EQ( fs::file_size(f), 10 );
- fs::resize_file( f, 5 );
- BOOST_TEST( fs::exists(f) );
- BOOST_TEST_EQ( fs::file_size(f), 5 );
- fs::resize_file( f, 15 );
- BOOST_TEST( fs::exists(f) );
- BOOST_TEST_EQ( fs::file_size(f), 15 );
+ BOOST_TEST(fs::exists(f));
+ BOOST_TEST_EQ(fs::file_size(f), 10);
+ fs::resize_file(f, 5);
+ BOOST_TEST(fs::exists(f));
+ BOOST_TEST_EQ(fs::file_size(f), 5);
+ fs::resize_file(f, 15);
+ BOOST_TEST(fs::exists(f));
+ BOOST_TEST_EQ(fs::file_size(f), 15);
error_code ec;
- fs::resize_file( "no such file", 15, ec );
- BOOST_TEST( ec );
+ fs::resize_file("no such file", 15, ec);
+ BOOST_TEST(ec);
+ }
+
+ // status_of_nonexistent_tests -----------------------------------------------------//
+
+ void status_of_nonexistent_tests()
+ {
+ std::cout << "status_of_nonexistent_tests..." << std::endl;
+ fs::path p ("nosuch");
+ BOOST_TEST(!fs::is_regular_file(p));
+ BOOST_TEST(!fs::is_directory(p));
+ BOOST_TEST(!fs::is_symlink(p));
+ BOOST_TEST(!fs::is_other(p));
+
+ fs::file_status s = fs::status(p);
+ BOOST_TEST_EQ(s.type(), fs::file_not_found);
+ BOOST_TEST(fs::status_known(s));
+ BOOST_TEST(!fs::is_regular_file(s));
+ BOOST_TEST(!fs::is_directory(s));
+ BOOST_TEST(!fs::is_symlink(s));
+ BOOST_TEST(!fs::is_other(s));
}
- // _tests ----------------------------------------------------//
+ // _tests --------------------------------------------------------------------------//
void _tests()
{
@@ -767,21 +774,21 @@
//------------------------------------------------------------------------------------//
// //
- // main //
+ // main //
// //
//------------------------------------------------------------------------------------//
-int 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;
+ if (argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='t') report_throws = true;
+ if (argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='x') cleanup = false;
// The choice of platform is make at runtime rather than compile-time
// so that compile errors for all platforms will be detected even though
// only the current platform is runtime tested.
-# if defined( BOOST_POSIX_API )
+# if defined(BOOST_POSIX_API)
platform = "POSIX";
-# elif defined( BOOST_WINDOWS_API )
+# elif defined(BOOST_WINDOWS_API)
platform = "Windows";
# if !defined(__MINGW32__) && !defined(__CYGWIN__)
language_id = ::GetUserDefaultUILanguage();
@@ -789,7 +796,7 @@
language_id = 0x0409; // Assume US English
# endif
# else
- platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" )
+ platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
? "Windows"
: "POSIX";
# endif
@@ -800,109 +807,109 @@
std::cout << "\ninitial_path().string() is\n \""
<< fs::initial_path().string()
<< "\"\n\n";
- 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_TEST(fs::initial_path().is_complete());
+ BOOST_TEST(fs::current_path().is_complete());
+ BOOST_TEST(fs::initial_path().string()
+ == fs::current_path().string());
- BOOST_TEST( fs::complete( "" ).empty() );
- fs::path px1 = fs::complete( "/" );
+ BOOST_TEST(fs::complete("").empty());
+ fs::path px1 = fs::complete("/");
fs::path px2 = fs::initial_path().root_path();
- 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" );
+ 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();
dir = fs::initial_path() / temp_dir_name;
- if ( fs::exists( dir ) )
+ if (fs::exists(dir))
{
std::cout << "remove residue from prior failed tests..." << std::endl;
- fs::remove_all( dir );
+ fs::remove_all(dir);
}
- BOOST_TEST( !fs::exists( dir ) );
+ BOOST_TEST(!fs::exists(dir));
create_directory_tests();
// Windows only tests
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
std::cout << "Window specific tests..."
"\n (may take several seconds)" << std::endl;
- 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_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" );
-
- fs::path p1( fs::system_complete( "/foo" ) );
- BOOST_TEST_EQ( p1.string().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_TEST( fs::complete( fs::path( "c:/foo" ) ).string()
- == "c:/foo" );
-
- 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_TEST( fs::system_complete( fs::path( "c:/" ) ).string()
- == "c:/" );
- BOOST_TEST( fs::system_complete( fs::path( "c:/foo" ) ).string()
- == "c:/foo" );
- BOOST_TEST( fs::system_complete( fs::path( "//share" ) ).string()
- == "//share" );
+ 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_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");
+
+ fs::path p1(fs::system_complete("/foo"));
+ BOOST_TEST_EQ(p1.string().size(), 6U); // 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_TEST(fs::complete(fs::path("c:/foo")).string()
+ == "c:/foo");
+
+ 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_TEST(fs::system_complete(fs::path("c:/")).string()
+ == "c:/");
+ BOOST_TEST(fs::system_complete(fs::path("c:/foo")).string()
+ == "c:/foo");
+ BOOST_TEST(fs::system_complete(fs::path("//share")).string()
+ == "//share");
} // Windows
- else if ( platform == "POSIX" )
+ else if (platform == "POSIX")
{
std::cout << "POSIX specific tests..." << std::endl;
- 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_TEST( fs::system_complete( "/foo" ).string()
- == fs::initial_path().root_path().string()+"foo" );
+ 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_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_TEST( 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
+ try { fs::file_size(ng); } // will throw
- catch ( const fs::filesystem_error & ex )
+ catch (const fs::filesystem_error & ex)
{
- BOOST_TEST( 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_TEST( 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_TEST( spi.capacity > 1000000 );
- BOOST_TEST( spi.free > 1000 );
- BOOST_TEST( spi.capacity > spi.free );
- BOOST_TEST( spi.free >= spi.available );
+ fs::space_info spi(fs::space(dir));
+ 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
@@ -911,66 +918,67 @@
std::cout << "available = " << spi.available << '\n';
# endif
- if ( platform == "Windows" )
- BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, ENOENT ) );
+ if (platform == "Windows")
+ BOOST_TEST(CHECK_EXCEPTION(bad_directory_size, ENOENT));
else
- BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, 0 ) );
+ BOOST_TEST(CHECK_EXCEPTION(bad_directory_size, 0));
- BOOST_TEST( !fs::create_directory( dir ) );
+ BOOST_TEST(!fs::create_directory(dir));
- BOOST_TEST( !fs::is_symlink( dir ) );
- BOOST_TEST( !fs::is_symlink( "nosuchfileordirectory" ) );
+ BOOST_TEST(!fs::is_symlink(dir));
+ BOOST_TEST(!fs::is_symlink("nosuchfileordirectory"));
d1 = dir / "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 ) );
+ BOOST_TEST(fs::create_directory(d1));
+ BOOST_TEST(fs::exists(d1));
+ BOOST_TEST(fs::is_directory(d1));
+ BOOST_TEST(fs::is_empty(d1));
+ status_of_nonexistent_tests();
directory_iterator_tests();
create_directories_tests(); // must run AFTER directory_iterator_tests
// create an empty file named "f0"
- fs::path file_ph( dir / "f0");
- create_file( file_ph, "" );
- 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 );
+ fs::path file_ph(dir / "f0");
+ create_file(file_ph, "");
+ BOOST_TEST(fs::exists(file_ph));
+ BOOST_TEST(!fs::is_directory(file_ph));
+ BOOST_TEST(fs::is_regular_file(file_ph));
+ BOOST_TEST(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_TEST( CHECK_EXCEPTION( bad_create_directory, EEXIST ) );
- fs::file_status stat = fs::status( file_ph );
- 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 ) );
+ BOOST_TEST(CHECK_EXCEPTION(bad_create_directory, EEXIST));
+ fs::file_status stat = fs::status(file_ph);
+ 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" );
+ create_file(file_ph, "foobar1");
- 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" );
+ 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_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 ) );
+ 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();
@@ -978,32 +986,32 @@
// copy_file() tests
std::cout << "begin copy_file test..." << std::endl;
- BOOST_TEST( fs::exists( file_ph ) );
- fs::remove( d1 / "f2" ); // remove possible residue from prior testing
- BOOST_TEST( fs::exists( d1 ) );
- BOOST_TEST( !fs::exists( d1 / "f2" ) );
+ BOOST_TEST(fs::exists(file_ph));
+ fs::remove(d1 / "f2"); // remove possible residue from prior testing
+ BOOST_TEST(fs::exists(d1));
+ BOOST_TEST(!fs::exists(d1 / "f2"));
std::cout << " copy " << file_ph << " to " << d1 / "f2" << std::endl;
- fs::copy_file( file_ph, d1 / "f2" );
+ fs::copy_file(file_ph, d1 / "f2");
std::cout << " copy complete" << std::endl;
- BOOST_TEST( fs::exists( file_ph ) );
- BOOST_TEST( fs::exists( d1 / "f2" ) );
- BOOST_TEST( !fs::is_directory( d1 / "f2" ) );
- verify_file( d1 / "f2", "foobar1" );
+ BOOST_TEST(fs::exists(file_ph));
+ BOOST_TEST(fs::exists(d1 / "f2"));
+ BOOST_TEST(!fs::is_directory(d1 / "f2"));
+ verify_file(d1 / "f2", "foobar1");
bool copy_ex_ok = false;
- try { fs::copy_file( file_ph, d1 / "f2" ); }
- catch ( const fs::filesystem_error & ) { copy_ex_ok = true; }
- BOOST_TEST( copy_ex_ok );
+ try { fs::copy_file(file_ph, d1 / "f2"); }
+ catch (const fs::filesystem_error &) { copy_ex_ok = true; }
+ BOOST_TEST(copy_ex_ok);
copy_ex_ok = false;
- try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::fail_if_exists ); }
- catch ( const fs::filesystem_error & ) { copy_ex_ok = true; }
- BOOST_TEST( copy_ex_ok );
+ try { fs::copy_file(file_ph, d1 / "f2", fs::copy_option::fail_if_exists); }
+ catch (const fs::filesystem_error &) { copy_ex_ok = true; }
+ BOOST_TEST(copy_ex_ok);
copy_ex_ok = true;
- try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::overwrite_if_exists ); }
- catch ( const fs::filesystem_error & ) { copy_ex_ok = false; }
- BOOST_TEST( copy_ex_ok );
+ try { fs::copy_file(file_ph, d1 / "f2", fs::copy_option::overwrite_if_exists); }
+ catch (const fs::filesystem_error &) { copy_ex_ok = false; }
+ BOOST_TEST(copy_ex_ok);
std::cout << "copy_file test complete" << std::endl;
@@ -1011,132 +1019,132 @@
// remove() file
file_ph = dir / "shortlife";
- BOOST_TEST( !fs::exists( file_ph ) );
- create_file( file_ph, "" );
- 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" ) );
+ BOOST_TEST(!fs::exists(file_ph));
+ create_file(file_ph, "");
+ 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_TEST( !fs::exists( d1 ) );
- fs::create_directory( d1 );
- BOOST_TEST( fs::exists( d1 ) );
- BOOST_TEST( fs::is_directory( d1 ) );
- BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) );
+ BOOST_TEST(!fs::exists(d1));
+ fs::create_directory(d1);
+ BOOST_TEST(fs::exists(d1));
+ BOOST_TEST(fs::is_directory(d1));
+ BOOST_TEST(fs::is_empty(d1));
bad_remove_dir = dir;
- BOOST_TEST( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) );
- BOOST_TEST( fs::remove( d1 ) );
- BOOST_TEST( !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
+ 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_TEST( !fs::is_symlink( link ) );
- BOOST_TEST( !fs::exists( link ) );
- fs::create_symlink( "nowhere", link );
- BOOST_TEST( !fs::exists( link ) );
- BOOST_TEST( fs::is_symlink( link ) );
- BOOST_TEST( fs::remove( link ) );
- BOOST_TEST( !fs::is_symlink( link ) );
+ fs::path link("dangling_link");
+ fs::remove(link); // remove any residue from past tests
+ BOOST_TEST(!fs::is_symlink(link));
+ BOOST_TEST(!fs::exists(link));
+ fs::create_symlink("nowhere", 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_TEST( !fs::is_symlink( link ) );
- BOOST_TEST( !fs::exists( link ) );
- fs::create_symlink( link, link );
- BOOST_TEST( fs::remove( link ) );
- BOOST_TEST( !fs::exists( link ) );
- BOOST_TEST( !fs::is_symlink( link ) );
+ fs::remove(link); // remove any residue from past tests
+ BOOST_TEST(!fs::is_symlink(link));
+ BOOST_TEST(!fs::exists(link));
+ fs::create_symlink(link, 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_TEST( !fs::is_symlink( link ) );
- BOOST_TEST( !fs::exists( link ) );
- fs::create_symlink( link, link2 );
- fs::create_symlink( link2, 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 ) );
+ 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_TEST(!fs::is_symlink(link));
+ BOOST_TEST(!fs::exists(link));
+ fs::create_symlink(link, link2);
+ fs::create_symlink(link2, 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_TEST( !fs::exists( file_ph ) );
- create_file( file_ph, "" );
- BOOST_TEST( fs::exists( file_ph ) );
- BOOST_TEST( !fs::is_directory( file_ph ) );
- BOOST_TEST( fs::is_regular_file( file_ph ) );
+ fs::remove(file_ph); // remove any residue from past tests
+ BOOST_TEST(!fs::exists(file_ph));
+ create_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_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 ) );
+ fs::create_symlink(file_ph, link);
+ 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_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" );
+ create_file(file_ph, "foobar2");
+ 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
// others (NTFS) report it as UTC. The C standard does not specify
// if time_t is local or UTC.
- std::time_t ft = fs::last_write_time( file_ph );
+ std::time_t ft = fs::last_write_time(file_ph);
std::cout << "\nUTC last_write_time() for a file just created is "
<< std::asctime(std::gmtime(&ft)) << std::endl;
- std::tm * tmp = std::localtime( &ft );
+ std::tm * tmp = std::localtime(&ft);
std::cout << "\nYear is " << tmp->tm_year << std::endl;
--tmp->tm_year;
std::cout << "Change year to " << tmp->tm_year << std::endl;
- fs::last_write_time( file_ph, std::mktime( tmp ) );
- std::time_t ft2 = fs::last_write_time( file_ph );
+ fs::last_write_time(file_ph, std::mktime(tmp));
+ 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_TEST( ft != fs::last_write_time( file_ph ) );
+ BOOST_TEST(ft != fs::last_write_time(file_ph));
std::cout << "\nReset to current time" << std::endl;
- fs::last_write_time( file_ph, ft );
- double time_diff = std::difftime( ft, fs::last_write_time( file_ph ) );
+ fs::last_write_time(file_ph, ft);
+ double time_diff = std::difftime(ft, fs::last_write_time(file_ph));
std::cout
<< "original last_write_time() - current last_write_time() is "
<< time_diff << " seconds" << std::endl;
- BOOST_TEST( time_diff >= -60.0 && time_diff <= 60.0 );
+ BOOST_TEST(time_diff >= -60.0 && time_diff <= 60.0);
// post-test cleanup
- if ( cleanup )
+ if (cleanup)
{
- BOOST_TEST( 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_TEST( !fs::exists( dir ) );
- BOOST_TEST( fs::remove_all( dir ) == 0 );
+ BOOST_TEST(!fs::exists(dir));
+ BOOST_TEST(fs::remove_all(dir) == 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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -17,16 +17,16 @@
using std::cout;
using std::string;
-#define CHECK(x) check( x, __FILE__, __LINE__ )
+#define CHECK(x) check(x, __FILE__, __LINE__)
namespace
{
std::string this_file;
- void check( bool ok, const char* file, int line )
+ void check(bool ok, const char* file, int line)
{
- if ( ok ) return;
+ if (ok) return;
++::boost::detail::test_errors();
@@ -41,20 +41,20 @@
error_code ec;
- CHECK( file_size( "no-such-file", ec ) == 0 );
- CHECK( ec == errc::no_such_file_or_directory );
+ CHECK(file_size("no-such-file", ec) == 0);
+ CHECK(ec == errc::no_such_file_or_directory);
- CHECK( status( "no-such-file" ) == file_status( file_not_found ) );
+ CHECK(status("no-such-file") == file_status(file_not_found));
- CHECK( exists( "/" ) );
- CHECK( !exists( "no-such-file" ) );
+ CHECK(exists("/"));
+ CHECK(!exists("no-such-file"));
- CHECK( is_directory( "/" ) );
- CHECK( !is_directory( this_file ) );
+ CHECK(is_directory("/"));
+ CHECK(!is_directory(this_file));
- CHECK( is_regular_file( this_file ) );
- CHECK( !boost::filesystem::is_empty( this_file ) );
- CHECK( !is_other( this_file ) );
+ CHECK(is_regular_file(this_file));
+ CHECK(!boost::filesystem::is_empty(this_file));
+ CHECK(!is_other(this_file));
}
// directory_iterator_test -----------------------------------------------//
@@ -65,29 +65,29 @@
directory_iterator end;
- directory_iterator it( "." );
+ directory_iterator it(".");
- CHECK( !it->path().empty() );
+ CHECK(!it->path().empty());
- if ( is_regular_file( it->status() ) )
+ if (is_regular_file(it->status()))
{
- CHECK( is_regular_file( it->symlink_status() ) );
- CHECK( !is_directory( it->status() ) );
- CHECK( !is_symlink( it->status() ) );
- CHECK( !is_directory( it->symlink_status() ) );
- CHECK( !is_symlink( it->symlink_status() ) );
+ CHECK(is_regular_file(it->symlink_status()));
+ CHECK(!is_directory(it->status()));
+ CHECK(!is_symlink(it->status()));
+ CHECK(!is_directory(it->symlink_status()));
+ CHECK(!is_symlink(it->symlink_status()));
}
else
{
- CHECK( is_directory( it->status() ) );
- CHECK( is_directory( it->symlink_status() ) );
- CHECK( !is_regular_file( it->status() ) );
- CHECK( !is_regular_file( it->symlink_status() ) );
- CHECK( !is_symlink( it->status() ) );
- CHECK( !is_symlink( it->symlink_status() ) );
+ CHECK(is_directory(it->status()));
+ CHECK(is_directory(it->symlink_status()));
+ CHECK(!is_regular_file(it->status()));
+ CHECK(!is_regular_file(it->symlink_status()));
+ CHECK(!is_symlink(it->status()));
+ CHECK(!is_symlink(it->symlink_status()));
}
- for ( ; it != end; ++it )
+ for (; it != end; ++it)
{
// cout << " " << it->path().string() << "\n";
}
@@ -103,23 +103,23 @@
error_code ec;
- CHECK( complete( "foo", "c:/" ) == "c:/foo" );
+ CHECK(complete("foo", "c:/") == "c:/foo");
- CHECK( !create_directory( "/", ec ) );
+ CHECK(!create_directory("/", ec));
- CHECK( !boost::filesystem::remove( "no-such-file-or-directory" ) );
- CHECK( !remove_all( "no-such-file-or-directory" ) );
+ CHECK(!boost::filesystem::remove("no-such-file-or-directory"));
+ CHECK(!remove_all("no-such-file-or-directory"));
- space_info info = space( "/" );
+ space_info info = space("/");
- CHECK( info.available <= info.capacity );
+ CHECK(info.available <= info.capacity);
- CHECK( equivalent( "/", "/" ) );
- CHECK( !equivalent( "/", "." ) );
+ CHECK(equivalent("/", "/"));
+ CHECK(!equivalent("/", "."));
- std::time_t ft = last_write_time( "." );
-
- last_write_time( ".", std::time_t(-1), ec );
+ std::time_t ft = last_write_time(".");
+ ft = -1;
+ last_write_time(".", ft, ec);
}
// directory_entry_overload_test ---------------------------------------------------//
@@ -128,8 +128,8 @@
{
std::cout << "directory_entry overload test..." << std::endl;
- directory_iterator it( "." );
- path p( *it );
+ directory_iterator it(".");
+ path p(*it);
}
} // unnamed namespace
@@ -140,7 +140,7 @@
// //
//--------------------------------------------------------------------------------------//
-int main( int argc, char * argv[] )
+int main(int, char* argv[])
{
this_file = argv[0];
@@ -148,26 +148,26 @@
// error handling tests
- bool threw( false );
+ bool threw(false);
try
{
- file_size( "no-such-file" );
+ file_size("no-such-file");
}
- catch ( const boost::filesystem::filesystem_error & ex )
+ 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 ( ... )
+ catch (...)
{
cout << "\nunexpected exception type caught" << std::endl;
}
- CHECK( threw );
+ CHECK(threw);
error_code ec;
- CHECK( !create_directory( "/", ec ) );
+ CHECK(!create_directory("/", ec));
query_test();
directory_iterator_test();
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -30,8 +30,8 @@
#include <boost/detail/lightweight_test.hpp>
-#define PATH_CHECK( a, b ) check( a, b, __FILE__, __LINE__ )
-#define CHECK_EQUAL( a,b ) check_equal( a, b, __FILE__, __LINE__ )
+#define PATH_CHECK(a, b) check(a, b, __FILE__, __LINE__)
+#define CHECK_EQUAL(a,b) check_equal(a, b, __FILE__, __LINE__)
# ifdef BOOST_FILESYSTEM_PATH_CTOR_COUNT
namespace boost { namespace filesystem { long path_constructor_count = 0L; }}
@@ -39,12 +39,12 @@
namespace
{
- std::string platform( BOOST_PLATFORM );
+ std::string platform(BOOST_PLATFORM);
- void check( const fs::path & source,
- const std::string & expected, const char* file, int line )
+ void check(const fs::path & source,
+ const std::string & expected, const char* file, int line)
{
- if ( source.native_string() == expected )
+ if (source.native_string() == expected)
return;
std::cout << file
@@ -55,10 +55,10 @@
++::boost::detail::test_errors();
}
- void check_equal( const fs::path & source,
- const std::string & expected, const char* file, int line )
+ void check_equal(const fs::path & source,
+ const std::string & expected, const char* file, int line)
{
- if ( source == expected ) return;
+ if (source == expected) return;
++::boost::detail::test_errors();
@@ -67,10 +67,10 @@
<< "\"" << std::endl;
}
- path p1( "fe/fi/fo/fum" );
- path p2( p1 );
+ path p1("fe/fi/fo/fum");
+ path p2(p1);
path p3;
- path p4( "foobar" );
+ path p4("foobar");
path p5;
// exception_tests -------------------------------------------------------//
@@ -79,25 +79,25 @@
{
std::cout << "exception_tests..." << std::endl;
const std::string str_1("string-1");
- boost::system::error_code ec( 12345, boost::system::system_category);
- try { throw fs::filesystem_error( str_1, ec ); }
- catch ( const fs::filesystem_error & ex )
+ boost::system::error_code ec(12345, boost::system::system_category);
+ try { throw fs::filesystem_error(str_1, ec); }
+ catch (const fs::filesystem_error & ex)
{
//std::cout << ex.what() << "*" << std::endl;
- //BOOST_TEST( std::strcmp( ex.what(),
- // "string-1: Unknown error" ) == 0 );
- BOOST_TEST( ex.code() == ec );
+ //BOOST_TEST(std::strcmp(ex.what(),
+ // "string-1: Unknown error") == 0);
+ BOOST_TEST(ex.code() == ec);
}
- try { throw fs::filesystem_error( str_1, "p1", "p2", ec ); }
- catch ( const fs::filesystem_error & ex )
+ try { throw fs::filesystem_error(str_1, "p1", "p2", ec); }
+ catch (const fs::filesystem_error & ex)
{
//std::cout << ex.what() << "*" << std::endl;
- //BOOST_TEST( std::strcmp( ex.what(),
- // "string-1: Unknown error: \"p1\", \"p2\"" ) == 0 );
- BOOST_TEST( ex.code() == ec );
- BOOST_TEST( ex.path1().string() == "p1" );
- BOOST_TEST( ex.path2().string() == "p2" );
+ //BOOST_TEST(std::strcmp(ex.what(),
+ // "string-1: Unknown error: \"p1\", \"p2\"") == 0);
+ BOOST_TEST(ex.code() == ec);
+ BOOST_TEST(ex.path1().string() == "p1");
+ BOOST_TEST(ex.path2().string() == "p2");
}
}
@@ -110,20 +110,20 @@
{
std::cout << "overload_tests..." << std::endl;
- fs::exists( p1 );
- fs::exists( "foo" );
- fs::exists( std::string( "foo" ) );
-
- fs::exists( p1 / path( "foo" ) );
- fs::exists( p1 / "foo" );
- fs::exists( p1 / std::string( "foo" ) );
+ fs::exists(p1);
+ fs::exists("foo");
+ fs::exists(std::string("foo"));
+
+ fs::exists(p1 / path("foo"));
+ fs::exists(p1 / "foo");
+ fs::exists(p1 / std::string("foo"));
- fs::exists( "foo" / p1 );
- fs::exists( std::string( "foo" ) / p1 );
+ fs::exists("foo" / p1);
+ fs::exists(std::string("foo") / p1);
- p4 /= path( "foo" );
+ p4 /= path("foo");
p4 /= "foo";
- p4 /= std::string( "foo" );
+ p4 /= std::string("foo");
}
// iterator_tests --------------------------------------------------------//
@@ -134,233 +134,233 @@
path itr_ck = "";
path::const_iterator itr = itr_ck.begin();
- BOOST_TEST( itr == itr_ck.end() );
+ BOOST_TEST(itr == itr_ck.end());
itr_ck = "/";
itr = itr_ck.begin();
- BOOST_TEST( *itr == std::string( "/" ) );
- BOOST_TEST( ++itr == itr_ck.end() );
- BOOST_TEST( *--itr == std::string( "/" ) );
+ BOOST_TEST(*itr == std::string("/"));
+ BOOST_TEST(++itr == itr_ck.end());
+ BOOST_TEST(*--itr == std::string("/"));
itr_ck = "foo";
- BOOST_TEST( *itr_ck.begin() == std::string( "foo" ) );
- BOOST_TEST( boost::next( itr_ck.begin() ) == itr_ck.end() );
- BOOST_TEST( *boost::prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_TEST( boost::prior( itr_ck.end() ) == itr_ck.begin() );
-
- itr_ck = path( "/foo" );
- BOOST_TEST( *itr_ck.begin() == std::string( "/" ) );
- BOOST_TEST( *boost::next( itr_ck.begin() ) == std::string( "foo" ) );
- BOOST_TEST( boost::next(boost::next( itr_ck.begin() )) == itr_ck.end() );
- BOOST_TEST( boost::next( itr_ck.begin() ) == boost::prior( itr_ck.end() ) );
- BOOST_TEST( *boost::prior( itr_ck.end() ) == std::string( "foo" ) );
- BOOST_TEST( *boost::prior(boost::prior( itr_ck.end() )) == std::string( "/" ) );
- BOOST_TEST( boost::prior(boost::prior( itr_ck.end() )) == itr_ck.begin() );
+ BOOST_TEST(*itr_ck.begin() == std::string("foo"));
+ BOOST_TEST(boost::next(itr_ck.begin()) == itr_ck.end());
+ BOOST_TEST(*boost::prior(itr_ck.end()) == std::string("foo"));
+ BOOST_TEST(boost::prior(itr_ck.end()) == itr_ck.begin());
+
+ itr_ck = path("/foo");
+ BOOST_TEST(*itr_ck.begin() == std::string("/"));
+ BOOST_TEST(*boost::next(itr_ck.begin()) == std::string("foo"));
+ BOOST_TEST(boost::next(boost::next(itr_ck.begin())) == itr_ck.end());
+ BOOST_TEST(boost::next(itr_ck.begin()) == boost::prior(itr_ck.end()));
+ BOOST_TEST(*boost::prior(itr_ck.end()) == std::string("foo"));
+ BOOST_TEST(*boost::prior(boost::prior(itr_ck.end())) == std::string("/"));
+ BOOST_TEST(boost::prior(boost::prior(itr_ck.end())) == itr_ck.begin());
itr_ck = "/foo/bar";
itr = itr_ck.begin();
- 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, "/" );
+ 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, "/");
itr_ck = "../f"; // previously failed due to short name bug
itr = itr_ck.begin();
- CHECK_EQUAL( *itr, ".." );
- CHECK_EQUAL( *++itr, "f" );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "f" );
- CHECK_EQUAL( *--itr, ".." );
+ CHECK_EQUAL(*itr, "..");
+ CHECK_EQUAL(*++itr, "f");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, "f");
+ CHECK_EQUAL(*--itr, "..");
// POSIX says treat "/foo/bar/" as "/foo/bar/."
itr_ck = "/foo/bar/";
itr = itr_ck.begin();
- CHECK_EQUAL( *itr, "/" );
- CHECK_EQUAL( *++itr, "foo" );
- CHECK_EQUAL( *++itr, "bar" );
- CHECK_EQUAL( *++itr, "." );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "." );
- CHECK_EQUAL( *--itr, "bar" );
- CHECK_EQUAL( *--itr, "foo" );
- CHECK_EQUAL( *--itr, "/" );
+ CHECK_EQUAL(*itr, "/");
+ CHECK_EQUAL(*++itr, "foo");
+ CHECK_EQUAL(*++itr, "bar");
+ CHECK_EQUAL(*++itr, ".");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, ".");
+ CHECK_EQUAL(*--itr, "bar");
+ CHECK_EQUAL(*--itr, "foo");
+ CHECK_EQUAL(*--itr, "/");
// POSIX says treat "/f/b/" as "/f/b/."
itr_ck = "/f/b/";
itr = itr_ck.begin();
- CHECK_EQUAL( *itr, "/" );
- CHECK_EQUAL( *++itr, "f" );
- CHECK_EQUAL( *++itr, "b" );
- CHECK_EQUAL( *++itr, "." );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "." );
- CHECK_EQUAL( *--itr, "b" );
- CHECK_EQUAL( *--itr, "f" );
- CHECK_EQUAL( *--itr, "/" );
+ CHECK_EQUAL(*itr, "/");
+ CHECK_EQUAL(*++itr, "f");
+ CHECK_EQUAL(*++itr, "b");
+ CHECK_EQUAL(*++itr, ".");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, ".");
+ CHECK_EQUAL(*--itr, "b");
+ CHECK_EQUAL(*--itr, "f");
+ CHECK_EQUAL(*--itr, "/");
itr_ck = "//net";
itr = itr_ck.begin();
// 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_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "//net" );
+ CHECK_EQUAL(*itr, "//net");
+ 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_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "/" );
- CHECK_EQUAL( *--itr, "//net" );
+ CHECK_EQUAL(*itr, "//net");
+ CHECK_EQUAL(*++itr, "/");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, "/");
+ CHECK_EQUAL(*--itr, "//net");
itr_ck = "//foo///bar///";
itr = itr_ck.begin();
- CHECK_EQUAL( *itr, "//foo" );
- CHECK_EQUAL( *++itr, "/" );
- CHECK_EQUAL( *++itr, "bar" );
- CHECK_EQUAL( *++itr, "." );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "." );
- CHECK_EQUAL( *--itr, "bar" );
- CHECK_EQUAL( *--itr, "/" );
- CHECK_EQUAL( *--itr, "//foo" );
+ CHECK_EQUAL(*itr, "//foo");
+ CHECK_EQUAL(*++itr, "/");
+ CHECK_EQUAL(*++itr, "bar");
+ CHECK_EQUAL(*++itr, ".");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, ".");
+ CHECK_EQUAL(*--itr, "bar");
+ CHECK_EQUAL(*--itr, "/");
+ CHECK_EQUAL(*--itr, "//foo");
itr_ck = "///foo///bar///";
itr = itr_ck.begin();
// three or more leading slashes are to be treated as a single slash
- CHECK_EQUAL( *itr, "/" );
- CHECK_EQUAL( *++itr, "foo" );
- CHECK_EQUAL( *++itr, "bar" );
- CHECK_EQUAL( *++itr, "." );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "." );
- CHECK_EQUAL( *--itr, "bar" );
- CHECK_EQUAL( *--itr, "foo" );
- CHECK_EQUAL( *--itr, "/" );
+ CHECK_EQUAL(*itr, "/");
+ CHECK_EQUAL(*++itr, "foo");
+ CHECK_EQUAL(*++itr, "bar");
+ CHECK_EQUAL(*++itr, ".");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, ".");
+ CHECK_EQUAL(*--itr, "bar");
+ CHECK_EQUAL(*--itr, "foo");
+ CHECK_EQUAL(*--itr, "/");
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
itr_ck = "c:/";
itr = itr_ck.begin();
- CHECK_EQUAL( *itr, "c:" );
- CHECK_EQUAL( *++itr, "/" );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "/" );
- CHECK_EQUAL( *--itr, "c:" );
+ CHECK_EQUAL(*itr, "c:");
+ CHECK_EQUAL(*++itr, "/");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, "/");
+ CHECK_EQUAL(*--itr, "c:");
itr_ck = "c:\\foo";
itr = itr_ck.begin();
- 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:" ) );
+ 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();
// three or more leading slashes are to be treated as a single slash
- CHECK_EQUAL( *itr, "/" );
- CHECK_EQUAL( *++itr, "foo" );
- CHECK_EQUAL( *++itr, "bar" );
- CHECK_EQUAL( *++itr, "." );
- BOOST_TEST( ++itr == itr_ck.end() );
- CHECK_EQUAL( *--itr, "." );
- CHECK_EQUAL( *--itr, "bar" );
- CHECK_EQUAL( *--itr, "foo" );
- CHECK_EQUAL( *--itr, "/" );
+ CHECK_EQUAL(*itr, "/");
+ CHECK_EQUAL(*++itr, "foo");
+ CHECK_EQUAL(*++itr, "bar");
+ CHECK_EQUAL(*++itr, ".");
+ BOOST_TEST(++itr == itr_ck.end());
+ CHECK_EQUAL(*--itr, ".");
+ CHECK_EQUAL(*--itr, "bar");
+ CHECK_EQUAL(*--itr, "foo");
+ CHECK_EQUAL(*--itr, "/");
itr_ck = "c:foo";
itr = itr_ck.begin();
- 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:" ) );
+ 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_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_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_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_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_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_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_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_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_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:" ) );
+ 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_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_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_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_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_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_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_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_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_TEST( ++itr == itr_ck.end() );
+ CHECK_EQUAL(*itr, "/");
+ BOOST_TEST(++itr == itr_ck.end());
}
}
@@ -379,286 +379,286 @@
char acs[] = "a";
std::string as(acs);
- path a( as );
+ path a(as);
char acs2[] = "a";
std::string as2(acs2);
- path a2( as2 );
+ path a2(as2);
char bcs[] = "b";
std::string bs(bcs);
- path b( bs );
+ path b(bs);
// swap
- a.swap( b );
- BOOST_TEST( a.string() == "b" );
- BOOST_TEST( b.string() == "a" );
- fs::swap( a, b );
- BOOST_TEST( a.string() == "a" );
- BOOST_TEST( b.string() == "b" );
+ a.swap(b);
+ BOOST_TEST(a.string() == "b");
+ BOOST_TEST(b.string() == "a");
+ fs::swap(a, b);
+ BOOST_TEST(a.string() == "a");
+ BOOST_TEST(b.string() == "b");
// probe operator /
- PATH_CHECK( path("") / ".", "." );
- PATH_CHECK( path("") / "..", ".." );
- if ( platform == "Windows" )
+ PATH_CHECK(path("") / ".", ".");
+ PATH_CHECK(path("") / "..", "..");
+ if (platform == "Windows")
{
- BOOST_TEST( (b / a).native_string() == "b\\a" );
- BOOST_TEST( (bs / a).native_string() == "b\\a" );
- BOOST_TEST( (bcs / a).native_string() == "b\\a" );
- BOOST_TEST( (b / as).native_string() == "b\\a" );
- BOOST_TEST( (b / acs).native_string() == "b\\a" );
- PATH_CHECK( path("a") / "b", "a\\b" );
- PATH_CHECK( path("..") / "", ".." );
- PATH_CHECK( path("foo") / path("bar"), "foo\\bar" ); // path arg
- PATH_CHECK( path("foo") / "bar", "foo\\bar" ); // const char * arg
- PATH_CHECK( path("foo") / path("woo/bar").filename(), "foo\\bar" ); // const std::string & arg
- PATH_CHECK( "foo" / path("bar"), "foo\\bar" );
- PATH_CHECK( path("..") / ".." , "..\\.." );
- PATH_CHECK( path("/") / ".." , "/.." );
- PATH_CHECK( path("/..") / ".." , "/..\\.." );
- PATH_CHECK( path("..") / "foo" , "..\\foo" );
- PATH_CHECK( path("foo") / ".." , "foo\\.." );
- PATH_CHECK( path("..") / "f" , "..\\f" );
- PATH_CHECK( path("/..") / "f" , "/..\\f" );
- PATH_CHECK( path("f") / ".." , "f\\.." );
- PATH_CHECK( path("foo") / ".." / ".." , "foo\\..\\.." );
- PATH_CHECK( path("foo") / ".." / ".." / ".." , "foo\\..\\..\\.." );
- PATH_CHECK( path("f") / ".." / "b" , "f\\..\\b" );
- PATH_CHECK( path("foo") / ".." / "bar" , "foo\\..\\bar" );
- PATH_CHECK( path("foo") / "bar" / ".." , "foo\\bar\\.." );
- PATH_CHECK( path("foo") / "bar" / ".." / "..", "foo\\bar\\..\\.." );
- PATH_CHECK( path("foo") / "bar" / ".." / "blah", "foo\\bar\\..\\blah" );
- PATH_CHECK( path("f") / "b" / ".." , "f\\b\\.." );
- PATH_CHECK( path("f") / "b" / ".." / "a", "f\\b\\..\\a" );
- PATH_CHECK( path("foo") / "bar" / "blah" / ".." / "..", "foo\\bar\\blah\\..\\.." );
- PATH_CHECK( path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo\\bar\\blah\\..\\..\\bletch" );
-
- PATH_CHECK( path(".") / "foo", ".\\foo" );
- PATH_CHECK( path(".") / "..", ".\\.." );
- PATH_CHECK( path("foo") / ".", "foo\\." );
- PATH_CHECK( path("..") / ".", "..\\." );
- PATH_CHECK( path(".") / ".", ".\\." );
- PATH_CHECK( path(".") / "." / ".", ".\\.\\." );
- PATH_CHECK( path(".") / "foo" / ".", ".\\foo\\." );
- PATH_CHECK( path("foo") / "." / "bar", "foo\\.\\bar" );
- PATH_CHECK( path("foo") / "." / ".", "foo\\.\\." );
- PATH_CHECK( path("foo") / "." / "..", "foo\\.\\.." );
- PATH_CHECK( path(".") / "." / "..", ".\\.\\.." );
- PATH_CHECK( path(".") / ".." / ".", ".\\..\\." );
- PATH_CHECK( path("..") / "." / ".", "..\\.\\." );
+ BOOST_TEST((b / a).native_string() == "b\\a");
+ BOOST_TEST((bs / a).native_string() == "b\\a");
+ BOOST_TEST((bcs / a).native_string() == "b\\a");
+ BOOST_TEST((b / as).native_string() == "b\\a");
+ BOOST_TEST((b / acs).native_string() == "b\\a");
+ PATH_CHECK(path("a") / "b", "a\\b");
+ PATH_CHECK(path("..") / "", "..");
+ PATH_CHECK(path("foo") / path("bar"), "foo\\bar"); // path arg
+ PATH_CHECK(path("foo") / "bar", "foo\\bar"); // const char* arg
+ PATH_CHECK(path("foo") / path("woo/bar").filename(), "foo\\bar"); // const std::string & arg
+ PATH_CHECK("foo" / path("bar"), "foo\\bar");
+ PATH_CHECK(path("..") / ".." , "..\\..");
+ PATH_CHECK(path("/") / ".." , "/..");
+ PATH_CHECK(path("/..") / ".." , "/..\\..");
+ PATH_CHECK(path("..") / "foo" , "..\\foo");
+ PATH_CHECK(path("foo") / ".." , "foo\\..");
+ PATH_CHECK(path("..") / "f" , "..\\f");
+ PATH_CHECK(path("/..") / "f" , "/..\\f");
+ PATH_CHECK(path("f") / ".." , "f\\..");
+ PATH_CHECK(path("foo") / ".." / ".." , "foo\\..\\..");
+ PATH_CHECK(path("foo") / ".." / ".." / ".." , "foo\\..\\..\\..");
+ PATH_CHECK(path("f") / ".." / "b" , "f\\..\\b");
+ PATH_CHECK(path("foo") / ".." / "bar" , "foo\\..\\bar");
+ PATH_CHECK(path("foo") / "bar" / ".." , "foo\\bar\\..");
+ PATH_CHECK(path("foo") / "bar" / ".." / "..", "foo\\bar\\..\\..");
+ PATH_CHECK(path("foo") / "bar" / ".." / "blah", "foo\\bar\\..\\blah");
+ PATH_CHECK(path("f") / "b" / ".." , "f\\b\\..");
+ PATH_CHECK(path("f") / "b" / ".." / "a", "f\\b\\..\\a");
+ PATH_CHECK(path("foo") / "bar" / "blah" / ".." / "..", "foo\\bar\\blah\\..\\..");
+ PATH_CHECK(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo\\bar\\blah\\..\\..\\bletch");
+
+ PATH_CHECK(path(".") / "foo", ".\\foo");
+ PATH_CHECK(path(".") / "..", ".\\..");
+ PATH_CHECK(path("foo") / ".", "foo\\.");
+ PATH_CHECK(path("..") / ".", "..\\.");
+ PATH_CHECK(path(".") / ".", ".\\.");
+ PATH_CHECK(path(".") / "." / ".", ".\\.\\.");
+ PATH_CHECK(path(".") / "foo" / ".", ".\\foo\\.");
+ PATH_CHECK(path("foo") / "." / "bar", "foo\\.\\bar");
+ PATH_CHECK(path("foo") / "." / ".", "foo\\.\\.");
+ PATH_CHECK(path("foo") / "." / "..", "foo\\.\\..");
+ PATH_CHECK(path(".") / "." / "..", ".\\.\\..");
+ PATH_CHECK(path(".") / ".." / ".", ".\\..\\.");
+ PATH_CHECK(path("..") / "." / ".", "..\\.\\.");
}
else
{
- 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("") / "..", ".." );
- PATH_CHECK( path("foo") / path("bar"), "foo/bar" ); // path arg
- PATH_CHECK( path("foo") / "bar", "foo/bar" ); // const char * arg
- PATH_CHECK( path("foo") / path("woo/bar").filename(), "foo/bar" ); // const std::string & arg
- PATH_CHECK( "foo" / path("bar"), "foo/bar" );
- PATH_CHECK( path("..") / ".." , "../.." );
- PATH_CHECK( path("/") / ".." , "/.." );
- PATH_CHECK( path("/..") / ".." , "/../.." );
- PATH_CHECK( path("..") / "foo" , "../foo" );
- PATH_CHECK( path("foo") / ".." , "foo/.." );
- PATH_CHECK( path("..") / "f" , "../f" );
- PATH_CHECK( path("/..") / "f" , "/../f" );
- PATH_CHECK( path("f") / ".." , "f/.." );
- PATH_CHECK( path("foo") / ".." / ".." , "foo/../.." );
- PATH_CHECK( path("foo") / ".." / ".." / ".." , "foo/../../.." );
- PATH_CHECK( path("f") / ".." / "b" , "f/../b" );
- PATH_CHECK( path("foo") / ".." / "bar" , "foo/../bar" );
- PATH_CHECK( path("foo") / "bar" / ".." , "foo/bar/.." );
- PATH_CHECK( path("foo") / "bar" / ".." / "..", "foo/bar/../.." );
- PATH_CHECK( path("foo") / "bar" / ".." / "blah", "foo/bar/../blah" );
- PATH_CHECK( path("f") / "b" / ".." , "f/b/.." );
- PATH_CHECK( path("f") / "b" / ".." / "a", "f/b/../a" );
- PATH_CHECK( path("foo") / "bar" / "blah" / ".." / "..", "foo/bar/blah/../.." );
- PATH_CHECK( path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo/bar/blah/../../bletch" );
-
- PATH_CHECK( path(".") / "foo", "./foo" );
- PATH_CHECK( path(".") / "..", "./.." );
- PATH_CHECK( path("foo") / ".", "foo/." );
- PATH_CHECK( path("..") / ".", "../." );
- PATH_CHECK( path(".") / ".", "./." );
- PATH_CHECK( path(".") / "." / ".", "././." );
- PATH_CHECK( path(".") / "foo" / ".", "./foo/." );
- PATH_CHECK( path("foo") / "." / "bar", "foo/./bar" );
- PATH_CHECK( path("foo") / "." / ".", "foo/./." );
- PATH_CHECK( path("foo") / "." / "..", "foo/./.." );
- PATH_CHECK( path(".") / "." / "..", "././.." );
- PATH_CHECK( path(".") / ".." / ".", "./../." );
- PATH_CHECK( path("..") / "." / ".", ".././." );
+ 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("") / "..", "..");
+ PATH_CHECK(path("foo") / path("bar"), "foo/bar"); // path arg
+ PATH_CHECK(path("foo") / "bar", "foo/bar"); // const char* arg
+ PATH_CHECK(path("foo") / path("woo/bar").filename(), "foo/bar"); // const std::string & arg
+ PATH_CHECK("foo" / path("bar"), "foo/bar");
+ PATH_CHECK(path("..") / ".." , "../..");
+ PATH_CHECK(path("/") / ".." , "/..");
+ PATH_CHECK(path("/..") / ".." , "/../..");
+ PATH_CHECK(path("..") / "foo" , "../foo");
+ PATH_CHECK(path("foo") / ".." , "foo/..");
+ PATH_CHECK(path("..") / "f" , "../f");
+ PATH_CHECK(path("/..") / "f" , "/../f");
+ PATH_CHECK(path("f") / ".." , "f/..");
+ PATH_CHECK(path("foo") / ".." / ".." , "foo/../..");
+ PATH_CHECK(path("foo") / ".." / ".." / ".." , "foo/../../..");
+ PATH_CHECK(path("f") / ".." / "b" , "f/../b");
+ PATH_CHECK(path("foo") / ".." / "bar" , "foo/../bar");
+ PATH_CHECK(path("foo") / "bar" / ".." , "foo/bar/..");
+ PATH_CHECK(path("foo") / "bar" / ".." / "..", "foo/bar/../..");
+ PATH_CHECK(path("foo") / "bar" / ".." / "blah", "foo/bar/../blah");
+ PATH_CHECK(path("f") / "b" / ".." , "f/b/..");
+ PATH_CHECK(path("f") / "b" / ".." / "a", "f/b/../a");
+ PATH_CHECK(path("foo") / "bar" / "blah" / ".." / "..", "foo/bar/blah/../..");
+ PATH_CHECK(path("foo") / "bar" / "blah" / ".." / ".." / "bletch", "foo/bar/blah/../../bletch");
+
+ PATH_CHECK(path(".") / "foo", "./foo");
+ PATH_CHECK(path(".") / "..", "./..");
+ PATH_CHECK(path("foo") / ".", "foo/.");
+ PATH_CHECK(path("..") / ".", "../.");
+ PATH_CHECK(path(".") / ".", "./.");
+ PATH_CHECK(path(".") / "." / ".", "././.");
+ PATH_CHECK(path(".") / "foo" / ".", "./foo/.");
+ PATH_CHECK(path("foo") / "." / "bar", "foo/./bar");
+ PATH_CHECK(path("foo") / "." / ".", "foo/./.");
+ PATH_CHECK(path("foo") / "." / "..", "foo/./..");
+ PATH_CHECK(path(".") / "." / "..", "././..");
+ PATH_CHECK(path(".") / ".." / ".", "./../.");
+ PATH_CHECK(path("..") / "." / ".", ".././.");
}
// probe operator <
- 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) );
+ 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_TEST( !(as < as) );
- BOOST_TEST( !(as < acs) );
- BOOST_TEST( !(acs < as) );
+ BOOST_TEST(!(as < as));
+ BOOST_TEST(!(as < acs));
+ BOOST_TEST(!(acs < as));
// reality check character set is as expected
- BOOST_TEST( std::string("a.b") < std::string("a/b") );
+ BOOST_TEST(std::string("a.b") < std::string("a/b"));
// verify compare is actually lexicographical
- BOOST_TEST( path("a/b") < path("a.b") );
+ BOOST_TEST(path("a/b") < path("a.b"));
// make sure the derivative operators also work
- 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 );
+ 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);
// operator == and != are implemented separately, so test separately
- path p1( "fe/fi/fo/fum" );
- path p2( p1 );
- path p3( "fe/fi/fo/fumm" );
- BOOST_TEST( p1.string() != p3.string() );
+ path p1("fe/fi/fo/fum");
+ path p2(p1);
+ path p3("fe/fi/fo/fumm");
+ BOOST_TEST(p1.string() != p3.string());
// check each overload
- BOOST_TEST( p1 != p3 );
- BOOST_TEST( p1 != p3.string() );
- BOOST_TEST( p1 != p3.string().c_str() );
- BOOST_TEST( p1.string() != p3 );
- BOOST_TEST( p1.string().c_str() != p3 );
+ BOOST_TEST(p1 != p3);
+ BOOST_TEST(p1 != p3.string());
+ BOOST_TEST(p1 != p3.string().c_str());
+ BOOST_TEST(p1.string() != p3);
+ BOOST_TEST(p1.string().c_str() != p3);
p3 = p2;
- BOOST_TEST( p1.string() == p3.string() );
+ BOOST_TEST(p1.string() == p3.string());
// check each overload
- BOOST_TEST( p1 == p3 );
- BOOST_TEST( p1 == p3.string() );
- BOOST_TEST( p1 == p3.string().c_str() );
- BOOST_TEST( p1.string() == p3 );
- BOOST_TEST( p1.string().c_str() == p3 );
+ BOOST_TEST(p1 == p3);
+ BOOST_TEST(p1 == p3.string());
+ BOOST_TEST(p1 == p3.string().c_str());
+ BOOST_TEST(p1.string() == p3);
+ BOOST_TEST(p1.string().c_str() == p3);
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
std::cout << "Windows relational tests..." << std::endl;
path p10 ("c:\\file");
path p11 ("c:/file");
// check each overload
- BOOST_TEST( p10.string() == p11.string() );
- BOOST_TEST( p10 == p11 );
- BOOST_TEST( p10 == p11.string() );
- BOOST_TEST( p10 == p11.string().c_str() );
- BOOST_TEST( p10.string() == p11 );
- BOOST_TEST( p10.string().c_str() == p11 );
- BOOST_TEST( p10 == L"c:\\file" );
- BOOST_TEST( p10 == L"c:/file" );
- BOOST_TEST( p11 == L"c:\\file" );
- BOOST_TEST( p11 == L"c:/file" );
- BOOST_TEST( L"c:\\file" == p10 );
- BOOST_TEST( L"c:/file" == p10 );
- BOOST_TEST( L"c:\\file" == p11 );
- BOOST_TEST( L"c:/file" == p11 );
-
- BOOST_TEST( !(p10.string() != p11.string()) );
- BOOST_TEST( !(p10 != p11) );
- BOOST_TEST( !(p10 != p11.string()) );
- BOOST_TEST( !(p10 != p11.string().c_str()) );
- BOOST_TEST( !(p10.string() != p11) );
- BOOST_TEST( !(p10.string().c_str() != p11) );
- BOOST_TEST( !(p10 != L"c:\\file") );
- BOOST_TEST( !(p10 != L"c:/file") );
- BOOST_TEST( !(p11 != L"c:\\file") );
- BOOST_TEST( !(p11 != L"c:/file") );
- BOOST_TEST( !(L"c:\\file" != p10) );
- BOOST_TEST( !(L"c:/file" != p10) );
- BOOST_TEST( !(L"c:\\file" != p11) );
- BOOST_TEST( !(L"c:/file" != p11) );
-
- BOOST_TEST( !(p10.string() < p11.string()) );
- BOOST_TEST( !(p10 < p11) );
- BOOST_TEST( !(p10 < p11.string()) );
- BOOST_TEST( !(p10 < p11.string().c_str()) );
- BOOST_TEST( !(p10.string() < p11) );
- BOOST_TEST( !(p10.string().c_str() < p11) );
- BOOST_TEST( !(p10 < L"c:\\file") );
- BOOST_TEST( !(p10 < L"c:/file") );
- BOOST_TEST( !(p11 < L"c:\\file") );
- BOOST_TEST( !(p11 < L"c:/file") );
- BOOST_TEST( !(L"c:\\file" < p10) );
- BOOST_TEST( !(L"c:/file" < p10) );
- BOOST_TEST( !(L"c:\\file" < p11) );
- BOOST_TEST( !(L"c:/file" < p11) );
-
- BOOST_TEST( !(p10.string() > p11.string()) );
- BOOST_TEST( !(p10 > p11) );
- BOOST_TEST( !(p10 > p11.string()) );
- BOOST_TEST( !(p10 > p11.string().c_str()) );
- BOOST_TEST( !(p10.string() > p11) );
- BOOST_TEST( !(p10.string().c_str() > p11) );
- BOOST_TEST( !(p10 > L"c:\\file") );
- BOOST_TEST( !(p10 > L"c:/file") );
- BOOST_TEST( !(p11 > L"c:\\file") );
- BOOST_TEST( !(p11 > L"c:/file") );
- BOOST_TEST( !(L"c:\\file" > p10) );
- BOOST_TEST( !(L"c:/file" > p10) );
- BOOST_TEST( !(L"c:\\file" > p11) );
- BOOST_TEST( !(L"c:/file" > p11) );
+ BOOST_TEST(p10.string() == p11.string());
+ BOOST_TEST(p10 == p11);
+ BOOST_TEST(p10 == p11.string());
+ BOOST_TEST(p10 == p11.string().c_str());
+ BOOST_TEST(p10.string() == p11);
+ BOOST_TEST(p10.string().c_str() == p11);
+ BOOST_TEST(p10 == L"c:\\file");
+ BOOST_TEST(p10 == L"c:/file");
+ BOOST_TEST(p11 == L"c:\\file");
+ BOOST_TEST(p11 == L"c:/file");
+ BOOST_TEST(L"c:\\file" == p10);
+ BOOST_TEST(L"c:/file" == p10);
+ BOOST_TEST(L"c:\\file" == p11);
+ BOOST_TEST(L"c:/file" == p11);
+
+ BOOST_TEST(!(p10.string() != p11.string()));
+ BOOST_TEST(!(p10 != p11));
+ BOOST_TEST(!(p10 != p11.string()));
+ BOOST_TEST(!(p10 != p11.string().c_str()));
+ BOOST_TEST(!(p10.string() != p11));
+ BOOST_TEST(!(p10.string().c_str() != p11));
+ BOOST_TEST(!(p10 != L"c:\\file"));
+ BOOST_TEST(!(p10 != L"c:/file"));
+ BOOST_TEST(!(p11 != L"c:\\file"));
+ BOOST_TEST(!(p11 != L"c:/file"));
+ BOOST_TEST(!(L"c:\\file" != p10));
+ BOOST_TEST(!(L"c:/file" != p10));
+ BOOST_TEST(!(L"c:\\file" != p11));
+ BOOST_TEST(!(L"c:/file" != p11));
+
+ BOOST_TEST(!(p10.string() < p11.string()));
+ BOOST_TEST(!(p10 < p11));
+ BOOST_TEST(!(p10 < p11.string()));
+ BOOST_TEST(!(p10 < p11.string().c_str()));
+ BOOST_TEST(!(p10.string() < p11));
+ BOOST_TEST(!(p10.string().c_str() < p11));
+ BOOST_TEST(!(p10 < L"c:\\file"));
+ BOOST_TEST(!(p10 < L"c:/file"));
+ BOOST_TEST(!(p11 < L"c:\\file"));
+ BOOST_TEST(!(p11 < L"c:/file"));
+ BOOST_TEST(!(L"c:\\file" < p10));
+ BOOST_TEST(!(L"c:/file" < p10));
+ BOOST_TEST(!(L"c:\\file" < p11));
+ BOOST_TEST(!(L"c:/file" < p11));
+
+ BOOST_TEST(!(p10.string() > p11.string()));
+ BOOST_TEST(!(p10 > p11));
+ BOOST_TEST(!(p10 > p11.string()));
+ BOOST_TEST(!(p10 > p11.string().c_str()));
+ BOOST_TEST(!(p10.string() > p11));
+ BOOST_TEST(!(p10.string().c_str() > p11));
+ BOOST_TEST(!(p10 > L"c:\\file"));
+ BOOST_TEST(!(p10 > L"c:/file"));
+ BOOST_TEST(!(p11 > L"c:\\file"));
+ BOOST_TEST(!(p11 > L"c:/file"));
+ BOOST_TEST(!(L"c:\\file" > p10));
+ BOOST_TEST(!(L"c:/file" > p10));
+ BOOST_TEST(!(L"c:\\file" > p11));
+ BOOST_TEST(!(L"c:/file" > p11));
}
@@ -673,448 +673,448 @@
path p;
p = "";
- 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() );
+ 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_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_TEST( 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());
+ if (platform == "POSIX")
+ BOOST_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
p = "//";
- CHECK_EQUAL( p.relative_path().string(), "" );
- CHECK_EQUAL( p.parent_path().string(), "" );
- CHECK_EQUAL( p.filename(), "//" );
- CHECK_EQUAL( p.root_name(), "//" );
- CHECK_EQUAL( p.root_directory(), "" );
- CHECK_EQUAL( 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() );
+ CHECK_EQUAL(p.relative_path().string(), "");
+ CHECK_EQUAL(p.parent_path().string(), "");
+ CHECK_EQUAL(p.filename(), "//");
+ CHECK_EQUAL(p.root_name(), "//");
+ CHECK_EQUAL(p.root_directory(), "");
+ CHECK_EQUAL(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 = "///";
- CHECK_EQUAL( p.relative_path().string(), "" );
- CHECK_EQUAL( p.parent_path().string(), "" );
- CHECK_EQUAL( p.filename(), "/" );
- CHECK_EQUAL( p.root_name(), "" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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_TEST( p.is_complete() );
+ CHECK_EQUAL(p.relative_path().string(), "");
+ CHECK_EQUAL(p.parent_path().string(), "");
+ CHECK_EQUAL(p.filename(), "/");
+ CHECK_EQUAL(p.root_name(), "");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
p = ".";
- 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() );
+ 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_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() );
+ 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_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() );
+ 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" );
- CHECK_EQUAL( p.parent_path().string(), "/" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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_TEST( p.is_complete() );
+ CHECK_EQUAL(p.relative_path().string(), "foo");
+ CHECK_EQUAL(p.parent_path().string(), "/");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
p = "/foo/";
- CHECK_EQUAL( p.relative_path().string(), "foo/" );
- CHECK_EQUAL( p.parent_path().string(), "/foo" );
- CHECK_EQUAL( p.filename(), "." );
- CHECK_EQUAL( p.root_name(), "" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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_TEST( p.is_complete() );
+ CHECK_EQUAL(p.relative_path().string(), "foo/");
+ CHECK_EQUAL(p.parent_path().string(), "/foo");
+ CHECK_EQUAL(p.filename(), ".");
+ CHECK_EQUAL(p.root_name(), "");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
p = "///foo";
- CHECK_EQUAL( p.relative_path().string(), "foo" );
- CHECK_EQUAL( p.parent_path().string(), "/" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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_TEST( p.is_complete() );
+ CHECK_EQUAL(p.relative_path().string(), "foo");
+ CHECK_EQUAL(p.parent_path().string(), "/");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
p = "foo/bar";
- 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() );
+ 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_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() );
+ 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" );
- CHECK_EQUAL( p.parent_path().string(), ".." );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "" );
- CHECK_EQUAL( p.root_directory(), "" );
- CHECK_EQUAL( 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() );
+ CHECK_EQUAL(p.relative_path().string(), "..///foo");
+ CHECK_EQUAL(p.parent_path().string(), "..");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "");
+ CHECK_EQUAL(p.root_directory(), "");
+ CHECK_EQUAL(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/bar";
- 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_TEST( 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());
+ if (platform == "POSIX")
+ BOOST_TEST(p.is_complete());
else
- BOOST_TEST( !p.is_complete() );
+ BOOST_TEST(!p.is_complete());
// Both POSIX and Windows allow two leading slashs
// (POSIX meaning is implementation defined)
- PATH_CHECK( path( "//resource" ), "//resource" );
- PATH_CHECK( path( "//resource/" ), "//resource/" );
- PATH_CHECK( path( "//resource/foo" ), "//resource/foo" );
-
- p = path( "//net" );
- CHECK_EQUAL( p.string(), "//net" );
- CHECK_EQUAL( p.relative_path().string(), "" );
- CHECK_EQUAL( p.parent_path().string(), "" );
- CHECK_EQUAL( p.filename(), "//net" );
- CHECK_EQUAL( p.root_name(), "//net" );
- CHECK_EQUAL( p.root_directory(), "" );
- CHECK_EQUAL( 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/" );
- 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_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" );
- CHECK_EQUAL( p.parent_path().string(), "//net/" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "//net" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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() );
+ PATH_CHECK(path("//resource"), "//resource");
+ PATH_CHECK(path("//resource/"), "//resource/");
+ PATH_CHECK(path("//resource/foo"), "//resource/foo");
+
+ p = path("//net");
+ CHECK_EQUAL(p.string(), "//net");
+ CHECK_EQUAL(p.relative_path().string(), "");
+ CHECK_EQUAL(p.parent_path().string(), "");
+ CHECK_EQUAL(p.filename(), "//net");
+ CHECK_EQUAL(p.root_name(), "//net");
+ CHECK_EQUAL(p.root_directory(), "");
+ CHECK_EQUAL(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/");
+ 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_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");
+ CHECK_EQUAL(p.parent_path().string(), "//net/");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "//net");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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());
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
- p = path( "c:" );
- 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_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_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_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_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_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" );
- CHECK_EQUAL( p.parent_path().string(), "c:/" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "c:" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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" );
- CHECK_EQUAL( p.parent_path().string(), "c:/" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "c:" );
- CHECK_EQUAL( p.root_directory(), "/" );
- CHECK_EQUAL( 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\\bar" );
- CHECK_EQUAL( p.relative_path().string(), "foo\\bar" );
- CHECK_EQUAL( p.parent_path().string(), "c:\\foo" );
- CHECK_EQUAL( p.filename(), "bar" );
- CHECK_EQUAL( p.root_name(), "c:" );
- CHECK_EQUAL( p.root_directory(), "\\" );
- CHECK_EQUAL( 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( "prn:" );
- 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" );
- CHECK_EQUAL( p.parent_path().string(), "\\\\net\\" );
- CHECK_EQUAL( p.filename(), "foo" );
- CHECK_EQUAL( p.root_name(), "\\\\net" );
- CHECK_EQUAL( p.root_directory(), "\\" );
- CHECK_EQUAL( 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("c:/");
+ 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_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");
+ CHECK_EQUAL(p.parent_path().string(), "c:/");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "c:");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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");
+ CHECK_EQUAL(p.parent_path().string(), "c:/");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "c:");
+ CHECK_EQUAL(p.root_directory(), "/");
+ CHECK_EQUAL(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\\bar");
+ CHECK_EQUAL(p.relative_path().string(), "foo\\bar");
+ CHECK_EQUAL(p.parent_path().string(), "c:\\foo");
+ CHECK_EQUAL(p.filename(), "bar");
+ CHECK_EQUAL(p.root_name(), "c:");
+ CHECK_EQUAL(p.root_directory(), "\\");
+ CHECK_EQUAL(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("prn:");
+ 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");
+ CHECK_EQUAL(p.parent_path().string(), "\\\\net\\");
+ CHECK_EQUAL(p.filename(), "foo");
+ CHECK_EQUAL(p.root_name(), "\\\\net");
+ CHECK_EQUAL(p.root_directory(), "\\");
+ CHECK_EQUAL(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());
} // Windows
else
{ // POSIX
- PATH_CHECK( path( "/foo/bar/" ), "/foo/bar/" );
- PATH_CHECK( path( "//foo//bar//" ), "//foo//bar//" );
- PATH_CHECK( path( "///foo///bar///" ), "///foo///bar///" );
+ PATH_CHECK(path("/foo/bar/"), "/foo/bar/");
+ PATH_CHECK(path("//foo//bar//"), "//foo//bar//");
+ PATH_CHECK(path("///foo///bar///"), "///foo///bar///");
- p = path( "/usr/local/bin:/usr/bin:/bin" );
- BOOST_TEST( p.string() == "/usr/local/bin:/usr/bin:/bin" );
+ p = path("/usr/local/bin:/usr/bin:/bin");
+ BOOST_TEST(p.string() == "/usr/local/bin:/usr/bin:/bin");
} // POSIX
}
@@ -1124,142 +1124,142 @@
{
std::cout << "construction_tests..." << std::endl;
- PATH_CHECK( "", "" );
+ PATH_CHECK("", "");
- PATH_CHECK( "foo", "foo" );
- PATH_CHECK( "f", "f" );
+ PATH_CHECK("foo", "foo");
+ PATH_CHECK("f", "f");
- PATH_CHECK( "foo/", "foo/" );
- PATH_CHECK( "f/", "f/" );
- PATH_CHECK( "foo/..", "foo/.." );
- PATH_CHECK( "foo/../", "foo/../" );
- PATH_CHECK( "foo/bar/../..", "foo/bar/../.." );
- PATH_CHECK( "foo/bar/../../", "foo/bar/../../" );
- PATH_CHECK( path( "/" ), "/" );
- PATH_CHECK( path( "/f" ), "/f" );
-
- PATH_CHECK( "/foo", "/foo" );
- PATH_CHECK( path( "/foo/bar/" ), "/foo/bar/" );
- PATH_CHECK( path( "//foo//bar//" ), "//foo//bar//" );
- PATH_CHECK( path( "///foo///bar///" ), "///foo///bar///" );
- PATH_CHECK( path( "\\/foo\\/bar\\/" ), "\\/foo\\/bar\\/" );
- PATH_CHECK( path( "\\//foo\\//bar\\//" ), "\\//foo\\//bar\\//" );
+ PATH_CHECK("foo/", "foo/");
+ PATH_CHECK("f/", "f/");
+ PATH_CHECK("foo/..", "foo/..");
+ PATH_CHECK("foo/../", "foo/../");
+ PATH_CHECK("foo/bar/../..", "foo/bar/../..");
+ PATH_CHECK("foo/bar/../../", "foo/bar/../../");
+ PATH_CHECK(path("/"), "/");
+ PATH_CHECK(path("/f"), "/f");
+
+ PATH_CHECK("/foo", "/foo");
+ PATH_CHECK(path("/foo/bar/"), "/foo/bar/");
+ PATH_CHECK(path("//foo//bar//"), "//foo//bar//");
+ PATH_CHECK(path("///foo///bar///"), "///foo///bar///");
+ PATH_CHECK(path("\\/foo\\/bar\\/"), "\\/foo\\/bar\\/");
+ PATH_CHECK(path("\\//foo\\//bar\\//"), "\\//foo\\//bar\\//");
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
- PATH_CHECK( path("c:") / "foo", "c:foo" );
- PATH_CHECK( path("c:") / "/foo", "c:/foo" );
+ PATH_CHECK(path("c:") / "foo", "c:foo");
+ PATH_CHECK(path("c:") / "/foo", "c:/foo");
- PATH_CHECK( path( "\\foo\\bar\\" ), "\\foo\\bar\\" );
- PATH_CHECK( path( "\\\\foo\\\\bar\\\\" ), "\\\\foo\\\\bar\\\\" );
- PATH_CHECK( path( "\\\\\\foo\\\\\\bar\\\\\\" ), "\\\\\\foo\\\\\\bar\\\\\\" );
-
- PATH_CHECK( path( "\\" ), "\\" );
- PATH_CHECK( path( "\\f" ), "\\f" );
- PATH_CHECK( path( "\\foo" ), "\\foo" );
- PATH_CHECK( path( "foo\\bar" ), "foo\\bar" );
- PATH_CHECK( path( "foo bar" ), "foo bar" );
- PATH_CHECK( path( "c:" ), "c:" );
- PATH_CHECK( path( "c:/" ), "c:/" );
- PATH_CHECK( path( "c:." ), "c:." );
- PATH_CHECK( path( "c:./foo" ), "c:./foo" );
- PATH_CHECK( path( "c:.\\foo" ), "c:.\\foo" );
- PATH_CHECK( path( "c:.." ), "c:.." );
- PATH_CHECK( path( "c:/." ), "c:/." );
- PATH_CHECK( path( "c:/.." ), "c:/.." );
- PATH_CHECK( path( "c:/../" ), "c:/../" );
- PATH_CHECK( path( "c:\\..\\" ), "c:\\..\\" );
- PATH_CHECK( path( "c:/../.." ), "c:/../.." );
- PATH_CHECK( path( "c:/../foo" ), "c:/../foo" );
- PATH_CHECK( path( "c:\\..\\foo" ), "c:\\..\\foo" );
- PATH_CHECK( path( "c:../foo" ), "c:../foo" );
- PATH_CHECK( path( "c:..\\foo" ), "c:..\\foo" );
- PATH_CHECK( path( "c:/../../foo" ), "c:/../../foo" );
- PATH_CHECK( path( "c:\\..\\..\\foo" ), "c:\\..\\..\\foo" );
- PATH_CHECK( path( "c:foo/.." ), "c:foo/.." );
- PATH_CHECK( path( "c:/foo/.." ), "c:/foo/.." );
- PATH_CHECK( path( "c:/..foo" ), "c:/..foo" );
- PATH_CHECK( path( "c:foo" ), "c:foo" );
- PATH_CHECK( path( "c:/foo" ), "c:/foo" );
- PATH_CHECK( path( "\\\\netname" ), "\\\\netname" );
- PATH_CHECK( path( "\\\\netname\\" ), "\\\\netname\\" );
- PATH_CHECK( path( "\\\\netname\\foo" ), "\\\\netname\\foo" );
- PATH_CHECK( path( "c:/foo" ), "c:/foo" );
- PATH_CHECK( path( "prn:" ), "prn:" );
+ PATH_CHECK(path("\\foo\\bar\\"), "\\foo\\bar\\");
+ PATH_CHECK(path("\\\\foo\\\\bar\\\\"), "\\\\foo\\\\bar\\\\");
+ PATH_CHECK(path("\\\\\\foo\\\\\\bar\\\\\\"), "\\\\\\foo\\\\\\bar\\\\\\");
+
+ PATH_CHECK(path("\\"), "\\");
+ PATH_CHECK(path("\\f"), "\\f");
+ PATH_CHECK(path("\\foo"), "\\foo");
+ PATH_CHECK(path("foo\\bar"), "foo\\bar");
+ PATH_CHECK(path("foo bar"), "foo bar");
+ PATH_CHECK(path("c:"), "c:");
+ PATH_CHECK(path("c:/"), "c:/");
+ PATH_CHECK(path("c:."), "c:.");
+ PATH_CHECK(path("c:./foo"), "c:./foo");
+ PATH_CHECK(path("c:.\\foo"), "c:.\\foo");
+ PATH_CHECK(path("c:.."), "c:..");
+ PATH_CHECK(path("c:/."), "c:/.");
+ PATH_CHECK(path("c:/.."), "c:/..");
+ PATH_CHECK(path("c:/../"), "c:/../");
+ PATH_CHECK(path("c:\\..\\"), "c:\\..\\");
+ PATH_CHECK(path("c:/../.."), "c:/../..");
+ PATH_CHECK(path("c:/../foo"), "c:/../foo");
+ PATH_CHECK(path("c:\\..\\foo"), "c:\\..\\foo");
+ PATH_CHECK(path("c:../foo"), "c:../foo");
+ PATH_CHECK(path("c:..\\foo"), "c:..\\foo");
+ PATH_CHECK(path("c:/../../foo"), "c:/../../foo");
+ PATH_CHECK(path("c:\\..\\..\\foo"), "c:\\..\\..\\foo");
+ PATH_CHECK(path("c:foo/.."), "c:foo/..");
+ PATH_CHECK(path("c:/foo/.."), "c:/foo/..");
+ PATH_CHECK(path("c:/..foo"), "c:/..foo");
+ PATH_CHECK(path("c:foo"), "c:foo");
+ PATH_CHECK(path("c:/foo"), "c:/foo");
+ PATH_CHECK(path("\\\\netname"), "\\\\netname");
+ PATH_CHECK(path("\\\\netname\\"), "\\\\netname\\");
+ PATH_CHECK(path("\\\\netname\\foo"), "\\\\netname\\foo");
+ PATH_CHECK(path("c:/foo"), "c:/foo");
+ PATH_CHECK(path("prn:"), "prn:");
}
else
{
}
- PATH_CHECK( "foo/bar", "foo/bar" );
- PATH_CHECK( "a/b", "a/b" ); // probe for length effects
- PATH_CHECK( "..", ".." );
- PATH_CHECK( "../..", "../.." );
- PATH_CHECK( "/..", "/.." );
- PATH_CHECK( "/../..", "/../.." );
- PATH_CHECK( "../foo", "../foo" );
- PATH_CHECK( "foo/..", "foo/.." );
- PATH_CHECK( path( "foo/..bar"), "foo/..bar" );
- PATH_CHECK( "../f", "../f" );
- PATH_CHECK( "/../f", "/../f" );
- PATH_CHECK( "f/..", "f/.." );
- PATH_CHECK( "foo/../..", "foo/../.." );
- PATH_CHECK( "foo/../../..", "foo/../../.." );
- PATH_CHECK( "foo/../bar", "foo/../bar" );
- PATH_CHECK( "foo/bar/..", "foo/bar/.." );
- PATH_CHECK( "foo/bar/../..", "foo/bar/../.." );
- PATH_CHECK( "foo/bar/../blah", "foo/bar/../blah" );
- PATH_CHECK( "f/../b", "f/../b" );
- PATH_CHECK( "f/b/..", "f/b/.." );
- PATH_CHECK( "f/b/../a", "f/b/../a" );
- PATH_CHECK( "foo/bar/blah/../..", "foo/bar/blah/../.." );
- PATH_CHECK( "foo/bar/blah/../../bletch", "foo/bar/blah/../../bletch" );
- PATH_CHECK( "...", "..." );
- PATH_CHECK( "....", "...." );
- PATH_CHECK( "foo/...", "foo/..." );
- PATH_CHECK( "abc.", "abc." );
- PATH_CHECK( "abc..", "abc.." );
- PATH_CHECK( "foo/abc.", "foo/abc." );
- PATH_CHECK( "foo/abc..", "foo/abc.." );
-
- PATH_CHECK( path(".abc"), ".abc" );
- PATH_CHECK( "a.c", "a.c" );
- PATH_CHECK( path("..abc"), "..abc" );
- PATH_CHECK( "a..c", "a..c" );
- PATH_CHECK( path("foo/.abc"), "foo/.abc" );
- PATH_CHECK( "foo/a.c", "foo/a.c" );
- PATH_CHECK( path("foo/..abc"), "foo/..abc" );
- PATH_CHECK( "foo/a..c", "foo/a..c" );
-
- PATH_CHECK( ".", "." );
- PATH_CHECK( "./foo", "./foo" );
- PATH_CHECK( "./..", "./.." );
- PATH_CHECK( "./../foo", "./../foo" );
- PATH_CHECK( "foo/.", "foo/." );
- PATH_CHECK( "../.", "../." );
- PATH_CHECK( "./.", "./." );
- PATH_CHECK( "././.", "././." );
- PATH_CHECK( "./foo/.", "./foo/." );
- PATH_CHECK( "foo/./bar", "foo/./bar" );
- PATH_CHECK( "foo/./.", "foo/./." );
- PATH_CHECK( "foo/./..", "foo/./.." );
- PATH_CHECK( "foo/./../bar", "foo/./../bar" );
- PATH_CHECK( "foo/../.", "foo/../." );
- PATH_CHECK( "././..", "././.." );
- PATH_CHECK( "./../.", "./../." );
- PATH_CHECK( ".././.", ".././." );
+ PATH_CHECK("foo/bar", "foo/bar");
+ PATH_CHECK("a/b", "a/b"); // probe for length effects
+ PATH_CHECK("..", "..");
+ PATH_CHECK("../..", "../..");
+ PATH_CHECK("/..", "/..");
+ PATH_CHECK("/../..", "/../..");
+ PATH_CHECK("../foo", "../foo");
+ PATH_CHECK("foo/..", "foo/..");
+ PATH_CHECK(path("foo/..bar"), "foo/..bar");
+ PATH_CHECK("../f", "../f");
+ PATH_CHECK("/../f", "/../f");
+ PATH_CHECK("f/..", "f/..");
+ PATH_CHECK("foo/../..", "foo/../..");
+ PATH_CHECK("foo/../../..", "foo/../../..");
+ PATH_CHECK("foo/../bar", "foo/../bar");
+ PATH_CHECK("foo/bar/..", "foo/bar/..");
+ PATH_CHECK("foo/bar/../..", "foo/bar/../..");
+ PATH_CHECK("foo/bar/../blah", "foo/bar/../blah");
+ PATH_CHECK("f/../b", "f/../b");
+ PATH_CHECK("f/b/..", "f/b/..");
+ PATH_CHECK("f/b/../a", "f/b/../a");
+ PATH_CHECK("foo/bar/blah/../..", "foo/bar/blah/../..");
+ PATH_CHECK("foo/bar/blah/../../bletch", "foo/bar/blah/../../bletch");
+ PATH_CHECK("...", "...");
+ PATH_CHECK("....", "....");
+ PATH_CHECK("foo/...", "foo/...");
+ PATH_CHECK("abc.", "abc.");
+ PATH_CHECK("abc..", "abc..");
+ PATH_CHECK("foo/abc.", "foo/abc.");
+ PATH_CHECK("foo/abc..", "foo/abc..");
+
+ PATH_CHECK(path(".abc"), ".abc");
+ PATH_CHECK("a.c", "a.c");
+ PATH_CHECK(path("..abc"), "..abc");
+ PATH_CHECK("a..c", "a..c");
+ PATH_CHECK(path("foo/.abc"), "foo/.abc");
+ PATH_CHECK("foo/a.c", "foo/a.c");
+ PATH_CHECK(path("foo/..abc"), "foo/..abc");
+ PATH_CHECK("foo/a..c", "foo/a..c");
+
+ PATH_CHECK(".", ".");
+ PATH_CHECK("./foo", "./foo");
+ PATH_CHECK("./..", "./..");
+ PATH_CHECK("./../foo", "./../foo");
+ PATH_CHECK("foo/.", "foo/.");
+ PATH_CHECK("../.", "../.");
+ PATH_CHECK("./.", "./.");
+ PATH_CHECK("././.", "././.");
+ PATH_CHECK("./foo/.", "./foo/.");
+ PATH_CHECK("foo/./bar", "foo/./bar");
+ PATH_CHECK("foo/./.", "foo/./.");
+ PATH_CHECK("foo/./..", "foo/./..");
+ PATH_CHECK("foo/./../bar", "foo/./../bar");
+ PATH_CHECK("foo/../.", "foo/../.");
+ PATH_CHECK("././..", "././..");
+ PATH_CHECK("./../.", "./../.");
+ PATH_CHECK(".././.", ".././.");
}
// append_tests --------------------------------------------------------------------//
- void append_test_aux( const path & p, const std::string & s, const std::string & expect )
+ void append_test_aux(const path & p, const std::string & s, const std::string & expect)
{
- PATH_CHECK( p / path(s), expect );
- PATH_CHECK( p / s.c_str(), expect );
- PATH_CHECK( p / s, expect );
+ PATH_CHECK(p / path(s), expect);
+ PATH_CHECK(p / s.c_str(), expect);
+ PATH_CHECK(p / s, expect);
path x(p);
- x.append( s.begin(), s.end() );
- PATH_CHECK( x, expect );
+ x.append(s.begin(), s.end());
+ PATH_CHECK(x, expect);
}
void append_tests()
@@ -1277,76 +1277,76 @@
//// expected results must be checked by hand
//// "foo\bar" expected result must be edited by hand and moved for Windows/POSIX
////
- //const char * x[] = { "", "/", "foo", "foo/" };
- //const char * y[] = { "", "/", "bar", "/bar" };
+ //const char* x[] = { "", "/", "foo", "foo/" };
+ //const char* y[] = { "", "/", "bar", "/bar" };
- //for ( int i = 0; i < sizeof(x)/sizeof(char*); ++i )
- // for ( int j = 0; j < sizeof(y)/sizeof(char*); ++j )
+ //for (int i = 0; i < sizeof(x)/sizeof(char*); ++i)
+ // for (int j = 0; j < sizeof(y)/sizeof(char*); ++j)
// {
- // std::cout << "\n PATH_CHECK( path(\"" << x[i] << "\") / \"" << y[j] << "\", \""
- // << path(x[i]) / y[j] << "\" );\n";
- // std::cout << " append_test_aux( \"" << x[i] << "\", \"" << y[j] << "\", \""
+ // std::cout << "\n PATH_CHECK(path(\"" << x[i] << "\") / \"" << y[j] << "\", \""
+ // << path(x[i]) / y[j] << "\");\n";
+ // std::cout << " append_test_aux(\"" << x[i] << "\", \"" << y[j] << "\", \""
// << path(x[i]) / y[j] << "\");\n";
// }
- PATH_CHECK( path("") / "", "" );
- append_test_aux( "", "", "");
+ PATH_CHECK(path("") / "", "");
+ append_test_aux("", "", "");
- PATH_CHECK( path("") / "/", "/" );
- append_test_aux( "", "/", "/");
+ PATH_CHECK(path("") / "/", "/");
+ append_test_aux("", "/", "/");
- PATH_CHECK( path("") / "bar", "bar" );
- append_test_aux( "", "bar", "bar");
+ PATH_CHECK(path("") / "bar", "bar");
+ append_test_aux("", "bar", "bar");
- PATH_CHECK( path("") / "/bar", "/bar" );
- append_test_aux( "", "/bar", "/bar");
+ PATH_CHECK(path("") / "/bar", "/bar");
+ append_test_aux("", "/bar", "/bar");
- PATH_CHECK( path("/") / "", "/" );
- append_test_aux( "/", "", "/");
+ PATH_CHECK(path("/") / "", "/");
+ append_test_aux("/", "", "/");
- PATH_CHECK( path("/") / "/", "//" );
- append_test_aux( "/", "/", "//");
+ PATH_CHECK(path("/") / "/", "//");
+ append_test_aux("/", "/", "//");
- PATH_CHECK( path("/") / "bar", "/bar" );
- append_test_aux( "/", "bar", "/bar");
+ PATH_CHECK(path("/") / "bar", "/bar");
+ append_test_aux("/", "bar", "/bar");
- PATH_CHECK( path("/") / "/bar", "//bar" );
- append_test_aux( "/", "/bar", "//bar");
+ PATH_CHECK(path("/") / "/bar", "//bar");
+ append_test_aux("/", "/bar", "//bar");
- PATH_CHECK( path("foo") / "", "foo" );
- append_test_aux( "foo", "", "foo");
+ PATH_CHECK(path("foo") / "", "foo");
+ append_test_aux("foo", "", "foo");
- PATH_CHECK( path("foo") / "/", "foo/" );
- append_test_aux( "foo", "/", "foo/");
+ PATH_CHECK(path("foo") / "/", "foo/");
+ append_test_aux("foo", "/", "foo/");
- PATH_CHECK( path("foo") / "/bar", "foo/bar" );
- append_test_aux( "foo", "/bar", "foo/bar");
+ PATH_CHECK(path("foo") / "/bar", "foo/bar");
+ append_test_aux("foo", "/bar", "foo/bar");
- PATH_CHECK( path("foo/") / "", "foo/" );
- append_test_aux( "foo/", "", "foo/");
+ PATH_CHECK(path("foo/") / "", "foo/");
+ append_test_aux("foo/", "", "foo/");
- PATH_CHECK( path("foo/") / "/", "foo//" );
- append_test_aux( "foo/", "/", "foo//");
+ PATH_CHECK(path("foo/") / "/", "foo//");
+ append_test_aux("foo/", "/", "foo//");
- PATH_CHECK( path("foo/") / "bar", "foo/bar" );
- append_test_aux( "foo/", "bar", "foo/bar");
+ PATH_CHECK(path("foo/") / "bar", "foo/bar");
+ append_test_aux("foo/", "bar", "foo/bar");
- PATH_CHECK( path("foo/") / "/bar", "foo//bar" );
- append_test_aux( "foo/", "/bar", "foo//bar");
+ PATH_CHECK(path("foo/") / "/bar", "foo//bar");
+ append_test_aux("foo/", "/bar", "foo//bar");
- if ( platform == "Windows" )
+ if (platform == "Windows")
{
- PATH_CHECK( path("foo") / "bar", "foo\\bar" );
- append_test_aux( "foo", "bar", "foo\\bar");
+ PATH_CHECK(path("foo") / "bar", "foo\\bar");
+ append_test_aux("foo", "bar", "foo\\bar");
// hand created test case specific to Windows
- PATH_CHECK( path("c:") / "bar", "c:bar" );
- append_test_aux( "c:", "bar", "c:bar" );
+ PATH_CHECK(path("c:") / "bar", "c:bar");
+ append_test_aux("c:", "bar", "c:bar");
}
else
{
- PATH_CHECK( path("foo") / "bar", "foo/bar" );
- append_test_aux( "foo", "bar", "foo/bar");
+ PATH_CHECK(path("foo") / "bar", "foo/bar");
+ append_test_aux("foo", "bar", "foo/bar");
}
}
@@ -1357,81 +1357,81 @@
{
std::cout << "name_function_tests..." << std::endl;
- 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." ) ) );
+ 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 ---------------------------------------------------//
@@ -1440,12 +1440,12 @@
{
std::cout << "stem_tests..." << std::endl;
- 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() == "" );
+ 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 ---------------------------------------------------//
@@ -1454,13 +1454,13 @@
{
std::cout << "extension_tests..." << std::endl;
- 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() == "." );
+ 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 ---------------------------------------------------//
@@ -1469,24 +1469,24 @@
{
std::cout << "replace_extension_tests..." << std::endl;
- 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" );
+ 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_TEST( path().replace_extension(".txt") == ".txt" );
+ BOOST_TEST(path().replace_extension(".txt") == ".txt");
- 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" );
+ 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
@@ -1497,24 +1497,24 @@
// //
//--------------------------------------------------------------------------------------//
-int 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
// only the current platform is runtime tested.
- platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" )
+ platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin")
? "Windows"
: "POSIX";
std::cout << "Platform is " << platform << '\n';
- BOOST_TEST( p1.string() != p3.string() );
+ BOOST_TEST(p1.string() != p3.string());
p3 = p2;
- BOOST_TEST( p1.string() == p3.string() );
+ BOOST_TEST(p1.string() == p3.string());
- path p4( "foobar" );
- BOOST_TEST( p4.string() == "foobar" );
+ path p4("foobar");
+ BOOST_TEST(p4.string() == "foobar");
p4 = p4; // self-assignment
- BOOST_TEST( p4.string() == "foobar" );
+ BOOST_TEST(p4.string() == "foobar");
construction_tests();
append_tests();
@@ -1539,42 +1539,42 @@
# endif
- std::string s1( "//:somestring" ); // this used to be treated specially
+ std::string s1("//:somestring"); // this used to be treated specially
// check the path member templates
- p5.assign( s1.begin(), s1.end() );
+ p5.assign(s1.begin(), s1.end());
- PATH_CHECK( p5, "//:somestring" );
+ PATH_CHECK(p5, "//:somestring");
p5 = s1;
- PATH_CHECK( p5, "//:somestring" );
+ PATH_CHECK(p5, "//:somestring");
// this code, courtesy of David Whetstone, detects a now fixed bug that
// derefereced the end iterator (assuming debug build with checked itors)
std::vector<char> v1;
- p5.assign( v1.begin(), v1.end() );
- std::string s2( v1.begin(), v1.end() );
- PATH_CHECK( p5, s2 );
- p5.assign( s1.begin(), s1.begin() + 1 );
- PATH_CHECK( p5, "/" );
-
- 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 );
+ p5.assign(v1.begin(), v1.end());
+ std::string s2(v1.begin(), v1.end());
+ PATH_CHECK(p5, s2);
+ p5.assign(s1.begin(), s1.begin() + 1);
+ PATH_CHECK(p5, "/");
+
+ 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
+# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // bypass VC++ 7.0 and earlier
std::cout << "\nInserter and extractor test...";
std::stringstream ss;
- ss << fs::path( "foo/bar" ) << std::endl;
+ ss << fs::path("foo/bar") << std::endl;
fs::path round_trip;
ss >> round_trip;
- BOOST_TEST( round_trip.string() == "foo/bar" );
+ BOOST_TEST(round_trip.string() == "foo/bar");
std::cout << round_trip.string() << "..." << round_trip << " complete\n";
# endif
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-11-06 12:04:02 EST (Fri, 06 Nov 2009)
@@ -35,9 +35,14 @@
using std::string;
using std::wstring;
-#define CHECK(x) check( x, __FILE__, __LINE__ )
-#define PATH_IS( a, b ) check_path( a, b, __FILE__, __LINE__ )
-#define IS( a,b ) check_equal( a, b, __FILE__, __LINE__ )
+#define CHECK(x) check(x, __FILE__, __LINE__)
+#define PATH_IS(a, b) check_path(a, b, __FILE__, __LINE__)
+#define IS(a,b) check_equal(a, b, __FILE__, __LINE__)
+
+#if defined(_MSC_VER)
+# pragma warning(push) // Save warning settings.
+# pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
+#endif
namespace
{
@@ -46,12 +51,12 @@
const boost::system::error_code ok;
const boost::system::error_code ng(-1, boost::system::system_category);
- std::string platform( BOOST_PLATFORM );
+ std::string platform(BOOST_PLATFORM);
- void check_path( const path & source,
- const wstring & expected, const char* file, int line )
+ void check_path(const path & source,
+ const wstring & expected, const char* file, int line)
{
- if ( source == expected ) return;
+ if (source == expected) return;
++::boost::detail::test_errors();
@@ -63,10 +68,10 @@
}
template< class T1, class T2 >
- void check_equal( const T1 & value,
- const T2 & expected, const char* file, int line )
+ void check_equal(const T1 & value,
+ const T2 & expected, const char* file, int line)
{
- if ( value == expected ) return;
+ if (value == expected) return;
++::boost::detail::test_errors();
@@ -77,9 +82,9 @@
<< L"\"\n" ;
}
- void check( bool ok, const char* file, int line )
+ void check(bool ok, const char* file, int line)
{
- if ( ok ) return;
+ if (ok) return;
++::boost::detail::test_errors();
@@ -97,43 +102,43 @@
path x0; // default constructor
PATH_IS(x0, L"");
- BOOST_TEST_EQ( x0.native().size(), 0 );
+ BOOST_TEST_EQ(x0.native().size(), 0U);
path x1(s.begin(), s.end()); // iterator range char
PATH_IS(x1, L"string");
- BOOST_TEST_EQ( x1.native().size(), 6 );
+ BOOST_TEST_EQ(x1.native().size(), 6U);
path x2(x1); // copy constructor
PATH_IS(x2, L"string");
- BOOST_TEST_EQ( x2.native().size(), 6 );
+ BOOST_TEST_EQ(x2.native().size(), 6U);
path x3(ws.begin(), ws.end()); // iterator range wchar_t
PATH_IS(x3, L"wstring");
- BOOST_TEST_EQ( x3.native().size(), 7 );
+ BOOST_TEST_EQ(x3.native().size(), 7U);
path x4(string("std::string")); // container char
PATH_IS(x4, L"std::string");
- BOOST_TEST_EQ( x4.native().size(), 11 );
+ BOOST_TEST_EQ(x4.native().size(), 11U);
path x5(wstring(L"std::wstring")); // container wchar_t
PATH_IS(x5, L"std::wstring");
- BOOST_TEST_EQ( x5.native().size(), 12 );
+ BOOST_TEST_EQ(x5.native().size(), 12U);
path x6("array char"); // array char
PATH_IS(x6, L"array char");
- BOOST_TEST_EQ( x6.native().size(), 10 );
+ BOOST_TEST_EQ(x6.native().size(), 10U);
path x7(L"array wchar_t"); // array wchar_t
PATH_IS(x7, L"array wchar_t");
- BOOST_TEST_EQ( x7.native().size(), 13 );
+ BOOST_TEST_EQ(x7.native().size(), 13U);
- path x8( s.c_str() ); // const char * null terminated
+ path x8(s.c_str()); // const char* null terminated
PATH_IS(x8, L"string");
- BOOST_TEST_EQ( x8.native().size(), 6 );
+ BOOST_TEST_EQ(x8.native().size(), 6U);
- path x9( ws.c_str() ); // const wchar_t * null terminated
+ path x9(ws.c_str()); // const wchar_t* null terminated
PATH_IS(x9, L"wstring");
- BOOST_TEST_EQ( x9.native().size(), 7 );
+ BOOST_TEST_EQ(x9.native().size(), 7U);
}
path x;
@@ -147,11 +152,11 @@
x = path("yet another path"); // another path
PATH_IS(x, L"yet another path");
- BOOST_TEST_EQ( x.native().size(), 16 );
+ BOOST_TEST_EQ(x.native().size(), 16U);
x = x; // self-assignment
PATH_IS(x, L"yet another path");
- BOOST_TEST_EQ( x.native().size(), 16 );
+ BOOST_TEST_EQ(x.native().size(), 16U);
x.assign(s.begin(), s.end()); // iterator range char
PATH_IS(x, L"string");
@@ -171,10 +176,10 @@
x = L"array wchar"; // array wchar_t
PATH_IS(x, L"array wchar");
- x = s.c_str(); // const char * null terminated
+ x = s.c_str(); // const char* null terminated
PATH_IS(x, L"string");
- x = ws.c_str(); // const wchar_t * null terminated
+ x = ws.c_str(); // const wchar_t* null terminated
PATH_IS(x, L"wstring");
}
@@ -235,11 +240,11 @@
PATH_IS(x, BOOST_FS_FOO L"array wchar");
x = "/foo";
- x /= s.c_str(); // const char * null terminated
+ 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
+ x /= ws.c_str(); // const wchar_t* null terminated
PATH_IS(x, BOOST_FS_FOO L"wstring");
}
@@ -249,43 +254,43 @@
{
std::cout << "testing observers..." << std::endl;
- path p0( "abc" );
+ path p0("abc");
- CHECK( p0.native().size() == 3 );
- CHECK( p0.native_string() == "abc" );
- CHECK( p0.native_string().size() == 3 );
- CHECK( p0.native_wstring() == L"abc" );
- CHECK( p0.native_wstring().size() == 3 );
+ CHECK(p0.native().size() == 3);
+ CHECK(p0.native_string() == "abc");
+ CHECK(p0.native_string().size() == 3);
+ CHECK(p0.native_wstring() == L"abc");
+ CHECK(p0.native_wstring().size() == 3);
# ifdef BOOST_WINDOWS_PATH
- path p( "abc\\def/ghi" );
+ path p("abc\\def/ghi");
- CHECK( std::wstring( p.c_str() ) == L"abc\\def/ghi" );
+ CHECK(std::wstring(p.c_str()) == L"abc\\def/ghi");
- CHECK( p.native_string() == "abc\\def/ghi" );
- CHECK( p.native_wstring() == L"abc\\def/ghi" );
+ CHECK(p.native_string() == "abc\\def/ghi");
+ CHECK(p.native_wstring() == L"abc\\def/ghi");
- CHECK( p.string() == "abc/def/ghi" );
- CHECK( p.wstring() == L"abc/def/ghi" );
+ CHECK(p.string() == "abc/def/ghi");
+ CHECK(p.wstring() == L"abc/def/ghi");
- //CHECK( p.preferred().string() == "abc\\def\\ghi" );
- //CHECK( p.preferred().wstring() == L"abc\\def\\ghi" );
+ //CHECK(p.preferred().string() == "abc\\def\\ghi");
+ //CHECK(p.preferred().wstring() == L"abc\\def\\ghi");
# else // BOOST_POSIX_PATH
- path p( "abc\\def/ghi" );
+ path p("abc\\def/ghi");
- CHECK( string( p.c_str() ) == "abc\\def/ghi" );
+ CHECK(string(p.c_str()) == "abc\\def/ghi");
- CHECK( p.native_string() == "abc\\def/ghi" );
- CHECK( p.native_wstring() == L"abc\\def/ghi" );
+ CHECK(p.native_string() == "abc\\def/ghi");
+ CHECK(p.native_wstring() == L"abc\\def/ghi");
- CHECK( p.string() == "abc\\def/ghi" );
- CHECK( p.wstring() == L"abc\\def/ghi" );
+ CHECK(p.string() == "abc\\def/ghi");
+ CHECK(p.wstring() == L"abc\\def/ghi");
- //CHECK( p.preferred().string() == "abc\\def/ghi" );
- //CHECK( p.preferred().wstring() == L"abc\\def/ghi" );
+ //CHECK(p.preferred().string() == "abc\\def/ghi");
+ //CHECK(p.preferred().wstring() == L"abc\\def/ghi");
# endif
}
@@ -298,51 +303,51 @@
# ifdef BOOST_WINDOWS_API
// this is a critical use case to meet user expectations
- CHECK( path( "c:\\abc" ) == path( "c:/abc" ) );
+ CHECK(path("c:\\abc") == path("c:/abc"));
# endif
- const path p( "bar" );
- const path p2( "baz" );
+ const path p("bar");
+ const path p2("baz");
- CHECK( !(p < p) );
- CHECK( p < p2 );
- CHECK( !(p2 < p) );
- CHECK( p < "baz" );
- CHECK( p < string("baz") );
- CHECK( p < L"baz" );
- CHECK( p < wstring(L"baz") );
- CHECK( !("baz" < p) );
- CHECK( !(string("baz") < p) );
- CHECK( !(L"baz" < p) );
- CHECK( !(wstring(L"baz") < p) );
-
- CHECK( p == p );
- CHECK( !(p == p2) );
- CHECK( !(p2 == p) );
- CHECK( p2 == "baz" );
- CHECK( p2 == string("baz") );
- CHECK( p2 == L"baz" );
- CHECK( p2 == wstring(L"baz") );
- CHECK( "baz" == p2 );
- CHECK( string("baz") == p2 );
- CHECK( L"baz" == p2 );
- CHECK( wstring(L"baz") == p2 );
-
- CHECK( !(p != p) );
- CHECK( p != p2 );
- CHECK( p2 != p );
-
- CHECK( p <= p );
- CHECK( p <= p2 );
- CHECK( !(p2 <= p) );
-
- CHECK( !(p > p) );
- CHECK( !(p > p2) );
- CHECK( p2 > p );
-
- CHECK( p >= p );
- CHECK( !(p >= p2) );
- CHECK( p2 >= p );
+ CHECK(!(p < p));
+ CHECK(p < p2);
+ CHECK(!(p2 < p));
+ CHECK(p < "baz");
+ CHECK(p < string("baz"));
+ CHECK(p < L"baz");
+ CHECK(p < wstring(L"baz"));
+ CHECK(!("baz" < p));
+ CHECK(!(string("baz") < p));
+ CHECK(!(L"baz" < p));
+ CHECK(!(wstring(L"baz") < p));
+
+ CHECK(p == p);
+ CHECK(!(p == p2));
+ CHECK(!(p2 == p));
+ CHECK(p2 == "baz");
+ CHECK(p2 == string("baz"));
+ CHECK(p2 == L"baz");
+ CHECK(p2 == wstring(L"baz"));
+ CHECK("baz" == p2);
+ CHECK(string("baz") == p2);
+ CHECK(L"baz" == p2);
+ CHECK(wstring(L"baz") == p2);
+
+ CHECK(!(p != p));
+ CHECK(p != p2);
+ CHECK(p2 != p);
+
+ CHECK(p <= p);
+ CHECK(p <= p2);
+ CHECK(!(p2 <= p));
+
+ CHECK(!(p > p));
+ CHECK(!(p > p2));
+ CHECK(p2 > p);
+
+ CHECK(p >= p);
+ CHECK(!(p >= p2));
+ CHECK(p2 >= p);
}
// test_inserter_and_extractor -----------------------------------------------------//
@@ -356,10 +361,10 @@
std::stringstream ss;
- CHECK( p1 != p2 );
+ CHECK(p1 != p2);
ss << p1;
ss >> p2;
- CHECK( p1 == p2 );
+ CHECK(p1 == p2);
}
// test_other_non_members ----------------------------------------------------------//
@@ -373,24 +378,24 @@
// operator /
- CHECK( p1 / p2 == path( "foo/bar" ).localize() );
- CHECK( "foo" / p2 == path( "foo/bar" ).localize() );
- CHECK( L"foo" / p2 == path( "foo/bar" ).localize() );
- CHECK( string( "foo" ) / p2 == path( "foo/bar" ).localize() );
- CHECK( wstring( L"foo" ) / p2 == path( "foo/bar" ).localize() );
- CHECK( p1 / "bar" == path( "foo/bar" ).localize() );
- CHECK( p1 / L"bar" == path( "foo/bar" ).localize() );
- CHECK( p1 / string( "bar" ) == path( "foo/bar" ).localize() );
- CHECK( p1 / wstring( L"bar" ) == path( "foo/bar" ).localize() );
-
- swap( p1, p2 );
-
- CHECK( p1 == "bar" );
- CHECK( p2 == "foo" );
-
- CHECK( path( "" ).remove_filename() == "" );
- CHECK( path( "foo" ).remove_filename() == "" );
- CHECK( path( "foo/bar" ).remove_filename() == "foo/" );
+ CHECK(p1 / p2 == path("foo/bar").localize());
+ CHECK("foo" / p2 == path("foo/bar").localize());
+ CHECK(L"foo" / p2 == path("foo/bar").localize());
+ CHECK(string("foo") / p2 == path("foo/bar").localize());
+ CHECK(wstring(L"foo") / p2 == path("foo/bar").localize());
+ CHECK(p1 / "bar" == path("foo/bar").localize());
+ CHECK(p1 / L"bar" == path("foo/bar").localize());
+ CHECK(p1 / string("bar") == path("foo/bar").localize());
+ CHECK(p1 / wstring(L"bar") == path("foo/bar").localize());
+
+ swap(p1, p2);
+
+ CHECK(p1 == "bar");
+ CHECK(p2 == "foo");
+
+ CHECK(path("").remove_filename() == "");
+ CHECK(path("foo").remove_filename() == "");
+ CHECK(path("foo/bar").remove_filename() == "foo/");
}
@@ -409,25 +414,25 @@
std::cout << "testing iterators..." << std::endl;
path p1;
- CHECK( p1.begin() == p1.end() );
+ CHECK(p1.begin() == p1.end());
path p2("/");
- CHECK( p2.begin() != p2.end() );
- CHECK( *p2.begin() == "/" );
- CHECK( ++p2.begin() == p2.end() );
+ CHECK(p2.begin() != p2.end());
+ CHECK(*p2.begin() == "/");
+ CHECK(++p2.begin() == p2.end());
path p3("foo/bar/baz");
path::iterator it(p3.begin());
- CHECK( p3.begin() != p3.end() );
- CHECK( *it == "foo" );
- CHECK( *++it == "bar" );
- CHECK( *++it == "baz" );
- CHECK( *--it == "bar" );
- CHECK( *--it == "foo" );
- CHECK( *++it == "bar" );
- CHECK( *++it == "baz" );
- CHECK( ++it == p3.end() );
+ CHECK(p3.begin() != p3.end());
+ CHECK(*it == "foo");
+ CHECK(*++it == "bar");
+ CHECK(*++it == "baz");
+ CHECK(*--it == "bar");
+ CHECK(*--it == "foo");
+ CHECK(*++it == "bar");
+ CHECK(*++it == "baz");
+ CHECK(++it == p3.end());
}
@@ -437,46 +442,46 @@
{
std::cout << "testing decompositions..." << std::endl;
- CHECK( path("").root_name().string() == "" );
- CHECK( path("foo").root_name().string() == "" );
- CHECK( path("/").root_name().string() == "" );
- CHECK( path("/foo").root_name().string() == "" );
- CHECK( path("//netname").root_name().string() == "//netname" );
- CHECK( path("//netname/foo").root_name().string() == "//netname" );
-
- CHECK( path("").root_directory().string() == "" );
- CHECK( path("foo").root_directory().string() == "" );
- CHECK( path("/").root_directory().string() == "/" );
- CHECK( path("/foo").root_directory().string() == "/" );
- CHECK( path("//netname").root_directory().string() == "" );
- CHECK( path("//netname/foo").root_directory().string() == "/" );
-
- CHECK( path("").root_path().string() == "" );
- CHECK( path("/").root_path().string() == "/" );
- CHECK( path("/foo").root_path().string() == "/" );
- CHECK( path("//netname").root_path().string() == "//netname" );
- CHECK( path("//netname/foo").root_path().string() == "//netname/" );
+ CHECK(path("").root_name().string() == "");
+ CHECK(path("foo").root_name().string() == "");
+ CHECK(path("/").root_name().string() == "");
+ CHECK(path("/foo").root_name().string() == "");
+ CHECK(path("//netname").root_name().string() == "//netname");
+ CHECK(path("//netname/foo").root_name().string() == "//netname");
+
+ CHECK(path("").root_directory().string() == "");
+ CHECK(path("foo").root_directory().string() == "");
+ CHECK(path("/").root_directory().string() == "/");
+ CHECK(path("/foo").root_directory().string() == "/");
+ CHECK(path("//netname").root_directory().string() == "");
+ CHECK(path("//netname/foo").root_directory().string() == "/");
+
+ CHECK(path("").root_path().string() == "");
+ CHECK(path("/").root_path().string() == "/");
+ CHECK(path("/foo").root_path().string() == "/");
+ CHECK(path("//netname").root_path().string() == "//netname");
+ CHECK(path("//netname/foo").root_path().string() == "//netname/");
# ifdef BOOST_WINDOWS_API
- CHECK( path("c:/foo").root_path().string() == "c:/" );
+ CHECK(path("c:/foo").root_path().string() == "c:/");
# endif
- CHECK( path("").relative_path().string() == "" );
- CHECK( path("/").relative_path().string() == "" );
- CHECK( path("/foo").relative_path().string() == "foo" );
-
- CHECK( path("").parent_path().string() == "" );
- CHECK( path("/").parent_path().string() == "" );
- CHECK( path("/foo").parent_path().string() == "/" );
- CHECK( path("/foo/bar").parent_path().string() == "/foo" );
+ CHECK(path("").relative_path().string() == "");
+ CHECK(path("/").relative_path().string() == "");
+ CHECK(path("/foo").relative_path().string() == "foo");
+
+ CHECK(path("").parent_path().string() == "");
+ CHECK(path("/").parent_path().string() == "");
+ CHECK(path("/foo").parent_path().string() == "/");
+ CHECK(path("/foo/bar").parent_path().string() == "/foo");
- CHECK( path("/foo/bar/baz.zoo").filename().string() == "baz.zoo" );
+ CHECK(path("/foo/bar/baz.zoo").filename().string() == "baz.zoo");
- CHECK( path("/foo/bar/baz.zoo").stem().string() == "baz" );
- CHECK( path("/foo/bar.woo/baz").stem().string() == "baz" );
+ CHECK(path("/foo/bar/baz.zoo").stem().string() == "baz");
+ CHECK(path("/foo/bar.woo/baz").stem().string() == "baz");
- CHECK( path("/foo/bar/baz.zoo").extension().string() == ".zoo" );
- CHECK( path("/foo/bar.woo/baz").extension().string() == "" );
+ CHECK(path("/foo/bar/baz.zoo").extension().string() == ".zoo");
+ CHECK(path("/foo/bar.woo/baz").extension().string() == "");
}
// test_queries --------------------------------------------------------------------//
@@ -485,26 +490,26 @@
{
std::cout << "testing queries..." << std::endl;
- path p1( "" );
- path p2( "//netname/foo" );
+ path p1("");
+ path p2("//netname/foo");
- CHECK( p1.empty() );
- CHECK( !p1.has_root_path() );
- CHECK( !p1.has_root_name() );
- CHECK( !p1.has_root_directory() );
- CHECK( !p1.has_relative_path() );
- CHECK( !p1.has_parent_path() );
- CHECK( !p1.has_filename() );
- CHECK( !p1.is_complete() );
-
- CHECK( !p2.empty() );
- CHECK( p2.has_root_path() );
- CHECK( p2.has_root_name() );
- CHECK( p2.has_root_directory() );
- CHECK( p2.has_relative_path() );
- CHECK( p2.has_parent_path() );
- CHECK( p2.has_filename() );
- CHECK( p2.is_complete() );
+ CHECK(p1.empty());
+ CHECK(!p1.has_root_path());
+ CHECK(!p1.has_root_name());
+ CHECK(!p1.has_root_directory());
+ CHECK(!p1.has_relative_path());
+ CHECK(!p1.has_parent_path());
+ CHECK(!p1.has_filename());
+ CHECK(!p1.is_complete());
+
+ CHECK(!p2.empty());
+ CHECK(p2.has_root_path());
+ CHECK(p2.has_root_name());
+ CHECK(p2.has_root_directory());
+ CHECK(p2.has_relative_path());
+ CHECK(p2.has_parent_path());
+ CHECK(p2.has_filename());
+ CHECK(p2.is_complete());
}
@@ -517,41 +522,41 @@
// \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 path_traits::convert
+ path p0(L"\u2722"); // for tests that depend on path_traits::convert
# ifdef BOOST_WINDOWS_PATH
- CHECK( p0.string() != "\xE2\x9C\xA2" );
+ CHECK(p0.string() != "\xE2\x9C\xA2");
# endif
- string p0_string( p0.string() );
+ string p0_string(p0.string());
std::cout << " testing p1 ..." << std::endl;
- path p1( "\xE2\x9C\xA2" );
+ path p1("\xE2\x9C\xA2");
# ifdef BOOST_WINDOWS_PATH
- CHECK( p1 != L"\u2722" );
+ CHECK(p1 != L"\u2722");
# endif
- wstring p1_wstring( p1.wstring() );
+ wstring p1_wstring(p1.wstring());
// 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 );
+ std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
std::cout << " imbuing locale ..." << std::endl;
- std::locale old_loc = path::imbue( loc );
+ std::locale old_loc = path::imbue(loc);
std::cout << " testing with the imbued locale ..." << std::endl;
- CHECK( p0.string() == "\xE2\x9C\xA2" );
- path p2( "\xE2\x9C\xA2" );
- CHECK( p2 == L"\u2722" );
- CHECK( p2.wstring() == L"\u2722" );
+ CHECK(p0.string() == "\xE2\x9C\xA2");
+ path p2("\xE2\x9C\xA2");
+ CHECK(p2 == L"\u2722");
+ CHECK(p2.wstring() == L"\u2722");
std::cout << " imbuing the original locale ..." << std::endl;
- path::imbue( old_loc );
+ path::imbue(old_loc);
std::cout << " testing with the original locale ..." << std::endl;
- CHECK( p0.string() == p0_string );
- path p3( "\xE2\x9C\xA2" );
+ CHECK(p0.string() == p0_string);
+ path p3("\xE2\x9C\xA2");
# ifdef BOOST_WINDOWS_PATH
- CHECK( p3 != L"\u2722" );
+ CHECK(p3 != L"\u2722");
# endif
- CHECK( p3.wstring() == p1_wstring );
+ CHECK(p3.wstring() == p1_wstring);
std::cout << " locale testing complete" << std::endl;
}
@@ -563,17 +568,17 @@
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" );
+ 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" );
+ path wp1(ws);
+ path wp2(ws.c_str());
+ path wp3(wa);
+ path wp4(L"foo");
}
// test_error_handling -------------------------------------------------------------//
@@ -589,32 +594,32 @@
virtual bool do_always_noconv() const throw() { return false; }
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_in(std::mbstate_t&,
+ const char*, const char*, const char*&,
+ wchar_t*, wchar_t*, wchar_t*&) const
{
static std::codecvt_base::result result = std::codecvt_base::noconv;
- if ( result == std::codecvt_base::partial ) result = std::codecvt_base::error;
- else if ( result == std::codecvt_base::error ) result = std::codecvt_base::noconv;
- else if ( result == std::codecvt_base::noconv ) result = std::codecvt_base::partial;
+ if (result == std::codecvt_base::partial) result = std::codecvt_base::error;
+ else if (result == std::codecvt_base::error) result = std::codecvt_base::noconv;
+ else if (result == std::codecvt_base::noconv) result = std::codecvt_base::partial;
return result;
}
- 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_out(std::mbstate_t &,
+ const wchar_t*, const wchar_t*, const wchar_t*&,
+ char*, char*, char*&) const
{
static std::codecvt_base::result result = std::codecvt_base::noconv;
- if ( result == std::codecvt_base::partial ) result = std::codecvt_base::error;
- else if ( result == std::codecvt_base::error ) result = std::codecvt_base::noconv;
- else if ( result == std::codecvt_base::noconv ) result = std::codecvt_base::partial;
+ if (result == std::codecvt_base::partial) result = std::codecvt_base::error;
+ else if (result == std::codecvt_base::error) result = std::codecvt_base::noconv;
+ else if (result == std::codecvt_base::noconv) result = std::codecvt_base::partial;
return result;
}
- 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 std::codecvt_base::result do_unshift(std::mbstate_t&,
+ char*, char*, char* &) const { return ok; }
+ virtual int do_length(std::mbstate_t &,
+ const char*, const char*, std::size_t) const { return 0; }
virtual int do_max_length() const throw () { return 0; }
};
@@ -623,9 +628,9 @@
std::cout << "testing error handling..." << std::endl;
std::locale global_loc = std::locale();
- std::locale loc( global_loc, new error_codecvt );
+ std::locale loc(global_loc, new error_codecvt);
std::cout << " imbuing error locale ..." << std::endl;
- std::locale old_loc = path::imbue( loc );
+ std::locale old_loc = path::imbue(loc);
# ifdef BOOST_WINDOWS_PATH
# define STRING_FOO_
@@ -635,39 +640,39 @@
{
bool exception_thrown (false);
- try { path( STRING_FOO_"foo" ); }
- catch ( const bs::system_error & ex )
+ try { path(STRING_FOO_"foo"); }
+ catch (const bs::system_error & ex)
{
exception_thrown = true;
- BOOST_TEST_EQ( ex.code(), bs::error_code( std::codecvt_base::partial, fs::codecvt_error_category() ) );
+ BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial, fs::codecvt_error_category()));
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
}
{
bool exception_thrown (false);
- try { path( STRING_FOO_"foo" ); }
- catch ( const bs::system_error & ex )
+ try { path(STRING_FOO_"foo"); }
+ catch (const bs::system_error & ex)
{
exception_thrown = true;
- BOOST_TEST_EQ( ex.code(), bs::error_code( std::codecvt_base::error, fs::codecvt_error_category() ) );
+ BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error, fs::codecvt_error_category()));
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
}
{
bool exception_thrown (false);
- try { path( STRING_FOO_"foo" ); }
- catch ( const bs::system_error & ex )
+ try { path(STRING_FOO_"foo"); }
+ catch (const bs::system_error & ex)
{
exception_thrown = true;
- BOOST_TEST_EQ( ex.code(), bs::error_code( std::codecvt_base::noconv, fs::codecvt_error_category() ) );
+ BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv, fs::codecvt_error_category()));
}
- BOOST_TEST( exception_thrown );
+ BOOST_TEST(exception_thrown);
}
std::cout << " restoring original locale ..." << std::endl;
- path::imbue( old_loc );
+ path::imbue(old_loc);
}
# if 0
@@ -699,10 +704,10 @@
template<> struct is_container<user_string> { static const bool value = true; };
template<>
- void append<user_string::value_type>( const user_string::value_type * begin,
- const user_string::value_type * end, string_type & target, system::error_code & ec )
+ void append<user_string::value_type>(const user_string::value_type * begin,
+ const user_string::value_type * end, string_type & target, system::error_code & ec)
{
- for ( ; begin != end && *begin; ++begin )
+ for (; begin != end && *begin; ++begin)
target += *begin + 1; // change so that results distinguishable from char cvts
}
@@ -710,21 +715,21 @@
// This specialization shouldn't be needed, and VC++, Intel, and others work
// fine without it. But gcc 4.3.2, and presumably other versions, need it.
template<>
- void append<user_string::value_type>( const user_string::value_type * begin,
- string_type & target, system::error_code & ec )
+ void append<user_string::value_type>(const user_string::value_type * begin,
+ string_type & target, system::error_code & ec)
{
- path_traits::append<user_string::value_type>( begin,
- static_cast<const user_string::value_type *>(0), target, ec );
+ path_traits::append<user_string::value_type>(begin,
+ static_cast<const user_string::value_type *>(0), target, ec);
}
# endif
template<>
- user_string convert<user_string>( const string_type & source,
- system::error_code & ec )
+ user_string convert<user_string>(const string_type & source,
+ system::error_code & ec)
{
user_string temp;
- for ( string_type::const_iterator it = source.begin();
- it != source.end(); ++it )
+ for (string_type::const_iterator it = source.begin();
+ it != source.end(); ++it)
temp += *it - 1;
return temp;
}
@@ -740,13 +745,13 @@
std::cout << "testing user supplied type..." << std::endl;
user_string::value_type usr_c_str[] = { 'a', 'b', 'c', 0 };
- user_string usr( usr_c_str );
+ user_string usr(usr_c_str);
- path p1( usr.c_str() );
- CHECK( p1 == path("bcd") );
- CHECK( p1 == "bcd" );
- user_string s1( p1.string<user_string>() );
- CHECK( s1 == usr );
+ path p1(usr.c_str());
+ CHECK(p1 == path("bcd"));
+ CHECK(p1 == "bcd");
+ user_string s1(p1.string<user_string>());
+ CHECK(s1 == usr);
}
# endif
@@ -759,7 +764,7 @@
// //
//--------------------------------------------------------------------------------------//
-int main( int, char*[] )
+int main(int, char*[])
{
test_overloads();
test_constructors();
@@ -783,9 +788,9 @@
#endif
std::string foo("\\abc");
- const char * bar = "/abc";
+ const char* bar = "/abc";
- if ( foo == bar )
+ if (foo == bar)
cout << "unintended consequence\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