#ifndef BOOST_SERIALIZATION_TEST_TOOLS_HPP
#define BOOST_SERIALIZATION_TEST_TOOLS_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem/operations.hpp>
#include <boost/config.hpp>
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
#include <exception>
#endif
#include <boost/core/no_exceptions_support.hpp>
#if defined(UNDER_CE)
namespace boost {
namespace archive {
const char * tmpnam(char * buffer){
static char ibuffer [512];
if(NULL == buffer)
buffer = ibuffer;
static unsigned short index = 0;
std::sprintf(buffer, "\\tmpfile%05X.tmp", index++);
return buffer;
}
} }
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <cstdlib>
#include <cstring>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::remove;
using ::strcpy;
using ::strcat;
using ::tmpnam;
}
#endif
#include <direct.h>
#include <boost/archive/tmpdir.hpp>
#if !defined(BOOST_EMBTC)
#define chdir _chdir
#endif
#if defined(NDEBUG) && defined(BOOST_BORLANDC)
#define STRCPY strcpy
#else
#define STRCPY std::strcpy
#endif
namespace boost {
namespace archive {
const char * test_filename(const char * dir = NULL, char *fname = NULL){
static char ibuffer [512];
ibuffer[0] = '\0';
if(NULL == dir){
dir = boost::archive::tmpdir();
}
STRCPY(ibuffer, dir);
std::strcat(ibuffer, "/");
if(NULL == fname){
char old_dir[256];
_getcwd(old_dir, sizeof(old_dir) - 1);
chdir(dir);
boost::filesystem::path tmp_path =
boost::filesystem::unique_path("%%%%%");
std::strcat(ibuffer, tmp_path.string().c_str());
chdir(old_dir);
}
else{
std::strcat(ibuffer, fname);
}
return ibuffer;
}
const char * tmpnam(char * buffer){
const char * name = test_filename(NULL, NULL);
if(NULL != buffer){
STRCPY(buffer, name);
}
return name;
}
} }
#else
#if defined(__hpux)
#define tmpnam(X) tempnam(NULL,X)
namespace boost {
namespace archive {
using ::tmpnam;
} }
#else
#include <boost/archive/tmpdir.hpp>
namespace boost {
namespace archive {
char const * tmpnam(char * buffer) {
static char name[512] = {0};
if (name[0] == 0) {
boost::filesystem::path tempdir(tmpdir());
boost::filesystem::path tempfilename =
boost::filesystem::unique_path("serialization-%%%%");
boost::filesystem::path temp = tempdir / tempfilename;
std::strcat(name, temp.string().c_str());
}
if (buffer != 0) std::strcpy(buffer, name);
return name;
}
} }
#endif #endif
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK( P ) \
BOOST_TEST( (P) )
#define BOOST_REQUIRE( P ) \
BOOST_TEST( (P) )
#define BOOST_CHECK_MESSAGE( P, M ) \
((P)? (void)0 : ::boost::detail::error_impl( (M) , __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_REQUIRE_MESSAGE( P, M ) \
BOOST_CHECK_MESSAGE( (P), (M) )
#define BOOST_CHECK_EQUAL( A , B ) \
BOOST_TEST( (A) == (B) )
namespace boost { namespace detail {
inline void msg_impl(char const * msg, char const * file, int line, char const * function)
{
std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl;
}
} }
#define BOOST_WARN_MESSAGE( P, M ) \
((P)? (void)0 : ::boost::detail::msg_impl( (M) , __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_MESSAGE( M ) \
BOOST_WARN_MESSAGE( true , (M) )
#define BOOST_CHECKPOINT( M ) \
BOOST_WARN_MESSAGE( true , (M) )
#define BOOST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, (M) )
#define EXIT_SUCCESS 0
int test_main(int argc, char * argv[]);
#include <boost/serialization/singleton.hpp>
int
main(int argc, char * argv[]){
boost::serialization::get_singleton_module().lock();
int retval = 1;
BOOST_TRY{
retval = test_main(argc, argv);
}
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
BOOST_CATCH(const std::exception & e){
BOOST_ERROR(e.what());
}
#endif
BOOST_CATCH(...){
BOOST_ERROR("failed with uncaught exception:");
}
BOOST_CATCH_END
boost::serialization::get_singleton_module().unlock();
int error_count = boost::report_errors();
if(error_count > 0)
retval = error_count;
return retval;
}
#if ! defined(BOOST_ARCHIVE_TEST)
#define BOOST_ARCHIVE_TEST text_archive.hpp
#endif
#include <boost/preprocessor/stringize.hpp>
#include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST)
#ifndef TEST_STREAM_FLAGS
#define TEST_STREAM_FLAGS (std::ios_base::openmode)0
#endif
#ifndef TEST_ARCHIVE_FLAGS
#define TEST_ARCHIVE_FLAGS 0
#endif
#ifndef TEST_DIRECTORY
#define TEST_DIRECTORY
#else
#define __x__ TEST_DIRECTORY
#undef TEST_DIRECTORY
#define TEST_DIRECTORY BOOST_PP_STRINGIZE(__x__)
#endif
#endif