summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 10:08:13 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 10:08:13 -0400
commit76fb5f1542297a7e1afdf983d8a0db459fc0b8ab (patch)
tree0c35366715e4a944361f5ec1cbf61535b04b6ab0 /indra/test
parentff42e557848158d5a01cc260bac0bbf974650934 (diff)
parentfde0868231a25b8c9ce03a86cb53f1738d35688d (diff)
merge with viewer tools update
Diffstat (limited to 'indra/test')
-rwxr-xr-xindra/test/CMakeLists.txt12
-rwxr-xr-xindra/test/llbuffer_tut.cpp1
-rwxr-xr-xindra/test/llevents_tut.cpp2
-rwxr-xr-xindra/test/llmessageconfig_tut.cpp2
-rwxr-xr-xindra/test/llpermissions_tut.cpp2
-rwxr-xr-xindra/test/llsd_new_tut.cpp43
-rwxr-xr-xindra/test/lltranscode_tut.cpp3
-rwxr-xr-xindra/test/lltut.cpp43
-rwxr-xr-xindra/test/lltut.h85
-rwxr-xr-xindra/test/message_tut.cpp5
-rwxr-xr-xindra/test/namedtempfile.h10
11 files changed, 110 insertions, 98 deletions
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 62b1d9db62..01d1d830a2 100755
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -1,6 +1,6 @@
# -*- cmake -*-
-project (test)
+project (lltest)
include(00-Common)
include(LLCommon)
@@ -80,9 +80,9 @@ set_source_files_properties(${test_HEADER_FILES}
list(APPEND test_SOURCE_FILES ${test_HEADER_FILES})
-add_executable(test ${test_SOURCE_FILES})
+add_executable(lltest ${test_SOURCE_FILES})
-target_link_libraries(test
+target_link_libraries(lltest
${LLDATABASE_LIBRARIES}
${LLINVENTORY_LIBRARIES}
${LLMESSAGE_LIBRARIES}
@@ -102,14 +102,14 @@ target_link_libraries(test
)
if (WINDOWS)
- set_target_properties(test
+ set_target_properties(lltest
PROPERTIES
LINK_FLAGS "/NODEFAULTLIB:LIBCMT"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\""
)
endif (WINDOWS)
-get_target_property(TEST_EXE test LOCATION)
+set(TEST_EXE $<TARGET_FILE:lltest>)
SET_TEST_PATH(DYLD_LIBRARY_PATH)
@@ -122,7 +122,7 @@ LL_TEST_COMMAND(command
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt
COMMAND ${command}
- DEPENDS test
+ DEPENDS lltest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "C++ unit tests"
)
diff --git a/indra/test/llbuffer_tut.cpp b/indra/test/llbuffer_tut.cpp
index a25fdebb7f..9b8aae6a73 100755
--- a/indra/test/llbuffer_tut.cpp
+++ b/indra/test/llbuffer_tut.cpp
@@ -27,6 +27,7 @@
*/
#include <tut/tut.hpp>
+
#include "linden_common.h"
#include "lltut.h"
#include "llbuffer.h"
diff --git a/indra/test/llevents_tut.cpp b/indra/test/llevents_tut.cpp
index a9114075fc..16edab6282 100755
--- a/indra/test/llevents_tut.cpp
+++ b/indra/test/llevents_tut.cpp
@@ -48,10 +48,10 @@
#include <boost/shared_ptr.hpp>
#include <boost/assign/list_of.hpp>
// other Linden headers
+#include "tests/listener.h" // must PRECEDE lltut.h
#include "lltut.h"
#include "catch_and_store_what_in.h"
#include "stringize.h"
-#include "tests/listener.h"
using boost::assign::list_of;
diff --git a/indra/test/llmessageconfig_tut.cpp b/indra/test/llmessageconfig_tut.cpp
index 8088ce8558..df2151b1b1 100755
--- a/indra/test/llmessageconfig_tut.cpp
+++ b/indra/test/llmessageconfig_tut.cpp
@@ -68,7 +68,7 @@ namespace tut
void writeConfigFile(const LLSD& config)
{
- llofstream file((mTestConfigDir + "/message.xml"));
+ llofstream file((mTestConfigDir + "/message.xml").c_str());
if (file.is_open())
{
LLSDSerialize::toPrettyXML(config, file);
diff --git a/indra/test/llpermissions_tut.cpp b/indra/test/llpermissions_tut.cpp
index 8d8d47a667..fa4b085fd3 100755
--- a/indra/test/llpermissions_tut.cpp
+++ b/indra/test/llpermissions_tut.cpp
@@ -28,7 +28,9 @@
#include <tut/tut.hpp>
#include "linden_common.h"
+
#include "lltut.h"
+
#include "message.h"
#include "llpermissions.h"
diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp
index 03df1d339b..458df3361e 100755
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/test/llsd_new_tut.cpp
@@ -33,18 +33,7 @@
#include "llsdtraits.h"
#include "llstring.h"
-#if LL_WINDOWS
-#include <float.h>
-namespace
-{
- int fpclassify(double x)
- {
- return _fpclass(x);
- }
-}
-#else
using std::fpclassify;
-#endif
namespace tut
{
@@ -112,15 +101,15 @@ namespace tut
SDTestGroup sdTestGroup("LLSD(new)");
- template<> template<>
- void SDTestObject::test<1>()
- // construction and test of undefined
- {
- SDCleanupCheck check;
-
- LLSD u;
- ensure("is undefined", u.isUndefined());
- }
+ // template<> template<>
+ // void SDTestObject::test<1>()
+ // // construction and test of undefined
+ // {
+ // SDCleanupCheck check;
+
+ // LLSD u;
+ // ensure("is undefined", u.isUndefined());
+ // }
template<> template<>
void SDTestObject::test<2>()
@@ -277,8 +266,18 @@ namespace tut
v = 0.5; checkConversions("point5", v, true, 0, 0.5, "0.5");
v = 0.9; checkConversions("point9", v, true, 0, 0.9, "0.9");
v = -3.9; checkConversions("neg3dot9", v, true, -3, -3.9, "-3.9");
- v = sqrt(-1.0); checkConversions("NaN", v, false, 0, sqrt(-1.0), "nan");
-
+ // Get rid of NaN test. First, some libraries don't reliably return
+ // NaN for sqrt(-1.0) -- meaning that I don't even know how to
+ // portably, reliably produce a NaN value. Second, we observe failures
+ // on different platforms in the asString() test. But LLSD's
+ // ImplReal::asString() does not itself recognize NaN! It merely
+ // passes the value through to llformat(), which passes it through to
+ // the library vsnprintf(). That is, even when we do produce NaN,
+ // we're not testing any LLSD code: we're testing the local library's
+ // vsnprintf() function, which (empirically) produces idiosyncratic
+ // results. This is just not a good test case.
+// v = sqrt(-1.0); checkConversions("NaN", v, false, 0, sqrt(-1.0), "nan");
+
v = ""; checkConversions("empty", v, false, 0, 0.0, "");
v = "0"; checkConversions("digit0", v, true, 0, 0.0, "0");
v = "10"; checkConversions("digit10", v, true, 10, 10.0, "10");
diff --git a/indra/test/lltranscode_tut.cpp b/indra/test/lltranscode_tut.cpp
index 2431afad27..3fce6e0e2b 100755
--- a/indra/test/lltranscode_tut.cpp
+++ b/indra/test/lltranscode_tut.cpp
@@ -49,9 +49,6 @@ namespace tut
template<> template<>
void LLTranscodeTestObject::test<1>()
{
-#if LL_WINDOWS
- skip("Windows APR libs can't transcode.");
-#endif
// Test utf8
std::stringstream input;
std::stringstream output;
diff --git a/indra/test/lltut.cpp b/indra/test/lltut.cpp
index c43a8f0c7d..5a8ee87afd 100755
--- a/indra/test/lltut.cpp
+++ b/indra/test/lltut.cpp
@@ -38,43 +38,44 @@
namespace tut
{
- void ensure_equals(const char* msg, const LLDate& actual,
+ void ensure_equals(const std::string& msg, const LLDate& actual,
const LLDate& expected)
{
ensure_equals(msg,
actual.secondsSinceEpoch(), expected.secondsSinceEpoch());
}
- void ensure_equals(const char* msg, const LLURI& actual,
+ void ensure_equals(const std::string& msg, const LLURI& actual,
const LLURI& expected)
{
ensure_equals(msg,
actual.asString(), expected.asString());
}
- void ensure_equals(const char* msg,
- const std::vector<U8>& actual, const std::vector<U8>& expected)
+ // The lexical param types here intentionally diverge from the declaration
+ // in our header file. In lltut.h, LLSD is only a forward-declared type;
+ // we have no access to its LLSD::Binary nested type, and so must restate
+ // it explicitly to declare this overload. However, an overload that does
+ // NOT match LLSD::Binary does us no good whatsoever: it would never be
+ // engaged. Stating LLSD::Binary for this definition at least means that
+ // if the LLSD::Binary type ever diverges from what we expect in lltut.h,
+ // that divergence will produce an error: no definition will match that
+ // declaration.
+ void ensure_equals(const std::string& msg,
+ const LLSD::Binary& actual, const LLSD::Binary& expected)
{
- std::string s(msg);
+ ensure_equals(msg + " size", actual.size(), expected.size());
- ensure_equals(s + " size", actual.size(), expected.size());
-
- std::vector<U8>::const_iterator i, j;
+ LLSD::Binary::const_iterator i, j;
int k;
for (i = actual.begin(), j = expected.begin(), k = 0;
i != actual.end();
++i, ++j, ++k)
{
- ensure_equals(s + " field", *i, *j);
+ ensure_equals(msg + " field", *i, *j);
}
}
- void ensure_equals(const char* m, const LLSD& actual,
- const LLSD& expected)
- {
- ensure_equals(std::string(m), actual, expected);
- }
-
void ensure_equals(const std::string& msg, const LLSD& actual,
const LLSD& expected)
{
@@ -158,8 +159,8 @@ namespace tut
if( actual.find(expectedStart, 0) != 0 )
{
std::stringstream ss;
- ss << msg << ": " << "expected to find " << expectedStart
- << " at start of actual " << actual;
+ ss << msg << ": " << "expected to find '" << expectedStart
+ << "' at start of actual '" << actual << "'";
throw failure(ss.str().c_str());
}
}
@@ -172,8 +173,8 @@ namespace tut
!= (actual.size() - expectedEnd.size()) )
{
std::stringstream ss;
- ss << msg << ": " << "expected to find " << expectedEnd
- << " at end of actual " << actual;
+ ss << msg << ": " << "expected to find '" << expectedEnd
+ << "' at end of actual '" << actual << "'";
throw failure(ss.str().c_str());
}
}
@@ -184,8 +185,8 @@ namespace tut
if( actual.find(expectedSubString, 0) == std::string::npos )
{
std::stringstream ss;
- ss << msg << ": " << "expected to find " << expectedSubString
- << " in actual " << actual;
+ ss << msg << ": " << "expected to find '" << expectedSubString
+ << "' in actual '" << actual << "'";
throw failure(ss.str().c_str());
}
}
diff --git a/indra/test/lltut.h b/indra/test/lltut.h
index 243e869be7..9835565bb6 100755
--- a/indra/test/lltut.h
+++ b/indra/test/lltut.h
@@ -30,8 +30,6 @@
#define LL_LLTUT_H
#include "is_approx_equal_fraction.h" // instead of llmath.h
-
-#include <tut/tut.hpp>
#include <cstring>
class LLDate;
@@ -40,6 +38,55 @@ class LLURI;
namespace tut
{
+ void ensure_equals(const std::string& msg,
+ const LLDate& actual, const LLDate& expected);
+
+ void ensure_equals(const std::string& msg,
+ const LLURI& actual, const LLURI& expected);
+
+ // std::vector<U8> is the current definition of LLSD::Binary. Because
+ // we're only forward-declaring LLSD in this header file, we can't
+ // directly reference that nested type. If the build complains that
+ // there's no definition for this declaration, it could be that
+ // LLSD::Binary has changed, and that this declaration must be adjusted to
+ // match.
+ void ensure_equals(const std::string& msg,
+ const std::vector<U8>& actual, const std::vector<U8>& expected);
+
+ void ensure_equals(const std::string& msg,
+ const LLSD& actual, const LLSD& expected);
+
+ void ensure_starts_with(const std::string& msg,
+ const std::string& actual, const std::string& expectedStart);
+
+ void ensure_ends_with(const std::string& msg,
+ const std::string& actual, const std::string& expectedEnd);
+
+ void ensure_contains(const std::string& msg,
+ const std::string& actual, const std::string& expectedSubString);
+
+ void ensure_does_not_contain(const std::string& msg,
+ const std::string& actual, const std::string& expectedSubString);
+}
+
+// This is an odd place to #include an important contributor -- but the usual
+// rules are reversed here. Instead of the overloads above referencing tut.hpp
+// features, we need calls in tut.hpp template functions to dispatch to our
+// overloads declared above.
+
+// turn off warnings about unused functions from clang for tut package
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
+#include <tut/tut.hpp>
+#if __clang__
+#pragma clang diagnostic pop
+#endif
+
+// The functions BELOW this point actually consume tut.hpp functionality.
+namespace tut
+{
inline void ensure_approximately_equals(const char* msg, F64 actual, F64 expected, U32 frac_bits)
{
if(!is_approx_equal_fraction(actual, expected, frac_bits))
@@ -107,40 +154,6 @@ namespace tut
{
ensure_not_equals(NULL, actual, expected);
}
-
-
- template <class T,class Q>
- void ensure_equals(const std::string& msg,
- const Q& actual,const T& expected)
- { ensure_equals(msg.c_str(), actual, expected); }
-
- void ensure_equals(const char* msg,
- const LLDate& actual, const LLDate& expected);
-
- void ensure_equals(const char* msg,
- const LLURI& actual, const LLURI& expected);
-
- void ensure_equals(const char* msg,
- const std::vector<U8>& actual, const std::vector<U8>& expected);
-
- void ensure_equals(const char* msg,
- const LLSD& actual, const LLSD& expected);
-
- void ensure_equals(const std::string& msg,
- const LLSD& actual, const LLSD& expected);
-
- void ensure_starts_with(const std::string& msg,
- const std::string& actual, const std::string& expectedStart);
-
- void ensure_ends_with(const std::string& msg,
- const std::string& actual, const std::string& expectedEnd);
-
- void ensure_contains(const std::string& msg,
- const std::string& actual, const std::string& expectedSubString);
-
- void ensure_does_not_contain(const std::string& msg,
- const std::string& actual, const std::string& expectedSubString);
}
-
#endif // LL_LLTUT_H
diff --git a/indra/test/message_tut.cpp b/indra/test/message_tut.cpp
index 57e423e550..aa23699de0 100755
--- a/indra/test/message_tut.cpp
+++ b/indra/test/message_tut.cpp
@@ -119,9 +119,8 @@ namespace tut
void writeConfigFile(const LLSD& config)
{
- std::ostringstream ostr;
- ostr << mTestConfigDir << mSep << "message.xml";
- llofstream file(ostr.str());
+ std::string ostr(mTestConfigDir + mSep + "message.xml");
+ llofstream file(ostr.c_str());
if (file.is_open())
{
LLSDSerialize::toPrettyXML(config, file);
diff --git a/indra/test/namedtempfile.h b/indra/test/namedtempfile.h
index 6069064627..7d59cad32c 100755
--- a/indra/test/namedtempfile.h
+++ b/indra/test/namedtempfile.h
@@ -17,8 +17,8 @@
#include "apr_file_io.h"
#include <string>
#include <boost/function.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
+#include <boost/phoenix/core/argument.hpp>
+#include <boost/phoenix/operator/bitwise.hpp>
#include <boost/noncopyable.hpp>
#include <iostream>
#include <sstream>
@@ -34,19 +34,19 @@ public:
NamedTempFile(const std::string& pfx, const std::string& content, apr_pool_t* pool=gAPRPoolp):
mPool(pool)
{
- createFile(pfx, boost::lambda::_1 << content);
+ createFile(pfx, boost::phoenix::placeholders::arg1 << content);
}
// Disambiguate when passing string literal
NamedTempFile(const std::string& pfx, const char* content, apr_pool_t* pool=gAPRPoolp):
mPool(pool)
{
- createFile(pfx, boost::lambda::_1 << content);
+ createFile(pfx, boost::phoenix::placeholders::arg1 << content);
}
// Function that accepts an ostream ref and (presumably) writes stuff to
// it, e.g.:
- // (boost::lambda::_1 << "the value is " << 17 << '\n')
+ // (boost::phoenix::placeholders::arg1 << "the value is " << 17 << '\n')
typedef boost::function<void(std::ostream&)> Streamer;
NamedTempFile(const std::string& pfx, const Streamer& func, apr_pool_t* pool=gAPRPoolp):