summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2014-11-14 08:49:08 -0500
committerNat Goodspeed <nat@lindenlab.com>2014-11-14 08:49:08 -0500
commit6be2f0ba2b672fc37cd6d4e8adf62ae71bf8c842 (patch)
tree86740538c9c2a2ff1359cf96db2521d99c8aebe7 /indra/test
parent2301cf800f40101baed7a5936683d0b1e4968be1 (diff)
parent316e35ad2a735784cfc309ea9fd74d2d9d1f985a (diff)
Automated merge with ssh://bitbucket.org/lindenlab/viewer-release
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/llpermissions_tut.cpp2
-rwxr-xr-xindra/test/llsd_new_tut.cpp32
-rwxr-xr-xindra/test/lltut.cpp43
-rwxr-xr-xindra/test/lltut.h81
7 files changed, 98 insertions, 75 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/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..81db191ca6 100755
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/test/llsd_new_tut.cpp
@@ -112,15 +112,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 +277,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/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..b334fb51e2 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,51 @@ 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
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#include <tut/tut.hpp>
+#pragma clang diagnostic pop
+
+// 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 +150,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