diff options
Diffstat (limited to 'indra/llmessage/tests')
-rw-r--r-- | indra/llmessage/tests/commtest.h | 12 | ||||
-rw-r--r-- | indra/llmessage/tests/llareslistener_test.cpp | 52 | ||||
-rw-r--r-- | indra/llmessage/tests/llavatarnamecache_test.cpp | 142 | ||||
-rw-r--r-- | indra/llmessage/tests/llcoproceduremanager_test.cpp | 12 | ||||
-rw-r--r-- | indra/llmessage/tests/llcurl_stub.cpp | 46 | ||||
-rw-r--r-- | indra/llmessage/tests/llhost_test.cpp | 478 | ||||
-rw-r--r-- | indra/llmessage/tests/llhttpclient_test.cpp | 532 | ||||
-rw-r--r-- | indra/llmessage/tests/llhttpnode_stub.cpp | 24 | ||||
-rw-r--r-- | indra/llmessage/tests/llmockhttpclient.h | 32 | ||||
-rw-r--r-- | indra/llmessage/tests/llnamevalue_test.cpp | 734 | ||||
-rw-r--r-- | indra/llmessage/tests/llpartdata_test.cpp | 220 | ||||
-rw-r--r-- | indra/llmessage/tests/lltemplatemessagedispatcher_test.cpp | 186 | ||||
-rw-r--r-- | indra/llmessage/tests/lltestmessagesender.cpp | 20 | ||||
-rw-r--r-- | indra/llmessage/tests/lltestmessagesender.h | 22 | ||||
-rw-r--r-- | indra/llmessage/tests/lltrustedmessageservice_test.cpp | 132 | ||||
-rw-r--r-- | indra/llmessage/tests/llxfer_file_test.cpp | 50 | ||||
-rw-r--r-- | indra/llmessage/tests/networkio.h | 12 |
17 files changed, 1353 insertions, 1353 deletions
diff --git a/indra/llmessage/tests/commtest.h b/indra/llmessage/tests/commtest.h index 0359eba803..cc72242e66 100644 --- a/indra/llmessage/tests/commtest.h +++ b/indra/llmessage/tests/commtest.h @@ -2,26 +2,26 @@ * @file commtest.h * @author Nat Goodspeed * @date 2009-01-09 - * @brief - * + * @brief + * * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ diff --git a/indra/llmessage/tests/llareslistener_test.cpp b/indra/llmessage/tests/llareslistener_test.cpp index 254185cbd0..f4a9e501ec 100644 --- a/indra/llmessage/tests/llareslistener_test.cpp +++ b/indra/llmessage/tests/llareslistener_test.cpp @@ -3,25 +3,25 @@ * @author Mark Palange * @date 2009-02-26 * @brief Tests of llareslistener.h. - * + * * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -57,14 +57,14 @@ LLAres::LLAres(): {} LLAres::~LLAres() {} void LLAres::rewriteURI(const std::string &uri, - LLAres::UriRewriteResponder *resp) + LLAres::UriRewriteResponder *resp) { - // This is the only LLAres method I chose to implement. - // The effect is that LLAres returns immediately with - // a result that is equal to the input uri. - std::vector<std::string> result; - result.push_back(uri); - resp->rewriteResult(result); + // This is the only LLAres method I chose to implement. + // The effect is that LLAres returns immediately with + // a result that is equal to the input uri. + std::vector<std::string> result; + result.push_back(uri); + resp->rewriteResult(result); } LLAres::QueryResponder::~QueryResponder() {} @@ -90,11 +90,11 @@ namespace tut typedef llareslistener_group::object object; llareslistener_group llareslistenergrp("llareslistener"); - struct ResponseCallback - { - std::vector<std::string> mURIs; - bool operator()(const LLSD& response) - { + struct ResponseCallback + { + std::vector<std::string> mURIs; + bool operator()(const LLSD& response) + { mURIs.clear(); for (LLSD::array_const_iterator ri(response.beginArray()), rend(response.endArray()); ri != rend; ++ri) @@ -102,16 +102,16 @@ namespace tut mURIs.push_back(*ri); } return false; - } - }; + } + }; template<> template<> void object::test<1>() { set_test_name("test event"); - // Tests the success and failure cases, since they both use - // the same code paths in the LLAres responder. - ResponseCallback response; + // Tests the success and failure cases, since they both use + // the same code paths in the LLAres responder. + ResponseCallback response; std::string pumpname("trigger"); // Since we're asking LLEventPumps to obtain() the pump by the desired // name, it will persist beyond the current scope, so ensure we @@ -121,15 +121,15 @@ namespace tut boost::bind(&ResponseCallback::operator(), &response, _1))); // Now build an LLSD request that will direct its response events to // that pump. - const std::string testURI("login.bar.com"); + const std::string testURI("login.bar.com"); LLSD request; request["op"] = "rewriteURI"; request["uri"] = testURI; request["reply"] = pumpname; LLEventPumps::instance().obtain("LLAres").post(request); - ensure_equals(response.mURIs.size(), 1); - ensure_equals(response.mURIs.front(), testURI); - } + ensure_equals(response.mURIs.size(), 1); + ensure_equals(response.mURIs.front(), testURI); + } template<> template<> void object::test<2>() diff --git a/indra/llmessage/tests/llavatarnamecache_test.cpp b/indra/llmessage/tests/llavatarnamecache_test.cpp index ec6b65d483..3735f42c47 100644 --- a/indra/llmessage/tests/llavatarnamecache_test.cpp +++ b/indra/llmessage/tests/llavatarnamecache_test.cpp @@ -6,25 +6,25 @@ * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #include "linden_common.h" #include "../llavatarnamecache.h" @@ -33,70 +33,70 @@ namespace tut { - struct avatarnamecache_data - { - }; - typedef test_group<avatarnamecache_data> avatarnamecache_test; - typedef avatarnamecache_test::object avatarnamecache_object; - tut::avatarnamecache_test avatarnamecache_testcase("LLAvatarNameCache"); - - template<> template<> - void avatarnamecache_object::test<1>() - { - bool valid = false; - S32 max_age = 0; - - valid = max_age_from_cache_control("max-age=3600", &max_age); - ensure("typical input valid", valid); - ensure_equals("typical input parsed", max_age, 3600); - - valid = max_age_from_cache_control( - " max-age=600 , no-cache,private=\"stuff\" ", &max_age); - ensure("complex input valid", valid); - ensure_equals("complex input parsed", max_age, 600); - - valid = max_age_from_cache_control( - "no-cache, max-age = 123 ", &max_age); - ensure("complex input 2 valid", valid); - ensure_equals("complex input 2 parsed", max_age, 123); - } - - template<> template<> - void avatarnamecache_object::test<2>() - { - bool valid = false; - S32 max_age = -1; - - valid = max_age_from_cache_control("", &max_age); - ensure("empty input returns invalid", !valid); - ensure_equals("empty input doesn't change val", max_age, -1); - - valid = max_age_from_cache_control("no-cache", &max_age); - ensure("no max-age field returns invalid", !valid); - - valid = max_age_from_cache_control("max", &max_age); - ensure("just 'max' returns invalid", !valid); - - valid = max_age_from_cache_control("max-age", &max_age); - ensure("partial max-age is invalid", !valid); - - valid = max_age_from_cache_control("max-age=", &max_age); - ensure("longer partial max-age is invalid", !valid); - - valid = max_age_from_cache_control("max-age=FOO", &max_age); - ensure("invalid integer max-age is invalid", !valid); - - valid = max_age_from_cache_control("max-age 234", &max_age); - ensure("space separated max-age is invalid", !valid); - - valid = max_age_from_cache_control("max-age=0", &max_age); - ensure("zero max-age is valid", valid); - - // *TODO: Handle "0000" as zero - //valid = max_age_from_cache_control("max-age=0000", &max_age); - //ensure("multi-zero max-age is valid", valid); - - valid = max_age_from_cache_control("max-age=-123", &max_age); - ensure("less than zero max-age is invalid", !valid); - } + struct avatarnamecache_data + { + }; + typedef test_group<avatarnamecache_data> avatarnamecache_test; + typedef avatarnamecache_test::object avatarnamecache_object; + tut::avatarnamecache_test avatarnamecache_testcase("LLAvatarNameCache"); + + template<> template<> + void avatarnamecache_object::test<1>() + { + bool valid = false; + S32 max_age = 0; + + valid = max_age_from_cache_control("max-age=3600", &max_age); + ensure("typical input valid", valid); + ensure_equals("typical input parsed", max_age, 3600); + + valid = max_age_from_cache_control( + " max-age=600 , no-cache,private=\"stuff\" ", &max_age); + ensure("complex input valid", valid); + ensure_equals("complex input parsed", max_age, 600); + + valid = max_age_from_cache_control( + "no-cache, max-age = 123 ", &max_age); + ensure("complex input 2 valid", valid); + ensure_equals("complex input 2 parsed", max_age, 123); + } + + template<> template<> + void avatarnamecache_object::test<2>() + { + bool valid = false; + S32 max_age = -1; + + valid = max_age_from_cache_control("", &max_age); + ensure("empty input returns invalid", !valid); + ensure_equals("empty input doesn't change val", max_age, -1); + + valid = max_age_from_cache_control("no-cache", &max_age); + ensure("no max-age field returns invalid", !valid); + + valid = max_age_from_cache_control("max", &max_age); + ensure("just 'max' returns invalid", !valid); + + valid = max_age_from_cache_control("max-age", &max_age); + ensure("partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=", &max_age); + ensure("longer partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=FOO", &max_age); + ensure("invalid integer max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age 234", &max_age); + ensure("space separated max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=0", &max_age); + ensure("zero max-age is valid", valid); + + // *TODO: Handle "0000" as zero + //valid = max_age_from_cache_control("max-age=0000", &max_age); + //ensure("multi-zero max-age is valid", valid); + + valid = max_age_from_cache_control("max-age=-123", &max_age); + ensure("less than zero max-age is invalid", !valid); + } } diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index d6481d4eea..4caae5f082 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -1,4 +1,4 @@ -/** +/** * @file llcoproceduremanager_test.cpp * @author Brad * @date 2019-02 @@ -7,21 +7,21 @@ * $LicenseInfo:firstyear=2019&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -100,7 +100,7 @@ namespace tut sync.yield(); ensure_equals("coprocedure failed to update foo", foo, 1); - + LLCoprocedureManager::instance().close("PoolName"); } diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp index 1c571a74da..78c195580c 100644 --- a/indra/llmessage/tests/llcurl_stub.cpp +++ b/indra/llmessage/tests/llcurl_stub.cpp @@ -5,21 +5,21 @@ * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -38,18 +38,18 @@ LLCurl::Responder::Responder() void LLCurl::Responder::httpCompleted() { - if (isGoodStatus()) - { - httpSuccess(); - } - else - { - httpFailure(); - } + if (isGoodStatus()) + { + httpSuccess(); + } + else + { + httpFailure(); + } } void LLCurl::Responder::completedRaw(LLChannelDescriptors const&, - std::shared_ptr<LLBufferArray> const&) + std::shared_ptr<LLBufferArray> const&) { } @@ -67,33 +67,33 @@ void LLCurl::Responder::httpSuccess() std::string LLCurl::Responder::dumpResponse() const { - return "dumpResponse()"; + return "dumpResponse()"; } void LLCurl::Responder::successResult(const LLSD& content) { - setResult(HTTP_OK, "", content); - httpSuccess(); + setResult(HTTP_OK, "", content); + httpSuccess(); } void LLCurl::Responder::failureResult(S32 status, const std::string& reason, const LLSD& content) { - setResult(status, reason, content); - httpFailure(); + setResult(status, reason, content); + httpFailure(); } void LLCurl::Responder::completeResult(S32 status, const std::string& reason, const LLSD& content) { - setResult(status, reason, content); - httpCompleted(); + setResult(status, reason, content); + httpCompleted(); } void LLCurl::Responder::setResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */) { - mStatus = status; - mReason = reason; - mContent = content; + mStatus = status; + mReason = reason; + mContent = content; } #endif diff --git a/indra/llmessage/tests/llhost_test.cpp b/indra/llmessage/tests/llhost_test.cpp index efca1bbfca..a66655ad6c 100644 --- a/indra/llmessage/tests/llhost_test.cpp +++ b/indra/llmessage/tests/llhost_test.cpp @@ -7,25 +7,25 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #include "linden_common.h" #include "../llhost.h" @@ -34,238 +34,238 @@ namespace tut { - struct host_data - { - }; - typedef test_group<host_data> host_test; - typedef host_test::object host_object; - tut::host_test host_testcase("LLHost"); - - - template<> template<> - void host_object::test<1>() - { - LLHost host; - ensure("IP address is not NULL", (0 == host.getAddress()) && (0 == host.getPort()) && !host.isOk()); - } - template<> template<> - void host_object::test<2>() - { - U32 ip_addr = 0xc098017d; - U32 port = 8080; - LLHost host(ip_addr, port); - ensure("IP address is invalid", ip_addr == host.getAddress()); - ensure("Port Number is invalid", port == host.getPort()); - ensure("IP address and port number both should be ok", host.isOk()); - } - - template<> template<> - void host_object::test<3>() - { - const char* str = "192.168.1.1"; - U32 port = 8080; - LLHost host(str, port); - ensure("IP address could not be processed", (host.getAddress() == ip_string_to_u32(str))); - ensure("Port Number is invalid", (port == host.getPort())); - } - - template<> template<> - void host_object::test<4>() - { - U32 ip = ip_string_to_u32("192.168.1.1"); - U32 port = 22; - U64 ip_port = (((U64) ip) << 32) | port; - LLHost host(ip_port); - ensure("IP address is invalid", ip == host.getAddress()); - ensure("Port Number is invalid", port == host.getPort()); - } - - template<> template<> - void host_object::test<5>() - { - std::string ip_port_string = "192.168.1.1:8080"; - U32 ip = ip_string_to_u32("192.168.1.1"); - U32 port = 8080; - - LLHost host(ip_port_string); - ensure("IP address from IP:port is invalid", ip == host.getAddress()); - ensure("Port Number from from IP:port is invalid", port == host.getPort()); - } - - template<> template<> - void host_object::test<6>() - { - U32 ip = 0xc098017d, port = 8080; - LLHost host; - host.set(ip,port); - ensure("IP address is invalid", (ip == host.getAddress())); - ensure("Port Number is invalid", (port == host.getPort())); - } - - template<> template<> - void host_object::test<7>() - { - const char* str = "192.168.1.1"; - U32 port = 8080, ip; - LLHost host; - host.set(str,port); - ip = ip_string_to_u32(str); - ensure("IP address is invalid", (ip == host.getAddress())); - ensure("Port Number is invalid", (port == host.getPort())); - - str = "64.233.187.99"; - ip = ip_string_to_u32(str); - host.setAddress(str); - ensure("IP address is invalid", (ip == host.getAddress())); - - ip = 0xc098017b; - host.setAddress(ip); - ensure("IP address is invalid", (ip == host.getAddress())); - // should still use the old port - ensure("Port Number is invalid", (port == host.getPort())); - - port = 8084; - host.setPort(port); - ensure("Port Number is invalid", (port == host.getPort())); - // should still use the old address - ensure("IP address is invalid", (ip == host.getAddress())); - } - - template<> template<> - void host_object::test<8>() - { - const std::string str("192.168.1.1"); - U32 port = 8080; - LLHost host; - host.set(str,port); - - std::string ip_string = host.getIPString(); - ensure("Function Failed", (ip_string == str)); - - std::string ip_string_port = host.getIPandPort(); - ensure("Function Failed", (ip_string_port == "192.168.1.1:8080")); - } - - -// getHostName() and setHostByName - template<> template<> - void host_object::test<9>() - { - skip("this test is irreparably flaky"); -// skip("setHostByName(\"google.com\"); getHostName() -> (e.g.) \"yx-in-f100.1e100.net\""); - // nat: is it reasonable to expect LLHost::getHostName() to echo - // back something resembling the string passed to setHostByName()? - // - // If that's not even reasonable, would a round trip in the /other/ - // direction make more sense? (Call getHostName() for something with - // known IP address; call setHostByName(); verify IP address) - // - // Failing that... is there a plausible way to test getHostName() and - // setHostByName()? Hopefully without putting up a dummy local DNS - // server? - - // monty: If you don't control the DNS server or the DNS configuration - // for the test point then, no, none of these will necessarily be - // reliable and may start to fail at any time. Forward translation - // is subject to CNAME records and round-robin address assignment. - // Reverse lookup is 1-to-many and is more and more likely to have - // nothing to do with the forward translation. - // - // So the test is increasingly meaningless on a real network. - - std::string hostStr = "lindenlab.com"; - LLHost host; - host.setHostByName(hostStr); - - // reverse DNS will likely result in appending of some - // sub-domain to the main hostname. so look for - // the main domain name and not do the exact compare - - std::string hostname = host.getHostName(); - try - { - ensure("getHostName failed", hostname.find(hostStr) != std::string::npos); - } - catch (const std::exception&) - { - std::cerr << "set '" << hostStr << "'; reported '" << hostname << "'" << std::endl; - throw; - } - } - -// setHostByName for dotted IP - template<> template<> - void host_object::test<10>() - { - std::string hostStr = "64.233.167.99"; - LLHost host; - host.setHostByName(hostStr); - ensure("SetHostByName for dotted IP Address failed", host.getAddress() == ip_string_to_u32(hostStr.c_str())); - } - - template<> template<> - void host_object::test<11>() - { - LLHost host1(0xc098017d, 8080); - LLHost host2 = host1; - ensure("Both IP addresses are not same", (host1.getAddress() == host2.getAddress())); - ensure("Both port numbers are not same", (host1.getPort() == host2.getPort())); - } - - template<> template<> - void host_object::test<12>() - { - LLHost host1("192.168.1.1", 8080); - std::string str1 = "192.168.1.1:8080"; - std::ostringstream stream; - stream << host1; - ensure("Operator << failed", ( stream.str()== str1)); - - // There is no istream >> llhost operator. - //std::istringstream is(stream.str()); - //LLHost host2; - //is >> host2; - //ensure("Operator >> failed. Not compatible with <<", host1 == host2); - } - - // operators ==, !=, < - template<> template<> - void host_object::test<13>() - { - U32 ip_addr = 0xc098017d; - U32 port = 8080; - LLHost host1(ip_addr, port); - LLHost host2(ip_addr, port); - ensure("operator== failed", host1 == host2); - - // change port - host2.setPort(7070); - ensure("operator!= failed", host1 != host2); - - // set port back to 8080 and change IP address now - host2.setPort(8080); - host2.setAddress(ip_addr+10); - ensure("operator!= failed", host1 != host2); - - ensure("operator< failed", host1 < host2); - - // set IP address back to same value and change port - host2.setAddress(ip_addr); - host2.setPort(host1.getPort() + 10); - ensure("operator< failed", host1 < host2); - } - - // invalid ip address string - template<> template<> - void host_object::test<14>() - { - LLHost host1("10.0.1.2", 6143); - ensure("10.0.1.2 should be a valid address", host1.isOk()); - - LLHost host2("booger-brains", 6143); - ensure("booger-brains should be an invalid ip addess", !host2.isOk()); - - LLHost host3("255.255.255.255", 6143); - ensure("255.255.255.255 should be valid broadcast address", host3.isOk()); - } + struct host_data + { + }; + typedef test_group<host_data> host_test; + typedef host_test::object host_object; + tut::host_test host_testcase("LLHost"); + + + template<> template<> + void host_object::test<1>() + { + LLHost host; + ensure("IP address is not NULL", (0 == host.getAddress()) && (0 == host.getPort()) && !host.isOk()); + } + template<> template<> + void host_object::test<2>() + { + U32 ip_addr = 0xc098017d; + U32 port = 8080; + LLHost host(ip_addr, port); + ensure("IP address is invalid", ip_addr == host.getAddress()); + ensure("Port Number is invalid", port == host.getPort()); + ensure("IP address and port number both should be ok", host.isOk()); + } + + template<> template<> + void host_object::test<3>() + { + const char* str = "192.168.1.1"; + U32 port = 8080; + LLHost host(str, port); + ensure("IP address could not be processed", (host.getAddress() == ip_string_to_u32(str))); + ensure("Port Number is invalid", (port == host.getPort())); + } + + template<> template<> + void host_object::test<4>() + { + U32 ip = ip_string_to_u32("192.168.1.1"); + U32 port = 22; + U64 ip_port = (((U64) ip) << 32) | port; + LLHost host(ip_port); + ensure("IP address is invalid", ip == host.getAddress()); + ensure("Port Number is invalid", port == host.getPort()); + } + + template<> template<> + void host_object::test<5>() + { + std::string ip_port_string = "192.168.1.1:8080"; + U32 ip = ip_string_to_u32("192.168.1.1"); + U32 port = 8080; + + LLHost host(ip_port_string); + ensure("IP address from IP:port is invalid", ip == host.getAddress()); + ensure("Port Number from from IP:port is invalid", port == host.getPort()); + } + + template<> template<> + void host_object::test<6>() + { + U32 ip = 0xc098017d, port = 8080; + LLHost host; + host.set(ip,port); + ensure("IP address is invalid", (ip == host.getAddress())); + ensure("Port Number is invalid", (port == host.getPort())); + } + + template<> template<> + void host_object::test<7>() + { + const char* str = "192.168.1.1"; + U32 port = 8080, ip; + LLHost host; + host.set(str,port); + ip = ip_string_to_u32(str); + ensure("IP address is invalid", (ip == host.getAddress())); + ensure("Port Number is invalid", (port == host.getPort())); + + str = "64.233.187.99"; + ip = ip_string_to_u32(str); + host.setAddress(str); + ensure("IP address is invalid", (ip == host.getAddress())); + + ip = 0xc098017b; + host.setAddress(ip); + ensure("IP address is invalid", (ip == host.getAddress())); + // should still use the old port + ensure("Port Number is invalid", (port == host.getPort())); + + port = 8084; + host.setPort(port); + ensure("Port Number is invalid", (port == host.getPort())); + // should still use the old address + ensure("IP address is invalid", (ip == host.getAddress())); + } + + template<> template<> + void host_object::test<8>() + { + const std::string str("192.168.1.1"); + U32 port = 8080; + LLHost host; + host.set(str,port); + + std::string ip_string = host.getIPString(); + ensure("Function Failed", (ip_string == str)); + + std::string ip_string_port = host.getIPandPort(); + ensure("Function Failed", (ip_string_port == "192.168.1.1:8080")); + } + + +// getHostName() and setHostByName + template<> template<> + void host_object::test<9>() + { + skip("this test is irreparably flaky"); +// skip("setHostByName(\"google.com\"); getHostName() -> (e.g.) \"yx-in-f100.1e100.net\""); + // nat: is it reasonable to expect LLHost::getHostName() to echo + // back something resembling the string passed to setHostByName()? + // + // If that's not even reasonable, would a round trip in the /other/ + // direction make more sense? (Call getHostName() for something with + // known IP address; call setHostByName(); verify IP address) + // + // Failing that... is there a plausible way to test getHostName() and + // setHostByName()? Hopefully without putting up a dummy local DNS + // server? + + // monty: If you don't control the DNS server or the DNS configuration + // for the test point then, no, none of these will necessarily be + // reliable and may start to fail at any time. Forward translation + // is subject to CNAME records and round-robin address assignment. + // Reverse lookup is 1-to-many and is more and more likely to have + // nothing to do with the forward translation. + // + // So the test is increasingly meaningless on a real network. + + std::string hostStr = "lindenlab.com"; + LLHost host; + host.setHostByName(hostStr); + + // reverse DNS will likely result in appending of some + // sub-domain to the main hostname. so look for + // the main domain name and not do the exact compare + + std::string hostname = host.getHostName(); + try + { + ensure("getHostName failed", hostname.find(hostStr) != std::string::npos); + } + catch (const std::exception&) + { + std::cerr << "set '" << hostStr << "'; reported '" << hostname << "'" << std::endl; + throw; + } + } + +// setHostByName for dotted IP + template<> template<> + void host_object::test<10>() + { + std::string hostStr = "64.233.167.99"; + LLHost host; + host.setHostByName(hostStr); + ensure("SetHostByName for dotted IP Address failed", host.getAddress() == ip_string_to_u32(hostStr.c_str())); + } + + template<> template<> + void host_object::test<11>() + { + LLHost host1(0xc098017d, 8080); + LLHost host2 = host1; + ensure("Both IP addresses are not same", (host1.getAddress() == host2.getAddress())); + ensure("Both port numbers are not same", (host1.getPort() == host2.getPort())); + } + + template<> template<> + void host_object::test<12>() + { + LLHost host1("192.168.1.1", 8080); + std::string str1 = "192.168.1.1:8080"; + std::ostringstream stream; + stream << host1; + ensure("Operator << failed", ( stream.str()== str1)); + + // There is no istream >> llhost operator. + //std::istringstream is(stream.str()); + //LLHost host2; + //is >> host2; + //ensure("Operator >> failed. Not compatible with <<", host1 == host2); + } + + // operators ==, !=, < + template<> template<> + void host_object::test<13>() + { + U32 ip_addr = 0xc098017d; + U32 port = 8080; + LLHost host1(ip_addr, port); + LLHost host2(ip_addr, port); + ensure("operator== failed", host1 == host2); + + // change port + host2.setPort(7070); + ensure("operator!= failed", host1 != host2); + + // set port back to 8080 and change IP address now + host2.setPort(8080); + host2.setAddress(ip_addr+10); + ensure("operator!= failed", host1 != host2); + + ensure("operator< failed", host1 < host2); + + // set IP address back to same value and change port + host2.setAddress(ip_addr); + host2.setPort(host1.getPort() + 10); + ensure("operator< failed", host1 < host2); + } + + // invalid ip address string + template<> template<> + void host_object::test<14>() + { + LLHost host1("10.0.1.2", 6143); + ensure("10.0.1.2 should be a valid address", host1.isOk()); + + LLHost host2("booger-brains", 6143); + ensure("booger-brains should be an invalid ip addess", !host2.isOk()); + + LLHost host3("255.255.255.255", 6143); + ensure("255.255.255.255 should be valid broadcast address", host3.isOk()); + } } diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp index 78faa66a0d..1881144d3e 100644 --- a/indra/llmessage/tests/llhttpclient_test.cpp +++ b/indra/llmessage/tests/llhttpclient_test.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llhttpclient_test.cpp * @brief Testing the HTTP client classes. * * $LicenseInfo:firstyear=2006&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -47,265 +47,265 @@ namespace tut { - struct HTTPClientTestData - { - public: - HTTPClientTestData(): - PORT(LLStringUtil::getenv("PORT")), - // Turning NULL PORT into empty string doesn't make things work; - // that's just to keep this initializer from blowing up. We test - // PORT separately in the constructor body. - local_server(STRINGIZE("http://127.0.0.1:" << PORT << "/")) - { - ensure("Set environment variable PORT to local test server port", !PORT.empty()); - apr_pool_create(&mPool, NULL); - LLCurl::initClass(false); - mClientPump = new LLPumpIO(mPool); - - LLHTTPClient::setPump(*mClientPump); - } - - ~HTTPClientTestData() - { - delete mClientPump; - SUBSYSTEM_CLEANUP(LLProxy); - apr_pool_destroy(mPool); - } - - void runThePump(float timeout = 100.0f) - { - LLTimer timer; - timer.setTimerExpirySec(timeout); - - while(!mSawCompleted && !mSawCompletedHeader && !timer.hasExpired()) - { - LLFrameTimer::updateFrameTime(); - if (mClientPump) - { - mClientPump->pump(); - mClientPump->callback(); - } - } - } - - const std::string PORT; - const std::string local_server; - - private: - apr_pool_t* mPool; - LLPumpIO* mClientPump; - - protected: - void ensureStatusOK() - { - if (mSawError) - { - std::string msg = - llformat("httpFailure() called when not expected, status %d", - mStatus); - fail(msg); - } - } - - void ensureStatusError() - { - if (!mSawError) - { - fail("httpFailure() wasn't called"); - } - } - - LLSD getResult() - { - return mResult; - } - LLSD getHeader() - { - return mHeader; - } - - protected: - bool mSawError; - U32 mStatus; - std::string mReason; - bool mSawCompleted; - bool mSawCompletedHeader; - LLSD mResult; - LLSD mHeader; - bool mResultDeleted; - - class Result : public LLHTTPClient::Responder - { - protected: - Result(HTTPClientTestData& client) - : mClient(client) - { - } - - public: - static Result* build(HTTPClientTestData& client) - { - return new Result(client); - } - - ~Result() - { - mClient.mResultDeleted = true; - } - - protected: - virtual void httpFailure() - { - mClient.mSawError = true; - mClient.mStatus = getStatus(); - mClient.mReason = getReason(); - } - - virtual void httpSuccess() - { - mClient.mResult = getContent(); - } - - virtual void httpCompleted() - { - LLHTTPClient::Responder::httpCompleted(); - - mClient.mSawCompleted = true; - mClient.mSawCompletedHeader = true; - mClient.mHeader = getResponseHeaders(); - } - - private: - HTTPClientTestData& mClient; - }; - - friend class Result; - - protected: - LLHTTPClient::ResponderPtr newResult() - { - mSawError = false; - mStatus = 0; - mSawCompleted = false; - mSawCompletedHeader = false; - mResult.clear(); - mHeader.clear(); - mResultDeleted = false; - - return Result::build(*this); - } - }; - - - typedef test_group<HTTPClientTestData> HTTPClientTestGroup; - typedef HTTPClientTestGroup::object HTTPClientTestObject; - HTTPClientTestGroup httpClientTestGroup("http_client"); - - template<> template<> - void HTTPClientTestObject::test<1>() - { - LLHTTPClient::get(local_server, newResult()); - runThePump(); - ensureStatusOK(); - ensure("result object wasn't destroyed", mResultDeleted); - } - - template<> template<> - void HTTPClientTestObject::test<2>() - { - // Please nobody listen on this particular port... - LLHTTPClient::get("http://127.0.0.1:7950", newResult()); - runThePump(); - ensureStatusError(); - } - - template<> template<> - void HTTPClientTestObject::test<3>() - { - LLSD sd; - - sd["list"][0]["one"] = 1; - sd["list"][0]["two"] = 2; - sd["list"][1]["three"] = 3; - sd["list"][1]["four"] = 4; - - LLHTTPClient::post(local_server + "web/echo", sd, newResult()); - runThePump(); - ensureStatusOK(); - ensure_equals("echoed result matches", getResult(), sd); - } - - template<> template<> - void HTTPClientTestObject::test<4>() - { - LLSD sd; - - sd["message"] = "This is my test message."; - - LLHTTPClient::put(local_server + "test/storage", sd, newResult()); - runThePump(); - ensureStatusOK(); - - LLHTTPClient::get(local_server + "test/storage", newResult()); - runThePump(); - ensureStatusOK(); - ensure_equals("echoed result matches", getResult(), sd); - - } - - template<> template<> - void HTTPClientTestObject::test<5>() - { - LLSD sd; - sd["status"] = 543; - sd["reason"] = "error for testing"; - - LLHTTPClient::post(local_server + "test/error", sd, newResult()); - runThePump(); - ensureStatusError(); - ensure_contains("reason", mReason, sd["reason"]); - } - - template<> template<> - void HTTPClientTestObject::test<6>() - { - const F32 timeout = 1.0f; - LLHTTPClient::get(local_server + "test/timeout", newResult(), LLSD(), timeout); - runThePump(timeout * 5.0f); - ensureStatusError(); - ensure_equals("reason", mReason, "STATUS_EXPIRED"); - } - - template<> template<> - void HTTPClientTestObject::test<7>() - { - LLHTTPClient::get(local_server, newResult()); - runThePump(); - ensureStatusOK(); - LLSD expected = getResult(); - - LLSD result; - result = LLHTTPClient::blockingGet(local_server); - LLSD body = result["body"]; - ensure_equals("echoed result matches", body.size(), expected.size()); - } - template<> template<> - void HTTPClientTestObject::test<8>() - { - // This is testing for the presence of the Header in the returned results - // from an HTTP::get call. - LLHTTPClient::get(local_server, newResult()); - runThePump(); - ensureStatusOK(); - LLSD header = getHeader(); - ensure("got a header", ! header.emptyMap().asBoolean()); - } - template<> template<> - void HTTPClientTestObject::test<9>() - { - LLHTTPClient::head(local_server, newResult()); - runThePump(); - ensureStatusOK(); - ensure("result object wasn't destroyed", mResultDeleted); - } + struct HTTPClientTestData + { + public: + HTTPClientTestData(): + PORT(LLStringUtil::getenv("PORT")), + // Turning NULL PORT into empty string doesn't make things work; + // that's just to keep this initializer from blowing up. We test + // PORT separately in the constructor body. + local_server(STRINGIZE("http://127.0.0.1:" << PORT << "/")) + { + ensure("Set environment variable PORT to local test server port", !PORT.empty()); + apr_pool_create(&mPool, NULL); + LLCurl::initClass(false); + mClientPump = new LLPumpIO(mPool); + + LLHTTPClient::setPump(*mClientPump); + } + + ~HTTPClientTestData() + { + delete mClientPump; + SUBSYSTEM_CLEANUP(LLProxy); + apr_pool_destroy(mPool); + } + + void runThePump(float timeout = 100.0f) + { + LLTimer timer; + timer.setTimerExpirySec(timeout); + + while(!mSawCompleted && !mSawCompletedHeader && !timer.hasExpired()) + { + LLFrameTimer::updateFrameTime(); + if (mClientPump) + { + mClientPump->pump(); + mClientPump->callback(); + } + } + } + + const std::string PORT; + const std::string local_server; + + private: + apr_pool_t* mPool; + LLPumpIO* mClientPump; + + protected: + void ensureStatusOK() + { + if (mSawError) + { + std::string msg = + llformat("httpFailure() called when not expected, status %d", + mStatus); + fail(msg); + } + } + + void ensureStatusError() + { + if (!mSawError) + { + fail("httpFailure() wasn't called"); + } + } + + LLSD getResult() + { + return mResult; + } + LLSD getHeader() + { + return mHeader; + } + + protected: + bool mSawError; + U32 mStatus; + std::string mReason; + bool mSawCompleted; + bool mSawCompletedHeader; + LLSD mResult; + LLSD mHeader; + bool mResultDeleted; + + class Result : public LLHTTPClient::Responder + { + protected: + Result(HTTPClientTestData& client) + : mClient(client) + { + } + + public: + static Result* build(HTTPClientTestData& client) + { + return new Result(client); + } + + ~Result() + { + mClient.mResultDeleted = true; + } + + protected: + virtual void httpFailure() + { + mClient.mSawError = true; + mClient.mStatus = getStatus(); + mClient.mReason = getReason(); + } + + virtual void httpSuccess() + { + mClient.mResult = getContent(); + } + + virtual void httpCompleted() + { + LLHTTPClient::Responder::httpCompleted(); + + mClient.mSawCompleted = true; + mClient.mSawCompletedHeader = true; + mClient.mHeader = getResponseHeaders(); + } + + private: + HTTPClientTestData& mClient; + }; + + friend class Result; + + protected: + LLHTTPClient::ResponderPtr newResult() + { + mSawError = false; + mStatus = 0; + mSawCompleted = false; + mSawCompletedHeader = false; + mResult.clear(); + mHeader.clear(); + mResultDeleted = false; + + return Result::build(*this); + } + }; + + + typedef test_group<HTTPClientTestData> HTTPClientTestGroup; + typedef HTTPClientTestGroup::object HTTPClientTestObject; + HTTPClientTestGroup httpClientTestGroup("http_client"); + + template<> template<> + void HTTPClientTestObject::test<1>() + { + LLHTTPClient::get(local_server, newResult()); + runThePump(); + ensureStatusOK(); + ensure("result object wasn't destroyed", mResultDeleted); + } + + template<> template<> + void HTTPClientTestObject::test<2>() + { + // Please nobody listen on this particular port... + LLHTTPClient::get("http://127.0.0.1:7950", newResult()); + runThePump(); + ensureStatusError(); + } + + template<> template<> + void HTTPClientTestObject::test<3>() + { + LLSD sd; + + sd["list"][0]["one"] = 1; + sd["list"][0]["two"] = 2; + sd["list"][1]["three"] = 3; + sd["list"][1]["four"] = 4; + + LLHTTPClient::post(local_server + "web/echo", sd, newResult()); + runThePump(); + ensureStatusOK(); + ensure_equals("echoed result matches", getResult(), sd); + } + + template<> template<> + void HTTPClientTestObject::test<4>() + { + LLSD sd; + + sd["message"] = "This is my test message."; + + LLHTTPClient::put(local_server + "test/storage", sd, newResult()); + runThePump(); + ensureStatusOK(); + + LLHTTPClient::get(local_server + "test/storage", newResult()); + runThePump(); + ensureStatusOK(); + ensure_equals("echoed result matches", getResult(), sd); + + } + + template<> template<> + void HTTPClientTestObject::test<5>() + { + LLSD sd; + sd["status"] = 543; + sd["reason"] = "error for testing"; + + LLHTTPClient::post(local_server + "test/error", sd, newResult()); + runThePump(); + ensureStatusError(); + ensure_contains("reason", mReason, sd["reason"]); + } + + template<> template<> + void HTTPClientTestObject::test<6>() + { + const F32 timeout = 1.0f; + LLHTTPClient::get(local_server + "test/timeout", newResult(), LLSD(), timeout); + runThePump(timeout * 5.0f); + ensureStatusError(); + ensure_equals("reason", mReason, "STATUS_EXPIRED"); + } + + template<> template<> + void HTTPClientTestObject::test<7>() + { + LLHTTPClient::get(local_server, newResult()); + runThePump(); + ensureStatusOK(); + LLSD expected = getResult(); + + LLSD result; + result = LLHTTPClient::blockingGet(local_server); + LLSD body = result["body"]; + ensure_equals("echoed result matches", body.size(), expected.size()); + } + template<> template<> + void HTTPClientTestObject::test<8>() + { + // This is testing for the presence of the Header in the returned results + // from an HTTP::get call. + LLHTTPClient::get(local_server, newResult()); + runThePump(); + ensureStatusOK(); + LLSD header = getHeader(); + ensure("got a header", ! header.emptyMap().asBoolean()); + } + template<> template<> + void HTTPClientTestObject::test<9>() + { + LLHTTPClient::head(local_server, newResult()); + runThePump(); + ensureStatusOK(); + ensure("result object wasn't destroyed", mResultDeleted); + } } diff --git a/indra/llmessage/tests/llhttpnode_stub.cpp b/indra/llmessage/tests/llhttpnode_stub.cpp index 479a256bdd..d896084021 100644 --- a/indra/llmessage/tests/llhttpnode_stub.cpp +++ b/indra/llmessage/tests/llhttpnode_stub.cpp @@ -1,26 +1,26 @@ -/** +/** * @file llhttpnode_stub.cpp * @brief STUB Implementation of classes for generic HTTP/LSL/REST handling. * * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * + * * Second Life Viewer Source Code * Copyright (c) 2006-2009, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -69,28 +69,28 @@ const LLHTTPNode* LLHTTPNode::findNode(const std::string& name) const { return N LLHTTPNode::Response::~Response(){} void LLHTTPNode::Response::notFound(const std::string& message) { - status(404, message); + status(404, message); } void LLHTTPNode::Response::notFound() { - status(404, "Not Found"); + status(404, "Not Found"); } void LLHTTPNode::Response::methodNotAllowed() { - status(405, "Method Not Allowed"); + status(405, "Method Not Allowed"); } void LLHTTPNode::Response::statusUnknownError(S32 code) { - status(code, "Unknown Error"); + status(code, "Unknown Error"); } void LLHTTPNode::Response::status(S32 code, const std::string& message) { } -void LLHTTPNode::Response::addHeader(const std::string& name,const std::string& value) +void LLHTTPNode::Response::addHeader(const std::string& name,const std::string& value) { - mHeaders[name] = value; + mHeaders[name] = value; } void LLHTTPNode::describe(Description& desc) const { } diff --git a/indra/llmessage/tests/llmockhttpclient.h b/indra/llmessage/tests/llmockhttpclient.h index af26bf8803..1611ab7bd8 100644 --- a/indra/llmessage/tests/llmockhttpclient.h +++ b/indra/llmessage/tests/llmockhttpclient.h @@ -1,25 +1,25 @@ -/** - * @file - * @brief +/** + * @file + * @brief * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -45,19 +45,19 @@ public: template<typename T> struct ResponderType { - bool operator()(LLCurl::ResponderPtr ptr) const - { - T* p = dynamic_cast<T*>(ptr.get()); - return p != NULL; - } + bool operator()(LLCurl::ResponderPtr ptr) const + { + T* p = dynamic_cast<T*>(ptr.get()); + return p != NULL; + } }; inline bool operator==(const LLSD& l, const LLSD& r) { - std::ostringstream ls, rs; - ls << l; - rs << r; - return ls.str() == rs.str(); + std::ostringstream ls, rs; + ls << l; + rs << r; + return ls.str() == rs.str(); } diff --git a/indra/llmessage/tests/llnamevalue_test.cpp b/indra/llmessage/tests/llnamevalue_test.cpp index 8902fdd2e8..f77cd102f4 100644 --- a/indra/llmessage/tests/llnamevalue_test.cpp +++ b/indra/llmessage/tests/llnamevalue_test.cpp @@ -1,4 +1,4 @@ -/** +/** * @file llnamevalue_test.cpp * @author Adroit * @date 2007-02 @@ -7,21 +7,21 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -41,366 +41,366 @@ namespace tut { - struct namevalue_test - { - namevalue_test() - { - } - }; - typedef test_group<namevalue_test> namevalue_t; - typedef namevalue_t::object namevalue_object_t; - tut::namevalue_t tut_namevalue("LLNameValue"); - - - template<> template<> - void namevalue_object_t::test<1>() - { - // LLNameValue() - LLNameValue nValue; - ensure("mName should have been NULL", nValue.mName == NULL); - ensure("getTypeEnum failed",nValue.getTypeEnum() == NVT_NULL); - ensure("getClassEnum failed",nValue.getClassEnum() == NVC_NULL); - ensure("getSendtoEnum failed",nValue.getSendtoEnum() == NVS_NULL); - - LLNameValue nValue1(" SecondLife ASSET RW SIM 232324343"); - - } - - // LLNameValue(const char* data); - // LLNameValue(const char* name, const char* data, const char* type, const char* nvclass, const char* nvsendto, - // TNameValueCallback nvcb = NULL, void** user_data = NULL); - template<> template<> - void namevalue_object_t::test<2>() - { - LLNameValue nValue(" SecondLife ASSET RW S 232324343"); - ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); - ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); - ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); - ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); - ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); - ensure("sendToData or sendToViewer failed", !nValue.sendToData() && !nValue.sendToViewer()); - - LLNameValue nValue1("\n\r SecondLife_1 STRING READ_WRITE SIM 232324343"); - ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife_1"))); - ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); - ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); - ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); - ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); - ensure("1. sendToData or sendToViewer failed", !nValue1.sendToData() && !nValue1.sendToViewer()); - - LLNameValue nValue2("SecondLife", "23.5", "F32", "R", "DS"); - ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); - ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); - ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_DATA_SIM); - ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); - ensure("2. sendToData or sendToViewer failed", nValue2.sendToData() && !nValue2.sendToViewer()); - - LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY", "SIM_SPACE"); - ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); - ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); - ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_DATA_SIM); - ensure("3. getS32 failed", *nValue3.getS32() == -43456787); - ensure("sendToData or sendToViewer failed", nValue3.sendToData() && !nValue3.sendToViewer()); - - LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW", "SV"); - LLVector3 llvec4(1.0, 2.0, 3.0); - ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); - ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); - ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM_VIEWER); - ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); - ensure("4. sendToData or sendToViewer failed", !nValue4.sendToData() && nValue4.sendToViewer()); - - LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW", "SIM_VIEWER"); - LLVector3 llvec5(-1.0f, 2.4f, 3); - ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); - ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); - ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM_VIEWER); - ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); - ensure("5. sendToData or sendToViewer failed", !nValue5.sendToData() && nValue5.sendToViewer()); - - LLNameValue nValue6("SecondLife", "89764323", "U32", "RW", "DSV"); - ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); - ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); - ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_DATA_SIM_VIEWER); - ensure("6. getU32 failed", *nValue6.getU32() == 89764323); - ensure("6. sendToData or sendToViewer failed", nValue6.sendToData() && nValue6.sendToViewer()); - - LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW", "SIM_SPACE_VIEWER"); - U64 u64_7 = U64L(89764323323232); - ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); - ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); - ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_DATA_SIM_VIEWER); - ensure("7. getU32 failed", *nValue7.getU64() == u64_7); - ensure("7. sendToData or sendToViewer failed", nValue7.sendToData() && nValue7.sendToViewer()); - } - - // LLNameValue(const char* name, const char* data, const char* type, const char* nvclass, - // TNameValueCallback nvcb = NULL, void** user_data = NULL); - template<> template<> - void namevalue_object_t::test<3>() - { - LLNameValue nValue("SecondLife", "232324343", "ASSET", "READ_WRITE"); - ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); - ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); - ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); - ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); - ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); - - LLNameValue nValue1("SecondLife", "232324343", "STRING", "READ_WRITE"); - ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife"))); - ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); - ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); - ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); - ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); - - LLNameValue nValue2("SecondLife", "23.5", "F32", "R"); - ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); - ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); - ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_SIM); - ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); - - LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY"); - ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); - ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); - ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); - ensure("3. getS32 failed", *nValue3.getS32() == -43456787); - - LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW"); - LLVector3 llvec4(1.0, 2.0, 3.0); - ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); - ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); - ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); - ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); - - LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW"); - LLVector3 llvec5(-1.0f, 2.4f, 3); - ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); - ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); - ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM); - ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); - - LLNameValue nValue6("SecondLife", "89764323", "U32", "RW"); - ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); - ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); - ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); - ensure("6. getU32 failed", *nValue6.getU32() == 89764323); - - LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW"); - U64 u64_7 = U64L(89764323323232); - ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); - ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); - ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); - ensure("7. getU32 failed", *nValue7.getU64() == u64_7); - } - - // LLNameValue(const char* name, const char* type, const char* nvclass, - // TNameValueCallback nvcb = NULL, void** user_data = NULL); - template<> template<> - void namevalue_object_t::test<4>() - { - LLNameValue nValue("SecondLife", "STRING", "READ_WRITE"); - ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); - ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_STRING); - ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); - ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue1("SecondLife", "ASSET", "READ_WRITE"); - ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife"))); - ensure("1. getTypeEnum for RW failed", nValue1.getTypeEnum() == NVT_ASSET); - ensure("1. getClassEnum for RW failed", nValue1.getClassEnum() == NVC_READ_WRITE); - ensure("1. getSendtoEnum for RW failed", nValue1.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue2("SecondLife", "F32", "READ_ONLY"); - ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); - ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); - ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue3("SecondLife", "S32", "READ_ONLY"); - ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); - ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); - ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue4("SecondLife", "VEC3", "READ_WRITE"); - ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); - ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); - ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue6("SecondLife", "U32", "READ_WRITE"); - ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); - ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); - ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); - - LLNameValue nValue7("SecondLife", "U64", "READ_WRITE"); - ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); - ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); - ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); - } - - template<> template<> - void namevalue_object_t::test<5>() - { - LLNameValue nValue("SecondLife", "This is a test", "STRING", "RW", "SIM"); - - ensure("getString failed", (0 == strcmp(nValue.getString(),"This is a test"))); - } - - template<> template<> - void namevalue_object_t::test<6>() - { - LLNameValue nValue("SecondLife", "This is a test", "ASSET", "RW", "S"); - ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); - } - - template<> template<> - void namevalue_object_t::test<7>() - { - LLNameValue nValue("SecondLife", "555555", "F32", "RW", "SIM"); - - ensure("getF32 failed",*nValue.getF32() == 555555.f); - } - - template<> template<> - void namevalue_object_t::test<8>() - { - LLNameValue nValue("SecondLife", "-5555", "S32", "RW", "SIM"); - - ensure("getS32 failed", *nValue.getS32() == -5555); - - S32 sVal = 0x7FFFFFFF; - nValue.setS32(sVal); - ensure("getS32 failed", *nValue.getS32() == sVal); - - sVal = -0x7FFFFFFF; - nValue.setS32(sVal); - ensure("getS32 failed", *nValue.getS32() == sVal); - - sVal = 0; - nValue.setS32(sVal); - ensure("getS32 failed", *nValue.getS32() == sVal); - } - - template<> template<> - void namevalue_object_t::test<9>() - { - LLNameValue nValue("SecondLife", "<-3, 2, 1>", "VEC3", "RW", "SIM"); - LLVector3 vecExpected(-3, 2, 1); - LLVector3 vec; - nValue.getVec3(vec); - ensure("getVec3 failed", vec == vecExpected); - } - - template<> template<> - void namevalue_object_t::test<10>() - { - LLNameValue nValue("SecondLife", "12345678", "U32", "RW", "SIM"); - - ensure("getU32 failed",*nValue.getU32() == 12345678); - - U32 val = 0xFFFFFFFF; - nValue.setU32(val); - ensure("U32 max", *nValue.getU32() == val); - - val = 0; - nValue.setU32(val); - ensure("U32 min", *nValue.getU32() == val); - } - - template<> template<> - void namevalue_object_t::test<11>() - { - //skip_fail("incomplete support for U64."); - LLNameValue nValue("SecondLife", "44444444444", "U64", "RW", "SIM"); - - ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); - - // there is no LLNameValue::setU64() - } - - - template<> template<> - void namevalue_object_t::test<12>() - { - //skip_fail("incomplete support for U64."); - LLNameValue nValue("SecondLife U64 RW DSV 44444444444"); - std::string ret_str = nValue.printNameValue(); - - ensure_equals("1:printNameValue failed",ret_str,"SecondLife U64 RW DSV 44444444444"); - - LLNameValue nValue1(ret_str.c_str()); - ensure_equals("Serialization of printNameValue failed", *nValue.getU64(), *nValue1.getU64()); - } - - template<> template<> - void namevalue_object_t::test<13>() - { - LLNameValue nValue("SecondLife STRING RW DSV 44444444444"); - std::string ret_str = nValue.printData(); - ensure_equals("1:printData failed",ret_str,"44444444444"); - - LLNameValue nValue1("SecondLife S32 RW DSV 44444"); - ret_str = nValue1.printData(); - ensure_equals("2:printData failed",ret_str,"44444"); - } - - template<> template<> - void namevalue_object_t::test<14>() - { - LLNameValue nValue("SecodLife STRING RW SIM 22222"); - std::ostringstream stream1,stream2,stream3, stream4, stream5; - stream1 << nValue; - ensure_equals("STRING << failed",stream1.str(),"22222"); - - LLNameValue nValue1("SecodLife F32 RW SIM 22222"); - stream2 << nValue1; - ensure_equals("F32 << failed",stream2.str(),"22222"); - - LLNameValue nValue2("SecodLife S32 RW SIM 22222"); - stream3<< nValue2; - ensure_equals("S32 << failed",stream3.str(),"22222"); - - LLNameValue nValue3("SecodLife U32 RW SIM 122222"); - stream4<< nValue3; - ensure_equals("U32 << failed",stream4.str(),"122222"); - - // I don't think we use U64 name value pairs. JC - //skip_fail("incomplete support for U64."); - //LLNameValue nValue4("SecodLife U64 RW SIM 22222"); - //stream5<< nValue4; - //ensure("U64 << failed",0 == strcmp((stream5.str()).c_str(),"22222")); - } - - template<> template<> - void namevalue_object_t::test<15>() - { - LLNameValue nValue("SecondLife", "This is a test", "ASSET", "R", "S"); - - ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); - // this should not have updated as it is read only. - nValue.setAsset("New Value should not be updated"); - ensure("setAsset on ReadOnly failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); - - LLNameValue nValue1("SecondLife", "1234", "U32", "R", "S"); - // this should not have updated as it is read only. - nValue1.setU32(4567); - ensure("setU32 on ReadOnly failed", *nValue1.getU32() == 1234); - - LLNameValue nValue2("SecondLife", "1234", "S32", "R", "S"); - // this should not have updated as it is read only. - nValue2.setS32(4567); - ensure("setS32 on ReadOnly failed", *nValue2.getS32() == 1234); - - LLNameValue nValue3("SecondLife", "1234", "F32", "R", "S"); - // this should not have updated as it is read only. - nValue3.setF32(4567); - ensure("setF32 on ReadOnly failed", *nValue3.getF32() == 1234); - - LLNameValue nValue4("SecondLife", "<1,2,3>", "VEC3", "R", "S"); - // this should not have updated as it is read only. - LLVector3 vec(4,5,6); - nValue3.setVec3(vec); - LLVector3 vec1(1,2,3); - ensure("setVec3 on ReadOnly failed", *nValue4.getVec3() == vec1); - - // cant test for U64 as no set64 exists nor any operators support U64 type - } + struct namevalue_test + { + namevalue_test() + { + } + }; + typedef test_group<namevalue_test> namevalue_t; + typedef namevalue_t::object namevalue_object_t; + tut::namevalue_t tut_namevalue("LLNameValue"); + + + template<> template<> + void namevalue_object_t::test<1>() + { + // LLNameValue() + LLNameValue nValue; + ensure("mName should have been NULL", nValue.mName == NULL); + ensure("getTypeEnum failed",nValue.getTypeEnum() == NVT_NULL); + ensure("getClassEnum failed",nValue.getClassEnum() == NVC_NULL); + ensure("getSendtoEnum failed",nValue.getSendtoEnum() == NVS_NULL); + + LLNameValue nValue1(" SecondLife ASSET RW SIM 232324343"); + + } + + // LLNameValue(const char* data); + // LLNameValue(const char* name, const char* data, const char* type, const char* nvclass, const char* nvsendto, + // TNameValueCallback nvcb = NULL, void** user_data = NULL); + template<> template<> + void namevalue_object_t::test<2>() + { + LLNameValue nValue(" SecondLife ASSET RW S 232324343"); + ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); + ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); + ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); + ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); + ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); + ensure("sendToData or sendToViewer failed", !nValue.sendToData() && !nValue.sendToViewer()); + + LLNameValue nValue1("\n\r SecondLife_1 STRING READ_WRITE SIM 232324343"); + ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife_1"))); + ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); + ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); + ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); + ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); + ensure("1. sendToData or sendToViewer failed", !nValue1.sendToData() && !nValue1.sendToViewer()); + + LLNameValue nValue2("SecondLife", "23.5", "F32", "R", "DS"); + ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); + ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); + ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_DATA_SIM); + ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); + ensure("2. sendToData or sendToViewer failed", nValue2.sendToData() && !nValue2.sendToViewer()); + + LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY", "SIM_SPACE"); + ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); + ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); + ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_DATA_SIM); + ensure("3. getS32 failed", *nValue3.getS32() == -43456787); + ensure("sendToData or sendToViewer failed", nValue3.sendToData() && !nValue3.sendToViewer()); + + LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW", "SV"); + LLVector3 llvec4(1.0, 2.0, 3.0); + ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); + ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); + ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM_VIEWER); + ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); + ensure("4. sendToData or sendToViewer failed", !nValue4.sendToData() && nValue4.sendToViewer()); + + LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW", "SIM_VIEWER"); + LLVector3 llvec5(-1.0f, 2.4f, 3); + ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); + ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); + ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM_VIEWER); + ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); + ensure("5. sendToData or sendToViewer failed", !nValue5.sendToData() && nValue5.sendToViewer()); + + LLNameValue nValue6("SecondLife", "89764323", "U32", "RW", "DSV"); + ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); + ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); + ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_DATA_SIM_VIEWER); + ensure("6. getU32 failed", *nValue6.getU32() == 89764323); + ensure("6. sendToData or sendToViewer failed", nValue6.sendToData() && nValue6.sendToViewer()); + + LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW", "SIM_SPACE_VIEWER"); + U64 u64_7 = U64L(89764323323232); + ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); + ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); + ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_DATA_SIM_VIEWER); + ensure("7. getU32 failed", *nValue7.getU64() == u64_7); + ensure("7. sendToData or sendToViewer failed", nValue7.sendToData() && nValue7.sendToViewer()); + } + + // LLNameValue(const char* name, const char* data, const char* type, const char* nvclass, + // TNameValueCallback nvcb = NULL, void** user_data = NULL); + template<> template<> + void namevalue_object_t::test<3>() + { + LLNameValue nValue("SecondLife", "232324343", "ASSET", "READ_WRITE"); + ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); + ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_ASSET); + ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); + ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); + ensure("getString failed", (0==strcmp(nValue.getAsset(),"232324343"))); + + LLNameValue nValue1("SecondLife", "232324343", "STRING", "READ_WRITE"); + ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife"))); + ensure("1. getTypeEnum failed", nValue1.getTypeEnum() == NVT_STRING); + ensure("1. getClassEnum failed", nValue1.getClassEnum() == NVC_READ_WRITE); + ensure("1. getSendtoEnum failed", nValue1.getSendtoEnum() == NVS_SIM); + ensure("1. getString failed", (0==strcmp(nValue1.getString(),"232324343"))); + + LLNameValue nValue2("SecondLife", "23.5", "F32", "R"); + ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); + ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); + ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_SIM); + ensure("2. getF32 failed", *nValue2.getF32() == 23.5f); + + LLNameValue nValue3("SecondLife", "-43456787", "S32", "READ_ONLY"); + ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); + ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); + ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); + ensure("3. getS32 failed", *nValue3.getS32() == -43456787); + + LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW"); + LLVector3 llvec4(1.0, 2.0, 3.0); + ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); + ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); + ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); + ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); + + LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW"); + LLVector3 llvec5(-1.0f, 2.4f, 3); + ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); + ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); + ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM); + ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); + + LLNameValue nValue6("SecondLife", "89764323", "U32", "RW"); + ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); + ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); + ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); + ensure("6. getU32 failed", *nValue6.getU32() == 89764323); + + LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW"); + U64 u64_7 = U64L(89764323323232); + ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); + ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); + ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); + ensure("7. getU32 failed", *nValue7.getU64() == u64_7); + } + + // LLNameValue(const char* name, const char* type, const char* nvclass, + // TNameValueCallback nvcb = NULL, void** user_data = NULL); + template<> template<> + void namevalue_object_t::test<4>() + { + LLNameValue nValue("SecondLife", "STRING", "READ_WRITE"); + ensure("mName not set correctly", (0 == strcmp(nValue.mName,"SecondLife"))); + ensure("getTypeEnum failed", nValue.getTypeEnum() == NVT_STRING); + ensure("getClassEnum failed", nValue.getClassEnum() == NVC_READ_WRITE); + ensure("getSendtoEnum failed", nValue.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue1("SecondLife", "ASSET", "READ_WRITE"); + ensure("1. mName not set correctly", (0 == strcmp(nValue1.mName,"SecondLife"))); + ensure("1. getTypeEnum for RW failed", nValue1.getTypeEnum() == NVT_ASSET); + ensure("1. getClassEnum for RW failed", nValue1.getClassEnum() == NVC_READ_WRITE); + ensure("1. getSendtoEnum for RW failed", nValue1.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue2("SecondLife", "F32", "READ_ONLY"); + ensure("2. getTypeEnum failed", nValue2.getTypeEnum() == NVT_F32); + ensure("2. getClassEnum failed", nValue2.getClassEnum() == NVC_READ_ONLY); + ensure("2. getSendtoEnum failed", nValue2.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue3("SecondLife", "S32", "READ_ONLY"); + ensure("3. getTypeEnum failed", nValue3.getTypeEnum() == NVT_S32); + ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); + ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue4("SecondLife", "VEC3", "READ_WRITE"); + ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); + ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); + ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue6("SecondLife", "U32", "READ_WRITE"); + ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); + ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); + ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); + + LLNameValue nValue7("SecondLife", "U64", "READ_WRITE"); + ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); + ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); + ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); + } + + template<> template<> + void namevalue_object_t::test<5>() + { + LLNameValue nValue("SecondLife", "This is a test", "STRING", "RW", "SIM"); + + ensure("getString failed", (0 == strcmp(nValue.getString(),"This is a test"))); + } + + template<> template<> + void namevalue_object_t::test<6>() + { + LLNameValue nValue("SecondLife", "This is a test", "ASSET", "RW", "S"); + ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); + } + + template<> template<> + void namevalue_object_t::test<7>() + { + LLNameValue nValue("SecondLife", "555555", "F32", "RW", "SIM"); + + ensure("getF32 failed",*nValue.getF32() == 555555.f); + } + + template<> template<> + void namevalue_object_t::test<8>() + { + LLNameValue nValue("SecondLife", "-5555", "S32", "RW", "SIM"); + + ensure("getS32 failed", *nValue.getS32() == -5555); + + S32 sVal = 0x7FFFFFFF; + nValue.setS32(sVal); + ensure("getS32 failed", *nValue.getS32() == sVal); + + sVal = -0x7FFFFFFF; + nValue.setS32(sVal); + ensure("getS32 failed", *nValue.getS32() == sVal); + + sVal = 0; + nValue.setS32(sVal); + ensure("getS32 failed", *nValue.getS32() == sVal); + } + + template<> template<> + void namevalue_object_t::test<9>() + { + LLNameValue nValue("SecondLife", "<-3, 2, 1>", "VEC3", "RW", "SIM"); + LLVector3 vecExpected(-3, 2, 1); + LLVector3 vec; + nValue.getVec3(vec); + ensure("getVec3 failed", vec == vecExpected); + } + + template<> template<> + void namevalue_object_t::test<10>() + { + LLNameValue nValue("SecondLife", "12345678", "U32", "RW", "SIM"); + + ensure("getU32 failed",*nValue.getU32() == 12345678); + + U32 val = 0xFFFFFFFF; + nValue.setU32(val); + ensure("U32 max", *nValue.getU32() == val); + + val = 0; + nValue.setU32(val); + ensure("U32 min", *nValue.getU32() == val); + } + + template<> template<> + void namevalue_object_t::test<11>() + { + //skip_fail("incomplete support for U64."); + LLNameValue nValue("SecondLife", "44444444444", "U64", "RW", "SIM"); + + ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); + + // there is no LLNameValue::setU64() + } + + + template<> template<> + void namevalue_object_t::test<12>() + { + //skip_fail("incomplete support for U64."); + LLNameValue nValue("SecondLife U64 RW DSV 44444444444"); + std::string ret_str = nValue.printNameValue(); + + ensure_equals("1:printNameValue failed",ret_str,"SecondLife U64 RW DSV 44444444444"); + + LLNameValue nValue1(ret_str.c_str()); + ensure_equals("Serialization of printNameValue failed", *nValue.getU64(), *nValue1.getU64()); + } + + template<> template<> + void namevalue_object_t::test<13>() + { + LLNameValue nValue("SecondLife STRING RW DSV 44444444444"); + std::string ret_str = nValue.printData(); + ensure_equals("1:printData failed",ret_str,"44444444444"); + + LLNameValue nValue1("SecondLife S32 RW DSV 44444"); + ret_str = nValue1.printData(); + ensure_equals("2:printData failed",ret_str,"44444"); + } + + template<> template<> + void namevalue_object_t::test<14>() + { + LLNameValue nValue("SecodLife STRING RW SIM 22222"); + std::ostringstream stream1,stream2,stream3, stream4, stream5; + stream1 << nValue; + ensure_equals("STRING << failed",stream1.str(),"22222"); + + LLNameValue nValue1("SecodLife F32 RW SIM 22222"); + stream2 << nValue1; + ensure_equals("F32 << failed",stream2.str(),"22222"); + + LLNameValue nValue2("SecodLife S32 RW SIM 22222"); + stream3<< nValue2; + ensure_equals("S32 << failed",stream3.str(),"22222"); + + LLNameValue nValue3("SecodLife U32 RW SIM 122222"); + stream4<< nValue3; + ensure_equals("U32 << failed",stream4.str(),"122222"); + + // I don't think we use U64 name value pairs. JC + //skip_fail("incomplete support for U64."); + //LLNameValue nValue4("SecodLife U64 RW SIM 22222"); + //stream5<< nValue4; + //ensure("U64 << failed",0 == strcmp((stream5.str()).c_str(),"22222")); + } + + template<> template<> + void namevalue_object_t::test<15>() + { + LLNameValue nValue("SecondLife", "This is a test", "ASSET", "R", "S"); + + ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); + // this should not have updated as it is read only. + nValue.setAsset("New Value should not be updated"); + ensure("setAsset on ReadOnly failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); + + LLNameValue nValue1("SecondLife", "1234", "U32", "R", "S"); + // this should not have updated as it is read only. + nValue1.setU32(4567); + ensure("setU32 on ReadOnly failed", *nValue1.getU32() == 1234); + + LLNameValue nValue2("SecondLife", "1234", "S32", "R", "S"); + // this should not have updated as it is read only. + nValue2.setS32(4567); + ensure("setS32 on ReadOnly failed", *nValue2.getS32() == 1234); + + LLNameValue nValue3("SecondLife", "1234", "F32", "R", "S"); + // this should not have updated as it is read only. + nValue3.setF32(4567); + ensure("setF32 on ReadOnly failed", *nValue3.getF32() == 1234); + + LLNameValue nValue4("SecondLife", "<1,2,3>", "VEC3", "R", "S"); + // this should not have updated as it is read only. + LLVector3 vec(4,5,6); + nValue3.setVec3(vec); + LLVector3 vec1(1,2,3); + ensure("setVec3 on ReadOnly failed", *nValue4.getVec3() == vec1); + + // cant test for U64 as no set64 exists nor any operators support U64 type + } } diff --git a/indra/llmessage/tests/llpartdata_test.cpp b/indra/llmessage/tests/llpartdata_test.cpp index de81e0bbb2..c517232bcc 100644 --- a/indra/llmessage/tests/llpartdata_test.cpp +++ b/indra/llmessage/tests/llpartdata_test.cpp @@ -7,21 +7,21 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -39,116 +39,116 @@ namespace tut { - //bunch of sniffed data that *should* be a valid particle system - static U8 msg[] = { - 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x80, 0x00, 0x80, - 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x5e, 0x12, 0x0b, 0xa1, 0x58, 0x05, 0xdc, 0x57, 0x66, - 0xb7, 0xf5, 0xac, 0x4b, 0xd1, 0x8f, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x02, 0x05, 0x02, 0x00, 0x00, 0x0a, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7e, 0xc6, 0x81, 0xdc, 0x7e, 0xc6, 0x81, 0xdc, 0x77, 0xcf, 0xef, 0xd4, 0xce, 0x64, 0x1a, 0x7e, - 0x26, 0x87, 0x55, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0x77, 0xcf, 0x98, 0xa3, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xf2, - 0xf1, 0x65, 0x32, 0x1b, 0xef, 0x18, 0x70, 0x66, 0xba, 0x30, 0xa0, 0x11, 0xaa, 0x2f, 0xb0, 0xab, 0xd0, - 0x30, 0x7d, 0xbd, 0x01, 0x00, 0xf8, 0x0d, 0xb8, 0x30, 0x01, 0x00, 0x00, 0x00, 0xce, 0xc6, 0x81, 0xdc, - 0xce, 0xc6, 0x81, 0xdc, 0xc7, 0xcf, 0xef, 0xd4, 0x75, 0x65, 0x1a, 0x7f, 0x62, 0x6f, 0x55, 0x7f, 0x6d, - 0x65, 0x22, 0x7f, 0x6d, 0x65, 0x22, 0x7f, 0xc7, 0xcf, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf2, 0xf1, 0x62, 0x12, 0x1b, 0xef, - 0x18, 0x7e, 0xbd, 0x01, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7c, 0xac, 0x28, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, - 0xe0, 0xb9, 0x30, 0x03, 0xe1, 0xb9, 0x30, 0xbb, 0x00, 0x00, 0x00, 0x48, 0xe0, 0xb9, 0x30, 0x36, 0xd9, - 0x81, 0xdc, 0x36, 0xd9, 0x81, 0xdc, 0x3f, 0xd0, 0xef, 0xd4, 0xa5, 0x7a, 0x72, 0x7f, 0x26, 0x30, 0x55, - 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x3f, 0xd0, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - struct partdata_test - { - }; + //bunch of sniffed data that *should* be a valid particle system + static U8 msg[] = { + 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x80, 0x00, 0x80, + 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x5e, 0x12, 0x0b, 0xa1, 0x58, 0x05, 0xdc, 0x57, 0x66, + 0xb7, 0xf5, 0xac, 0x4b, 0xd1, 0x8f, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x02, 0x05, 0x02, 0x00, 0x00, 0x0a, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7e, 0xc6, 0x81, 0xdc, 0x7e, 0xc6, 0x81, 0xdc, 0x77, 0xcf, 0xef, 0xd4, 0xce, 0x64, 0x1a, 0x7e, + 0x26, 0x87, 0x55, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0xdd, 0x65, 0x22, 0x7f, 0x77, 0xcf, 0x98, 0xa3, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xf2, + 0xf1, 0x65, 0x32, 0x1b, 0xef, 0x18, 0x70, 0x66, 0xba, 0x30, 0xa0, 0x11, 0xaa, 0x2f, 0xb0, 0xab, 0xd0, + 0x30, 0x7d, 0xbd, 0x01, 0x00, 0xf8, 0x0d, 0xb8, 0x30, 0x01, 0x00, 0x00, 0x00, 0xce, 0xc6, 0x81, 0xdc, + 0xce, 0xc6, 0x81, 0xdc, 0xc7, 0xcf, 0xef, 0xd4, 0x75, 0x65, 0x1a, 0x7f, 0x62, 0x6f, 0x55, 0x7f, 0x6d, + 0x65, 0x22, 0x7f, 0x6d, 0x65, 0x22, 0x7f, 0xc7, 0xcf, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf2, 0xf1, 0x62, 0x12, 0x1b, 0xef, + 0x18, 0x7e, 0xbd, 0x01, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0xac, 0x28, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, + 0xe0, 0xb9, 0x30, 0x03, 0xe1, 0xb9, 0x30, 0xbb, 0x00, 0x00, 0x00, 0x48, 0xe0, 0xb9, 0x30, 0x36, 0xd9, + 0x81, 0xdc, 0x36, 0xd9, 0x81, 0xdc, 0x3f, 0xd0, 0xef, 0xd4, 0xa5, 0x7a, 0x72, 0x7f, 0x26, 0x30, 0x55, + 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x95, 0x7a, 0x22, 0x7f, 0x3f, 0xd0, 0x98, 0xa3, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + struct partdata_test + { + }; + + typedef test_group<partdata_test> partdata_test_t; + typedef partdata_test_t::object partdata_test_object_t; + tut::partdata_test_t tut_partdata_test("LLPartData"); + + template<> template<> + void partdata_test_object_t::test<1>() + { + LLPartSysData llpsysdata; + LLDataPackerBinaryBuffer dp1(msg, sizeof(msg)); - typedef test_group<partdata_test> partdata_test_t; - typedef partdata_test_t::object partdata_test_object_t; - tut::partdata_test_t tut_partdata_test("LLPartData"); + ensure("LLPartSysData::unpack failed.", llpsysdata.unpack(dp1)); - template<> template<> - void partdata_test_object_t::test<1>() - { - LLPartSysData llpsysdata; - LLDataPackerBinaryBuffer dp1(msg, sizeof(msg)); - ensure("LLPartSysData::unpack failed.", llpsysdata.unpack(dp1)); + //mCRC 1 unsigned int + ensure("mCRC different after unpacking", llpsysdata.mCRC == (U32) 1); + //mFlags 0 unsigned int + ensure ("mFlags different after unpacking", llpsysdata.mFlags == (U32) 0); + //mPattern 1 '' unsigned char + ensure ("mPattern different after unpacking", llpsysdata.mPattern == (U8) 1); + //mInnerAngle 0.00000000 float + ensure_approximately_equals("mInnerAngle different after unpacking", llpsysdata.mInnerAngle, 0.f, 8); + //mOuterAngle 0.00000000 float + ensure_approximately_equals("mOuterAngle different after unpacking", llpsysdata.mOuterAngle, 0.f, 8); + //mAngularVelocity 0,0,0 + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[0], 0.f, 8); + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[1], 0.f, 8); + ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[2], 0.f, 8); + //mBurstRate 0.097656250 float + ensure_approximately_equals("mBurstRate different after unpacking", llpsysdata.mBurstRate, 0.097656250f, 8); + //mBurstPartCount 1 '' unsigned char + ensure("mBurstPartCount different after unpacking", llpsysdata.mBurstPartCount == (U8) 1); + //mBurstRadius 0.00000000 float + ensure_approximately_equals("mBurstRadius different after unpacking", llpsysdata.mBurstRadius, 0.f, 8); + //mBurstSpeedMin 1.0000000 float + ensure_approximately_equals("mBurstSpeedMin different after unpacking", llpsysdata.mBurstSpeedMin, 1.f, 8); + //mBurstSpeedMax 1.0000000 float + ensure_approximately_equals("mBurstSpeedMax different after unpacking", llpsysdata.mBurstSpeedMax, 1.f, 8); + //mMaxAge 0.00000000 float + ensure_approximately_equals("mMaxAge different after unpacking", llpsysdata.mMaxAge, 0.f, 8); + //mStartAge 0.00000000 float + ensure_approximately_equals("mStartAge different after unpacking", llpsysdata.mStartAge, 0.f, 8); + //mPartAccel <0,0,0> + ensure_approximately_equals("mPartAccel.mV[0] different after unpacking", llpsysdata.mPartAccel.mV[0], 0.f, 7); + ensure_approximately_equals("mPartAccel.mV[1] different after unpacking", llpsysdata.mPartAccel.mV[1], 0.f, 7); + ensure_approximately_equals("mPartAccel.mV[2] different after unpacking", llpsysdata.mPartAccel.mV[2], 0.f, 7); - - //mCRC 1 unsigned int - ensure("mCRC different after unpacking", llpsysdata.mCRC == (U32) 1); - //mFlags 0 unsigned int - ensure ("mFlags different after unpacking", llpsysdata.mFlags == (U32) 0); - //mPattern 1 '' unsigned char - ensure ("mPattern different after unpacking", llpsysdata.mPattern == (U8) 1); - //mInnerAngle 0.00000000 float - ensure_approximately_equals("mInnerAngle different after unpacking", llpsysdata.mInnerAngle, 0.f, 8); - //mOuterAngle 0.00000000 float - ensure_approximately_equals("mOuterAngle different after unpacking", llpsysdata.mOuterAngle, 0.f, 8); - //mAngularVelocity 0,0,0 - ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[0], 0.f, 8); - ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[1], 0.f, 8); - ensure_approximately_equals("mAngularVelocity.mV[0] different after unpacking", llpsysdata.mAngularVelocity.mV[2], 0.f, 8); - //mBurstRate 0.097656250 float - ensure_approximately_equals("mBurstRate different after unpacking", llpsysdata.mBurstRate, 0.097656250f, 8); - //mBurstPartCount 1 '' unsigned char - ensure("mBurstPartCount different after unpacking", llpsysdata.mBurstPartCount == (U8) 1); - //mBurstRadius 0.00000000 float - ensure_approximately_equals("mBurstRadius different after unpacking", llpsysdata.mBurstRadius, 0.f, 8); - //mBurstSpeedMin 1.0000000 float - ensure_approximately_equals("mBurstSpeedMin different after unpacking", llpsysdata.mBurstSpeedMin, 1.f, 8); - //mBurstSpeedMax 1.0000000 float - ensure_approximately_equals("mBurstSpeedMax different after unpacking", llpsysdata.mBurstSpeedMax, 1.f, 8); - //mMaxAge 0.00000000 float - ensure_approximately_equals("mMaxAge different after unpacking", llpsysdata.mMaxAge, 0.f, 8); - //mStartAge 0.00000000 float - ensure_approximately_equals("mStartAge different after unpacking", llpsysdata.mStartAge, 0.f, 8); - //mPartAccel <0,0,0> - ensure_approximately_equals("mPartAccel.mV[0] different after unpacking", llpsysdata.mPartAccel.mV[0], 0.f, 7); - ensure_approximately_equals("mPartAccel.mV[1] different after unpacking", llpsysdata.mPartAccel.mV[1], 0.f, 7); - ensure_approximately_equals("mPartAccel.mV[2] different after unpacking", llpsysdata.mPartAccel.mV[2], 0.f, 7); + //mPartData + LLPartData& data = llpsysdata.mPartData; - //mPartData - LLPartData& data = llpsysdata.mPartData; + //mFlags 132354 unsigned int + ensure ("mPartData.mFlags different after unpacking", data.mFlags == (U32) 132354); + //mMaxAge 10.000000 float + ensure_approximately_equals("mPartData.mMaxAge different after unpacking", data.mMaxAge, 10.f, 8); + //mStartColor <1,1,1,1> + ensure_approximately_equals("mPartData.mStartColor.mV[0] different after unpacking", data.mStartColor.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[1] different after unpacking", data.mStartColor.mV[1], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[2] different after unpacking", data.mStartColor.mV[2], 1.f, 8); + ensure_approximately_equals("mPartData.mStartColor.mV[3] different after unpacking", data.mStartColor.mV[3], 1.f, 8); + //mEndColor <1,1,0,0> + ensure_approximately_equals("mPartData.mEndColor.mV[0] different after unpacking", data.mEndColor.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[1] different after unpacking", data.mEndColor.mV[1], 1.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[2] different after unpacking", data.mEndColor.mV[2], 0.f, 8); + ensure_approximately_equals("mPartData.mEndColor.mV[3] different after unpacking", data.mEndColor.mV[3], 0.f, 8); + //mStartScale <1,1> + ensure_approximately_equals("mPartData.mStartScale.mV[0] different after unpacking", data.mStartScale.mV[0], 1.f, 8); + ensure_approximately_equals("mPartData.mStartScale.mV[1] different after unpacking", data.mStartScale.mV[1], 1.f, 8); + //mEndScale <0,0> + ensure_approximately_equals("mPartData.mEndScale.mV[0] different after unpacking", data.mEndScale.mV[0], 0.f, 8); + ensure_approximately_equals("mPartData.mEndScale.mV[1] different after unpacking", data.mEndScale.mV[1], 0.f, 8); + //mPosOffset <0,0,0> + ensure_approximately_equals("mPartData.mPosOffset.mV[0] different after unpacking", data.mPosOffset.mV[0], 0.f, 8); + ensure_approximately_equals("mPartData.mPosOffset.mV[1] different after unpacking", data.mPosOffset.mV[1], 0.f, 8); + ensure_approximately_equals("mPartData.mPosOffset.mV[2] different after unpacking", data.mPosOffset.mV[2], 0.f, 8); + //mParameter 0.00000000 float + ensure_approximately_equals("mPartData.mParameter different after unpacking", data.mParameter, 0.f, 8); - //mFlags 132354 unsigned int - ensure ("mPartData.mFlags different after unpacking", data.mFlags == (U32) 132354); - //mMaxAge 10.000000 float - ensure_approximately_equals("mPartData.mMaxAge different after unpacking", data.mMaxAge, 10.f, 8); - //mStartColor <1,1,1,1> - ensure_approximately_equals("mPartData.mStartColor.mV[0] different after unpacking", data.mStartColor.mV[0], 1.f, 8); - ensure_approximately_equals("mPartData.mStartColor.mV[1] different after unpacking", data.mStartColor.mV[1], 1.f, 8); - ensure_approximately_equals("mPartData.mStartColor.mV[2] different after unpacking", data.mStartColor.mV[2], 1.f, 8); - ensure_approximately_equals("mPartData.mStartColor.mV[3] different after unpacking", data.mStartColor.mV[3], 1.f, 8); - //mEndColor <1,1,0,0> - ensure_approximately_equals("mPartData.mEndColor.mV[0] different after unpacking", data.mEndColor.mV[0], 1.f, 8); - ensure_approximately_equals("mPartData.mEndColor.mV[1] different after unpacking", data.mEndColor.mV[1], 1.f, 8); - ensure_approximately_equals("mPartData.mEndColor.mV[2] different after unpacking", data.mEndColor.mV[2], 0.f, 8); - ensure_approximately_equals("mPartData.mEndColor.mV[3] different after unpacking", data.mEndColor.mV[3], 0.f, 8); - //mStartScale <1,1> - ensure_approximately_equals("mPartData.mStartScale.mV[0] different after unpacking", data.mStartScale.mV[0], 1.f, 8); - ensure_approximately_equals("mPartData.mStartScale.mV[1] different after unpacking", data.mStartScale.mV[1], 1.f, 8); - //mEndScale <0,0> - ensure_approximately_equals("mPartData.mEndScale.mV[0] different after unpacking", data.mEndScale.mV[0], 0.f, 8); - ensure_approximately_equals("mPartData.mEndScale.mV[1] different after unpacking", data.mEndScale.mV[1], 0.f, 8); - //mPosOffset <0,0,0> - ensure_approximately_equals("mPartData.mPosOffset.mV[0] different after unpacking", data.mPosOffset.mV[0], 0.f, 8); - ensure_approximately_equals("mPartData.mPosOffset.mV[1] different after unpacking", data.mPosOffset.mV[1], 0.f, 8); - ensure_approximately_equals("mPartData.mPosOffset.mV[2] different after unpacking", data.mPosOffset.mV[2], 0.f, 8); - //mParameter 0.00000000 float - ensure_approximately_equals("mPartData.mParameter different after unpacking", data.mParameter, 0.f, 8); - - //mStartGlow 0.00000000 float - ensure_approximately_equals("mPartData.mStartGlow different after unpacking", data.mStartGlow, 0.f, 8); - //mEndGlow 0.00000000 float - ensure_approximately_equals("mPartData.mEndGlow different after unpacking", data.mEndGlow, 0.f, 8); - //mBlendFuncSource 2 '' unsigned char - ensure("mPartData.mBlendFuncSource different after unpacking", data.mBlendFuncSource == (U8) 2); - //mBlendFuncDest 1 '' unsigned char - ensure("mPartData.mBlendFuncDest different after unpacking", data.mBlendFuncDest == (U8) 1); - } + //mStartGlow 0.00000000 float + ensure_approximately_equals("mPartData.mStartGlow different after unpacking", data.mStartGlow, 0.f, 8); + //mEndGlow 0.00000000 float + ensure_approximately_equals("mPartData.mEndGlow different after unpacking", data.mEndGlow, 0.f, 8); + //mBlendFuncSource 2 '' unsigned char + ensure("mPartData.mBlendFuncSource different after unpacking", data.mBlendFuncSource == (U8) 2); + //mBlendFuncDest 1 '' unsigned char + ensure("mPartData.mBlendFuncDest different after unpacking", data.mBlendFuncDest == (U8) 1); + } } diff --git a/indra/llmessage/tests/lltemplatemessagedispatcher_test.cpp b/indra/llmessage/tests/lltemplatemessagedispatcher_test.cpp index e20f61b73f..911aef827d 100644 --- a/indra/llmessage/tests/lltemplatemessagedispatcher_test.cpp +++ b/indra/llmessage/tests/lltemplatemessagedispatcher_test.cpp @@ -5,21 +5,21 @@ * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -40,121 +40,121 @@ LLPounceable<LLMessageSystem*, LLPounceableStatic> gMessageSystem; // sensor test doubles bool gClearRecvWasCalled = false; -void LLMessageSystem::clearReceiveState(void) -{ - gClearRecvWasCalled = true; +void LLMessageSystem::clearReceiveState(void) +{ + gClearRecvWasCalled = true; } char gUdpDispatchedData[MAX_BUFFER_SIZE]; bool gUdpDispatchWasCalled = false; -BOOL LLTemplateMessageReader::readMessage(const U8* data,class LLHost const &) -{ - gUdpDispatchWasCalled = true; - strcpy(gUdpDispatchedData, reinterpret_cast<const char*>(data)); - return true; +BOOL LLTemplateMessageReader::readMessage(const U8* data,class LLHost const &) +{ + gUdpDispatchWasCalled = true; + strcpy(gUdpDispatchedData, reinterpret_cast<const char*>(data)); + return true; } BOOL gValidateMessage = FALSE; -BOOL LLTemplateMessageReader::validateMessage(const U8*, S32 buffer_size, LLHost const &sender, bool trusted) -{ - return gValidateMessage; +BOOL LLTemplateMessageReader::validateMessage(const U8*, S32 buffer_size, LLHost const &sender, bool trusted) +{ + return gValidateMessage; } LLHost host; -const LLHost& LLMessageSystem::getSender() const -{ - return host; +const LLHost& LLMessageSystem::getSender() const +{ + return host; } const char* gBinaryTemplateData = "BINARYTEMPLATEDATA"; void fillVector(std::vector<U8>& vector_data, const char* data) { - vector_data.resize(strlen(data) + 1); - strcpy(reinterpret_cast<char*>(&vector_data[0]), data); + vector_data.resize(strlen(data) + 1); + strcpy(reinterpret_cast<char*>(&vector_data[0]), data); } namespace tut { - static LLTemplateMessageReader::message_template_number_map_t numberMap; - - struct LLTemplateMessageDispatcherData - { - LLTemplateMessageDispatcherData() - { - mMessageName = "MessageName"; - gUdpDispatchWasCalled = false; - gClearRecvWasCalled = false; - gValidateMessage = FALSE; - mMessage["body"]["binary-template-data"] = std::vector<U8>(); - } - - LLSD mMessage; - LLHTTPNode::ResponsePtr mResponsePtr; - std::string mMessageName; - }; - - typedef test_group<LLTemplateMessageDispatcherData> factory; - typedef factory::object object; + static LLTemplateMessageReader::message_template_number_map_t numberMap; + + struct LLTemplateMessageDispatcherData + { + LLTemplateMessageDispatcherData() + { + mMessageName = "MessageName"; + gUdpDispatchWasCalled = false; + gClearRecvWasCalled = false; + gValidateMessage = FALSE; + mMessage["body"]["binary-template-data"] = std::vector<U8>(); + } + + LLSD mMessage; + LLHTTPNode::ResponsePtr mResponsePtr; + std::string mMessageName; + }; + + typedef test_group<LLTemplateMessageDispatcherData> factory; + typedef factory::object object; } namespace { - tut::factory tf("LLTemplateMessageDispatcher"); + tut::factory tf("LLTemplateMessageDispatcher"); } namespace tut { - // does an empty message stop processing? - template<> template<> - void object::test<1>() - { - LLTemplateMessageReader* pReader = NULL; - LLTemplateMessageDispatcher t(*pReader); - t.dispatch(mMessageName, mMessage, mResponsePtr); - ensure(! gUdpDispatchWasCalled); - ensure(! gClearRecvWasCalled); - } - - // does the disaptch invoke the udp send method? - template<> template<> - void object::test<2>() - { - LLTemplateMessageReader* pReader = NULL; - LLTemplateMessageDispatcher t(*pReader); - gValidateMessage = TRUE; - std::vector<U8> vector_data; - fillVector(vector_data, gBinaryTemplateData); - mMessage["body"]["binary-template-data"] = vector_data; - t.dispatch(mMessageName, mMessage, mResponsePtr); - ensure("udp dispatch was called", gUdpDispatchWasCalled); - } - - // what if the message wasn't valid? We would hope the message gets cleared! - template<> template<> - void object::test<3>() - { - LLTemplateMessageReader* pReader = NULL; - LLTemplateMessageDispatcher t(*pReader); - std::vector<U8> vector_data; - fillVector(vector_data, gBinaryTemplateData); - mMessage["body"]["binary-template-data"] = vector_data; - gValidateMessage = FALSE; - t.dispatch(mMessageName, mMessage, mResponsePtr); - ensure("clear received message was called", gClearRecvWasCalled); - } - - // is the binary data passed through correctly? - template<> template<> - void object::test<4>() - { - LLTemplateMessageReader* pReader = NULL; - LLTemplateMessageDispatcher t(*pReader); - gValidateMessage = TRUE; - std::vector<U8> vector_data; - fillVector(vector_data, gBinaryTemplateData); - mMessage["body"]["binary-template-data"] = vector_data; - t.dispatch(mMessageName, mMessage, mResponsePtr); - ensure("data couriered correctly", strcmp(gBinaryTemplateData, gUdpDispatchedData) == 0); - } + // does an empty message stop processing? + template<> template<> + void object::test<1>() + { + LLTemplateMessageReader* pReader = NULL; + LLTemplateMessageDispatcher t(*pReader); + t.dispatch(mMessageName, mMessage, mResponsePtr); + ensure(! gUdpDispatchWasCalled); + ensure(! gClearRecvWasCalled); + } + + // does the disaptch invoke the udp send method? + template<> template<> + void object::test<2>() + { + LLTemplateMessageReader* pReader = NULL; + LLTemplateMessageDispatcher t(*pReader); + gValidateMessage = TRUE; + std::vector<U8> vector_data; + fillVector(vector_data, gBinaryTemplateData); + mMessage["body"]["binary-template-data"] = vector_data; + t.dispatch(mMessageName, mMessage, mResponsePtr); + ensure("udp dispatch was called", gUdpDispatchWasCalled); + } + + // what if the message wasn't valid? We would hope the message gets cleared! + template<> template<> + void object::test<3>() + { + LLTemplateMessageReader* pReader = NULL; + LLTemplateMessageDispatcher t(*pReader); + std::vector<U8> vector_data; + fillVector(vector_data, gBinaryTemplateData); + mMessage["body"]["binary-template-data"] = vector_data; + gValidateMessage = FALSE; + t.dispatch(mMessageName, mMessage, mResponsePtr); + ensure("clear received message was called", gClearRecvWasCalled); + } + + // is the binary data passed through correctly? + template<> template<> + void object::test<4>() + { + LLTemplateMessageReader* pReader = NULL; + LLTemplateMessageDispatcher t(*pReader); + gValidateMessage = TRUE; + std::vector<U8> vector_data; + fillVector(vector_data, gBinaryTemplateData); + mMessage["body"]["binary-template-data"] = vector_data; + t.dispatch(mMessageName, mMessage, mResponsePtr); + ensure("data couriered correctly", strcmp(gBinaryTemplateData, gUdpDispatchedData) == 0); + } } diff --git a/indra/llmessage/tests/lltestmessagesender.cpp b/indra/llmessage/tests/lltestmessagesender.cpp index ee40e0249e..1765a9eccd 100644 --- a/indra/llmessage/tests/lltestmessagesender.cpp +++ b/indra/llmessage/tests/lltestmessagesender.cpp @@ -1,25 +1,25 @@ -/** - * @file - * @brief +/** + * @file + * @brief * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -32,7 +32,7 @@ LLTestMessageSender::~LLTestMessageSender() S32 LLTestMessageSender::sendMessage(const LLHost& host, LLStoredMessagePtr message) { - mSendHosts.push_back(host); - mSendMessages.push_back(message); - return 0; + mSendHosts.push_back(host); + mSendMessages.push_back(message); + return 0; } diff --git a/indra/llmessage/tests/lltestmessagesender.h b/indra/llmessage/tests/lltestmessagesender.h index bb89289585..e78cfad96e 100644 --- a/indra/llmessage/tests/lltestmessagesender.h +++ b/indra/llmessage/tests/lltestmessagesender.h @@ -1,25 +1,25 @@ -/** - * @file - * @brief +/** + * @file + * @brief * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -38,11 +38,11 @@ class LLTestMessageSender : public LLMessageSenderInterface { public: - virtual ~LLTestMessageSender(); - virtual S32 sendMessage(const LLHost& host, LLStoredMessagePtr message); + virtual ~LLTestMessageSender(); + virtual S32 sendMessage(const LLHost& host, LLStoredMessagePtr message); - std::vector<LLHost> mSendHosts; - std::vector<LLStoredMessagePtr> mSendMessages; + std::vector<LLHost> mSendHosts; + std::vector<LLStoredMessagePtr> mSendMessages; }; diff --git a/indra/llmessage/tests/lltrustedmessageservice_test.cpp b/indra/llmessage/tests/lltrustedmessageservice_test.cpp index 41f982a7e2..cc199141b8 100644 --- a/indra/llmessage/tests/lltrustedmessageservice_test.cpp +++ b/indra/llmessage/tests/lltrustedmessageservice_test.cpp @@ -5,21 +5,21 @@ * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -40,7 +40,7 @@ LLPounceable<LLMessageSystem*, LLPounceableStatic> gMessageSystem; LLMessageConfig::SenderTrust LLMessageConfig::getSenderTrustedness(const std::string& msg_name) { - return LLMessageConfig::NOT_SET; + return LLMessageConfig::NOT_SET; } void LLMessageSystem::receivedMessageFromTrustedSender() @@ -49,12 +49,12 @@ void LLMessageSystem::receivedMessageFromTrustedSender() bool LLMessageSystem::isTrustedSender(const LLHost& host) const { - return false; + return false; } bool LLMessageSystem::isTrustedMessage(const std::string& name) const { - return false; + return false; } bool messageDispatched = false; @@ -63,80 +63,80 @@ LLSD lastLLSD; std::string lastMessageName; void LLMessageSystem::dispatch(const std::string& msg_name, - const LLSD& message, - LLHTTPNode::ResponsePtr responsep) + const LLSD& message, + LLHTTPNode::ResponsePtr responsep) { - messageDispatched = true; - lastLLSD = message; - lastMessageName = msg_name; + messageDispatched = true; + lastLLSD = message; + lastMessageName = msg_name; } void LLMessageSystem::dispatchTemplate(const std::string& msg_name, - const LLSD& message, - LLHTTPNode::ResponsePtr responsep) + const LLSD& message, + LLHTTPNode::ResponsePtr responsep) { - lastLLSD = message; - lastMessageName = msg_name; - messageDispatchedAsBinary = true; + lastLLSD = message; + lastMessageName = msg_name; + messageDispatchedAsBinary = true; } namespace tut { - struct LLTrustedMessageServiceData - { - LLTrustedMessageServiceData() - { - LLSD emptyLLSD; - lastLLSD = emptyLLSD; - lastMessageName = "uninitialised message name"; - messageDispatched = false; - messageDispatchedAsBinary = false; - } - }; - - typedef test_group<LLTrustedMessageServiceData> factory; - typedef factory::object object; + struct LLTrustedMessageServiceData + { + LLTrustedMessageServiceData() + { + LLSD emptyLLSD; + lastLLSD = emptyLLSD; + lastMessageName = "uninitialised message name"; + messageDispatched = false; + messageDispatchedAsBinary = false; + } + }; + + typedef test_group<LLTrustedMessageServiceData> factory; + typedef factory::object object; } namespace { - tut::factory tf("LLTrustedMessageServiceData"); + tut::factory tf("LLTrustedMessageServiceData"); } namespace tut { - // characterisation tests - - // 1) test that messages get forwarded with names etc. as current behaviour (something like LLMessageSystem::dispatch(name, data...) - - // test llsd messages are sent as normal using LLMessageSystem::dispatch() (eventually) - template<> template<> - void object::test<1>() - { - LLHTTPNode::ResponsePtr response; - LLSD input; - LLSD context; - LLTrustedMessageService adapter; - adapter.post(response, context, input); - // test original ting got called wit nowt, ya get me blood? - ensure_equals(messageDispatched, true); - ensure(lastLLSD.has("body")); - } - - // test that llsd wrapped binary-template-data messages are - // sent via LLMessageSystem::binaryDispatch() or similar - template<> template<> - void object::test<2>() - { - LLHTTPNode::ResponsePtr response; - LLSD input; - input["binary-template-data"] = "10001010110"; //make me a message here. - LLSD context; - LLTrustedMessageService adapter; - - adapter.post(response, context, input); - ensure("check template-binary-data message was dispatched as binary", messageDispatchedAsBinary); - ensure_equals(lastLLSD["body"]["binary-template-data"].asString(), "10001010110"); - // test somit got called with "10001010110" (something like LLMessageSystem::dispatchTemplate(blah)) - } + // characterisation tests + + // 1) test that messages get forwarded with names etc. as current behaviour (something like LLMessageSystem::dispatch(name, data...) + + // test llsd messages are sent as normal using LLMessageSystem::dispatch() (eventually) + template<> template<> + void object::test<1>() + { + LLHTTPNode::ResponsePtr response; + LLSD input; + LLSD context; + LLTrustedMessageService adapter; + adapter.post(response, context, input); + // test original ting got called wit nowt, ya get me blood? + ensure_equals(messageDispatched, true); + ensure(lastLLSD.has("body")); + } + + // test that llsd wrapped binary-template-data messages are + // sent via LLMessageSystem::binaryDispatch() or similar + template<> template<> + void object::test<2>() + { + LLHTTPNode::ResponsePtr response; + LLSD input; + input["binary-template-data"] = "10001010110"; //make me a message here. + LLSD context; + LLTrustedMessageService adapter; + + adapter.post(response, context, input); + ensure("check template-binary-data message was dispatched as binary", messageDispatchedAsBinary); + ensure_equals(lastLLSD["body"]["binary-template-data"].asString(), "10001010110"); + // test somit got called with "10001010110" (something like LLMessageSystem::dispatchTemplate(blah)) + } } diff --git a/indra/llmessage/tests/llxfer_file_test.cpp b/indra/llmessage/tests/llxfer_file_test.cpp index a8c1adf9b4..af0cc5b5ab 100644 --- a/indra/llmessage/tests/llxfer_file_test.cpp +++ b/indra/llmessage/tests/llxfer_file_test.cpp @@ -1,4 +1,4 @@ -/** +/** * @file llxfer_test.cpp * @author Moss * @date 2007-04-17 @@ -6,21 +6,21 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -33,26 +33,26 @@ namespace tut { - struct llxfer_data - { - }; - typedef test_group<llxfer_data> llxfer_test; - typedef llxfer_test::object llxfer_object; - tut::llxfer_test llxfer("LLXferFile"); + struct llxfer_data + { + }; + typedef test_group<llxfer_data> llxfer_test; + typedef llxfer_test::object llxfer_object; + tut::llxfer_test llxfer("LLXferFile"); - template<> template<> - void llxfer_object::test<1>() - { - // test that we handle an oversized filename correctly. - std::string oversized_filename; - U32 i; - for (i=0; i<LL_MAX_PATH*2; ++i) // create oversized filename - { - oversized_filename += 'X'; - } + template<> template<> + void llxfer_object::test<1>() + { + // test that we handle an oversized filename correctly. + std::string oversized_filename; + U32 i; + for (i=0; i<LL_MAX_PATH*2; ++i) // create oversized filename + { + oversized_filename += 'X'; + } - LLXfer_File xff(oversized_filename, FALSE, 1); - ensure("oversized local_filename nul-terminated", - xff.getFileName().length() < LL_MAX_PATH); - } + LLXfer_File xff(oversized_filename, FALSE, 1); + ensure("oversized local_filename nul-terminated", + xff.getFileName().length() < LL_MAX_PATH); + } } diff --git a/indra/llmessage/tests/networkio.h b/indra/llmessage/tests/networkio.h index 5986524342..a88c4ec596 100644 --- a/indra/llmessage/tests/networkio.h +++ b/indra/llmessage/tests/networkio.h @@ -2,26 +2,26 @@ * @file networkio.h * @author Nat Goodspeed * @date 2009-01-09 - * @brief - * + * @brief + * * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ |