Replace boost lexical casts in CppUnitLite
parent
d38562868f
commit
08e63aee12
|
@ -6,7 +6,6 @@ file(GLOB cppunitlite_src "*.cpp")
|
||||||
add_library(CppUnitLite STATIC ${cppunitlite_src} ${cppunitlite_headers})
|
add_library(CppUnitLite STATIC ${cppunitlite_src} ${cppunitlite_headers})
|
||||||
list(APPEND GTSAM_EXPORTED_TARGETS CppUnitLite)
|
list(APPEND GTSAM_EXPORTED_TARGETS CppUnitLite)
|
||||||
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
|
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
|
||||||
target_link_libraries(CppUnitLite PUBLIC Boost::boost) # boost/lexical_cast.h
|
|
||||||
|
|
||||||
gtsam_assign_source_folders("${cppunitlite_headers};${cppunitlite_src}") # MSVC project structure
|
gtsam_assign_source_folders("${cppunitlite_headers};${cppunitlite_src}") # MSVC project structure
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "TestResult.h"
|
#include "TestResult.h"
|
||||||
#include "Failure.h"
|
#include "Failure.h"
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <string>
|
||||||
|
|
||||||
Test::Test (const std::string& testName)
|
Test::Test (const std::string& testName)
|
||||||
: name_ (testName), next_(0), lineNumber_(-1), safeCheck_(true)
|
: name_ (testName), next_(0), lineNumber_(-1), safeCheck_(true)
|
||||||
|
@ -47,10 +47,10 @@ bool Test::check(long expected, long actual, TestResult& result, const std::stri
|
||||||
result.addFailure (
|
result.addFailure (
|
||||||
Failure (
|
Failure (
|
||||||
name_,
|
name_,
|
||||||
boost::lexical_cast<std::string> (__FILE__),
|
std::string(__FILE__),
|
||||||
__LINE__,
|
__LINE__,
|
||||||
boost::lexical_cast<std::string> (expected),
|
std::to_string(expected),
|
||||||
boost::lexical_cast<std::string> (actual)));
|
std::to_string(actual)));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ bool Test::check(const std::string& expected, const std::string& actual, TestRes
|
||||||
result.addFailure (
|
result.addFailure (
|
||||||
Failure (
|
Failure (
|
||||||
name_,
|
name_,
|
||||||
boost::lexical_cast<std::string> (__FILE__),
|
std::string(__FILE__),
|
||||||
__LINE__,
|
__LINE__,
|
||||||
expected,
|
expected,
|
||||||
actual));
|
actual));
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <string>
|
||||||
|
|
||||||
class TestResult;
|
class TestResult;
|
||||||
|
|
||||||
|
@ -112,17 +112,17 @@ protected:
|
||||||
|
|
||||||
#define THROWS_EXCEPTION(condition)\
|
#define THROWS_EXCEPTION(condition)\
|
||||||
{ try { condition; \
|
{ try { condition; \
|
||||||
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Didn't throw: ") + boost::lexical_cast<std::string>(#condition))); \
|
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Didn't throw: ") + std::string(#condition))); \
|
||||||
return; } \
|
return; } \
|
||||||
catch (...) {} }
|
catch (...) {} }
|
||||||
|
|
||||||
#define CHECK_EXCEPTION(condition, exception_name)\
|
#define CHECK_EXCEPTION(condition, exception_name)\
|
||||||
{ try { condition; \
|
{ try { condition; \
|
||||||
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Didn't throw: ") + boost::lexical_cast<std::string>(#condition))); \
|
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Didn't throw: ") + std::string(#condition))); \
|
||||||
return; } \
|
return; } \
|
||||||
catch (exception_name&) {} \
|
catch (exception_name&) {} \
|
||||||
catch (...) { \
|
catch (...) { \
|
||||||
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Wrong exception: ") + boost::lexical_cast<std::string>(#condition) + boost::lexical_cast<std::string>(", expected: ") + boost::lexical_cast<std::string>(#exception_name))); \
|
result_.addFailure (Failure (name_, __FILE__,__LINE__, std::string("Wrong exception: ") + std::string(#condition) + std::string(", expected: ") + std::string(#exception_name))); \
|
||||||
return; } }
|
return; } }
|
||||||
|
|
||||||
#define EQUALITY(expected,actual)\
|
#define EQUALITY(expected,actual)\
|
||||||
|
@ -130,21 +130,21 @@ protected:
|
||||||
result_.addFailure(Failure(name_, __FILE__, __LINE__, #expected, #actual)); }
|
result_.addFailure(Failure(name_, __FILE__, __LINE__, #expected, #actual)); }
|
||||||
|
|
||||||
#define CHECK_EQUAL(expected,actual)\
|
#define CHECK_EQUAL(expected,actual)\
|
||||||
{ if ((expected) == (actual)) return; result_.addFailure(Failure(name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expected), boost::lexical_cast<std::string>(actual))); }
|
{ if ((expected) == (actual)) return; result_.addFailure(Failure(name_, __FILE__, __LINE__, std::to_string(expected), std::to_string(actual))); }
|
||||||
|
|
||||||
#define LONGS_EQUAL(expected,actual)\
|
#define LONGS_EQUAL(expected,actual)\
|
||||||
{ long actualTemp = actual; \
|
{ long actualTemp = actual; \
|
||||||
long expectedTemp = expected; \
|
long expectedTemp = expected; \
|
||||||
if ((expectedTemp) != (actualTemp)) \
|
if ((expectedTemp) != (actualTemp)) \
|
||||||
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
|
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, std::to_string(expectedTemp), \
|
||||||
boost::lexical_cast<std::string>(actualTemp))); return; } }
|
std::to_string(actualTemp))); return; } }
|
||||||
|
|
||||||
#define DOUBLES_EQUAL(expected,actual,threshold)\
|
#define DOUBLES_EQUAL(expected,actual,threshold)\
|
||||||
{ double actualTemp = actual; \
|
{ double actualTemp = actual; \
|
||||||
double expectedTemp = expected; \
|
double expectedTemp = expected; \
|
||||||
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
|
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
|
||||||
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
|
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
|
||||||
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); return; } }
|
std::to_string(expectedTemp), std::to_string(actualTemp))); return; } }
|
||||||
|
|
||||||
|
|
||||||
/* EXPECTs: tests will continue running after a failure */
|
/* EXPECTs: tests will continue running after a failure */
|
||||||
|
@ -156,15 +156,15 @@ boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std:
|
||||||
{ long actualTemp = actual; \
|
{ long actualTemp = actual; \
|
||||||
long expectedTemp = expected; \
|
long expectedTemp = expected; \
|
||||||
if ((expectedTemp) != (actualTemp)) \
|
if ((expectedTemp) != (actualTemp)) \
|
||||||
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, boost::lexical_cast<std::string>(expectedTemp), \
|
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, std::to_string(expectedTemp), \
|
||||||
boost::lexical_cast<std::string>(actualTemp))); } }
|
std::to_string(actualTemp))); } }
|
||||||
|
|
||||||
#define EXPECT_DOUBLES_EQUAL(expected,actual,threshold)\
|
#define EXPECT_DOUBLES_EQUAL(expected,actual,threshold)\
|
||||||
{ double actualTemp = actual; \
|
{ double actualTemp = actual; \
|
||||||
double expectedTemp = expected; \
|
double expectedTemp = expected; \
|
||||||
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
|
if (!std::isfinite(actualTemp) || !std::isfinite(expectedTemp) || fabs ((expectedTemp)-(actualTemp)) > threshold) \
|
||||||
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
|
{ result_.addFailure (Failure (name_, __FILE__, __LINE__, \
|
||||||
boost::lexical_cast<std::string>((double)expectedTemp), boost::lexical_cast<std::string>((double)actualTemp))); } }
|
std::to_string(expectedTemp), std::to_string(actualTemp))); } }
|
||||||
|
|
||||||
|
|
||||||
#define FAIL(text) \
|
#define FAIL(text) \
|
||||||
|
|
Loading…
Reference in New Issue