summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/tests')
-rw-r--r--indra/llcommon/tests/llprocess_test.cpp44
-rw-r--r--indra/llcommon/tests/stringize_test.cpp12
2 files changed, 44 insertions, 12 deletions
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp
index b63cc52bec..13422612d6 100644
--- a/indra/llcommon/tests/llprocess_test.cpp
+++ b/indra/llcommon/tests/llprocess_test.cpp
@@ -54,14 +54,29 @@ std::string apr_strerror_helper(apr_status_t rv)
*****************************************************************************/
#define ensure_equals_(left, right) \
- ensure_equals(STRINGIZE(#left << " != " << #right), (left), (right))
+do { \
+ auto _left_val = (left); \
+ auto _right_val = (right); \
+ if (_left_val != _right_val) { \
+ std::string _msg = std::string(#left) + " != " + std::string(#right); \
+ tut::ensure_equals(_msg, _left_val, _right_val); \
+ } else { \
+ tut::ensure_equals("", _left_val, _right_val); \
+ } \
+} while(0)
#define aprchk(expr) aprchk_(#expr, (expr))
static void aprchk_(const char* call, apr_status_t rv, apr_status_t expected=APR_SUCCESS)
{
- tut::ensure_equals(STRINGIZE(call << " => " << rv << ": " << apr_strerror_helper
- (rv)),
- rv, expected);
+ if (rv != expected)
+ {
+ std::string msg = std::string(call) + " => " + std::to_string(rv) + ": " + apr_strerror_helper(rv);
+ tut::ensure_equals(msg, rv, expected);
+ }
+ else
+ {
+ tut::ensure_equals("", rv, expected);
+ }
}
/**
@@ -78,11 +93,14 @@ static std::string readfile(const std::string& pathname, const std::string& desc
std::string use_desc(desc);
if (use_desc.empty())
{
- use_desc = STRINGIZE("in " << pathname);
+ use_desc = "in " + pathname;
}
std::ifstream inf(pathname.c_str());
std::string output;
- tut::ensure(STRINGIZE("No output " << use_desc), bool(std::getline(inf, output)));
+ if (!std::getline(inf, output))
+ {
+ tut::ensure("No output " + use_desc, false);
+ }
std::string more;
while (std::getline(inf, more))
{
@@ -108,8 +126,8 @@ void waitfor(LLProcess& proc, int timeout=60)
{
yield();
}
- tut::ensure(STRINGIZE("process took longer than " << timeout << " seconds to terminate"),
- i < timeout);
+ std::string msg = "process took longer than " + std::to_string(timeout) + " seconds to terminate";
+ tut::ensure(msg, i < timeout);
}
void waitfor(LLProcess::handle h, const std::string& desc, int timeout=60)
@@ -119,8 +137,8 @@ void waitfor(LLProcess::handle h, const std::string& desc, int timeout=60)
{
yield();
}
- tut::ensure(STRINGIZE("process took longer than " << timeout << " seconds to terminate"),
- i < timeout);
+ std::string msg = "process took longer than " + std::to_string(timeout) + " seconds to terminate";
+ tut::ensure(msg, i < timeout);
}
/**
@@ -153,7 +171,8 @@ struct PythonProcessLauncher
try
{
mPy = LLProcess::create(mParams);
- tut::ensure(STRINGIZE("Couldn't launch " << mDesc << " script"), bool(mPy));
+ std::string msg = "Couldn't launch " + mDesc + " script";
+ tut::ensure(msg, bool(mPy));
}
catch (const tut::failure&)
{
@@ -214,7 +233,8 @@ struct PythonProcessLauncher
mParams.args.add(out.getName());
run();
// assuming the script wrote to that file, read it
- return readfile(out.getName(), STRINGIZE("from " << mDesc << " script"));
+ std::string desc = "from " + mDesc + " script";
+ return readfile(out.getName(), desc);
}
LLProcess::Params mParams;
diff --git a/indra/llcommon/tests/stringize_test.cpp b/indra/llcommon/tests/stringize_test.cpp
index a3ce7f8e3d..3f99041592 100644
--- a/indra/llcommon/tests/stringize_test.cpp
+++ b/indra/llcommon/tests/stringize_test.cpp
@@ -110,6 +110,17 @@ namespace tut
void stringize_object::test<3>()
{
//Tests rely on validity of wstring_to_utf8str()
+#if LL_WINDOWS // Windows wstring is a 2byte UTF16 type
+ ensure_equals(ll_convert<std::string>(wstringize(c)), ll_convert<std::string>(std::wstring(L"c")));
+ ensure_equals(ll_convert<std::string>(wstringize(s)), ll_convert<std::string>(std::wstring(L"17")));
+ ensure_equals(ll_convert<std::string>(wstringize(i)), ll_convert<std::string>(std::wstring(L"34")));
+ ensure_equals(ll_convert<std::string>(wstringize(l)), ll_convert<std::string>(std::wstring(L"68")));
+ ensure_equals(ll_convert<std::string>(wstringize(f)), ll_convert<std::string>(std::wstring(L"3.14159")));
+ ensure_equals(ll_convert<std::string>(wstringize(d)), ll_convert<std::string>(std::wstring(L"3.14159")));
+ ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(std::wstring(L"abc def")));
+ ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(wstringize(abc.c_str())));
+ ensure_equals(ll_convert<std::string>(wstringize(def)), ll_convert<std::string>(std::wstring(L"def ghi")));
+#else
ensure_equals(wstring_to_utf8str(wstringize(c)), wstring_to_utf8str(L"c"));
ensure_equals(wstring_to_utf8str(wstringize(s)), wstring_to_utf8str(L"17"));
ensure_equals(wstring_to_utf8str(wstringize(i)), wstring_to_utf8str(L"34"));
@@ -119,6 +130,7 @@ namespace tut
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(L"abc def"));
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(wstringize(abc.c_str())));
ensure_equals(wstring_to_utf8str(wstringize(def)), wstring_to_utf8str(L"def ghi"));
+#endif
// ensure_equals(wstring_to_utf8str(wstringize(llsd)), wstring_to_utf8str(L"{'abc':'abc def','d':r3.14159,'i':i34}"));
}
} // namespace tut