const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- BOOST_REQUIRE_MESSAGE(value == expected,
- "[" << filename << " > " << funcname << " : " << line << "]" <<
- " returned[" << capi_ec_to_string(value) <<
- "] expected[" << capi_ec_to_string(expected) << "] " << msg);
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "]" << " returned[" << capi_ec_to_string(value) <<
+ "] expected[" << capi_ec_to_string(expected) << "] " << msg);
+ else
+ BOOST_WARN_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << capi_ec_to_string(value) <<
+ "] expected[" << capi_ec_to_string(expected) << "] " << msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- BOOST_REQUIRE_MESSAGE(value == expected,
- "[" << filename << " > " << funcname << " : " << line << "]" <<
- " returned[" << capi_ec_to_string(value) << "] expected[" <<
- capi_ec_to_string(static_cast<csr_error_e>(expected)) << "]" <<
- " " << msg);
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << capi_ec_to_string(value) << "] expected[" <<
+ capi_ec_to_string(static_cast<csr_error_e>(expected)) <<
+ "] " << msg);
+ else
+ BOOST_WARN_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << capi_ec_to_string(value) << "] expected[" <<
+ capi_ec_to_string(static_cast<csr_error_e>(expected)) <<
+ "] " << msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- BOOST_REQUIRE_MESSAGE(value == expected,
- "[" << filename << " > " << funcname << " : " << line << "]" <<
- " returned[" <<
- capi_ec_to_string(static_cast<csr_error_e>(value)) <<
- "] expected[" << capi_ec_to_string(expected) << "] " << msg);
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << capi_ec_to_string(static_cast<csr_error_e>(value)) <<
+ "] expected[" << capi_ec_to_string(expected) << "] " << msg);
+ BOOST_WARN_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << capi_ec_to_string(static_cast<csr_error_e>(value)) <<
+ "] expected[" << capi_ec_to_string(expected) << "] " << msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- if (value == nullptr && expected == nullptr)
- BOOST_REQUIRE(true);
- else if (value != nullptr && expected != nullptr)
+ if (value == nullptr && expected == nullptr) {
+ if (isAssert)
+ BOOST_REQUIRE(true);
+ else
+ BOOST_WARN(true);
+ } else if (value != nullptr && expected != nullptr) {
_assert<std::string, const char *>(std::string(value), expected, filename,
- funcname, line, msg);
- else if (value == nullptr && expected != nullptr)
- BOOST_REQUIRE_MESSAGE(std::string(expected).empty(),
- "[" << filename << " > " << funcname << " : " << line <<
- "] returned[nullptr] expected[" << expected << "] " << msg);
- else
- BOOST_REQUIRE_MESSAGE(std::string(value).empty(),
- "[" << filename << " > " << funcname << " : " << line <<
- "] returned[" << value << "] expected[nullptr] " << msg);
+ funcname, line, isAssert, msg);
+ } else if (value == nullptr && expected != nullptr) {
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(std::string(expected).empty(),
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[nullptr] expected[" << expected << "] " << msg);
+ else
+ BOOST_WARN_MESSAGE(std::string(expected).empty(),
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[nullptr] expected[" << expected << "] " << msg);
+ } else {
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(std::string(value).empty(),
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << value << "] expected[nullptr] " << msg);
+ else
+ BOOST_WARN_MESSAGE(std::string(value).empty(),
+ "[" << filename << " > " << funcname << " : " << line <<
+ "] returned[" << value << "] expected[nullptr] " << msg);
+ }
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- _assert<const char *, const char *>(value, expected, filename, funcname, line, msg);
+ _assert<const char *, const char *>(value, expected, filename, funcname, line, isAssert, msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- _assert<const char *, const char *>(value, expected, filename, funcname, line, msg);
+ _assert<const char *, const char *>(value, expected, filename, funcname, line, isAssert, msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- _assert<const char *, const char *>(value, expected, filename, funcname, line, msg);
+ _assert<const char *, const char *>(value, expected, filename, funcname, line, isAssert, msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
_assert<std::string, std::string>(
(value == nullptr) ? std::string() : std::string(value),
- expected, filename, funcname, line, msg);
+ expected, filename, funcname, line, isAssert, msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg)
{
- _assert<const char *, std::string>(value, expected, filename, funcname, line, msg);
+ _assert<const char *, std::string>(value, expected, filename, funcname, line, isAssert, msg);
}
void exceptionGuard(const std::function<void()> &f)
0, std::ios_base::cur) << ITEMS)).str()
#define ASSERT_IF_MSG(value, expected, msg) \
- Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, TOSTRING(msg))
+ Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, true, TOSTRING(msg))
+
+#define WARN_IF_MSG(value, expected, msg) \
+ Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, false, TOSTRING(msg))
#define ASSERT_IF(value, expected) \
- Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, "")
+ Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, true, "")
+
+#define WARN_IF(value, expected) \
+ Test::_assert(value, expected, __FILENAME__, __func__, __LINE__, false, "")
#define ASSERT_SUCCESS(value) \
- Test::_assert(value, CSR_ERROR_NONE, __FILENAME__, __func__, __LINE__, "")
+ Test::_assert(value, CSR_ERROR_NONE, __FILENAME__, __func__, __LINE__, true, "")
+
+#define WARN_SUCCESS(value) \
+ Test::_assert(value, CSR_ERROR_NONE, __FILENAME__, __func__, __LINE__, false, "")
#define ASSERT_INSTALL_APP(path, type) \
BOOST_REQUIRE_MESSAGE(Test::install_app(path, type), \
template <typename T, typename U>
void _assert(const T &value, const U &expected, const std::string &filename,
- const std::string &funcname, unsigned int line, const std::string &msg)
+ const std::string &funcname, unsigned int line, bool isAssert,
+ const std::string &msg)
{
- BOOST_REQUIRE_MESSAGE(value == expected,
- "[" << filename << " > " << funcname << " : " << line << "]" <<
- " returned[" << value << "] expected[" << expected <<
- "] " << msg);
+ if (isAssert)
+ BOOST_REQUIRE_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "]" << " returned[" << value << "] expected[" << expected <<
+ "] " << msg);
+ else
+ BOOST_WARN_MESSAGE(value == expected,
+ "[" << filename << " > " << funcname << " : " << line <<
+ "]" << " returned[" << value << "] expected[" << expected <<
+ "] " << msg);
}
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
template <>
const std::string &filename,
const std::string &funcname,
unsigned int line,
+ bool isAssert,
const std::string &msg);
void exceptionGuard(const std::function<void()> &);