summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2023-01-13 21:53:18 -0500
committerNat Goodspeed <nat@lindenlab.com>2023-07-13 12:49:08 -0400
commit98793b8d44b32604033bd1b280f37023c86055bb (patch)
treeaa08312d7e10c2e974707903ef917405b69a810d
parentd637229beeb3b7fa2bc7adb850ce9337b119037c (diff)
DRTVWR-558: Make DispatchResult methods use their arguments.
Fix lleventdispatcher_test.cpp's test class DispatchResult::strfunc(), intfunc(), mapfunc() and arrayfunc() to return values derived from (not identical to) their arguments, so we can reuse these functions for further testing of passing arguments to a named callable. Adjust existing tests accordingly. (cherry picked from commit 07e09a8daea008d28b97399920db60a147cf75c0)
-rw-r--r--indra/llcommon/tests/lleventdispatcher_test.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/indra/llcommon/tests/lleventdispatcher_test.cpp b/indra/llcommon/tests/lleventdispatcher_test.cpp
index 179fab9fad..0254d23a0b 100644
--- a/indra/llcommon/tests/lleventdispatcher_test.cpp
+++ b/indra/llcommon/tests/lleventdispatcher_test.cpp
@@ -1351,12 +1351,18 @@ namespace tut
add("arrayfunc", "return array LLSD", &DR::arrayfunc, [this](){ return this; });
}
- std::string strfunc(const LLSD&) const { return "a string"; }
+ std::string strfunc(const std::string& str) const { return "got " + str; }
void voidfunc() const {}
LLSD emptyfunc() const { return {}; }
- int intfunc(const LLSD&) const { return 17; }
- LLSD mapfunc(const LLSD&) const { return llsd::map("key", "value"); }
- LLSD arrayfunc(const LLSD&) const { return llsd::array("a", "b", "c"); }
+ int intfunc(int i) const { return -i; }
+ LLSD mapfunc(int i, const std::string& str) const
+ {
+ return llsd::map("i", intfunc(i), "str", strfunc(str));
+ }
+ LLSD arrayfunc(int i, const std::string& str) const
+ {
+ return llsd::array(intfunc(i), strfunc(str));
+ }
};
template<> template<>
@@ -1364,8 +1370,8 @@ namespace tut
{
set_test_name("string result");
DispatchResult service;
- LLSD result{ service("strfunc", "ignored") };
- ensure_equals("strfunc() mismatch", result.asString(), "a string");
+ LLSD result{ service("strfunc", "a string") };
+ ensure_equals("strfunc() mismatch", result.asString(), "got a string");
}
template<> template<>
@@ -1382,7 +1388,7 @@ namespace tut
{
set_test_name("Integer result");
DispatchResult service;
- LLSD result{ service("intfunc", "ignored") };
+ LLSD result{ service("intfunc", -17) };
ensure_equals("intfunc() mismatch", result.asInteger(), 17);
}
@@ -1391,8 +1397,8 @@ namespace tut
{
set_test_name("map LLSD result");
DispatchResult service;
- LLSD result{ service("mapfunc", "ignored") };
- ensure_equals("mapfunc() mismatch", result, llsd::map("key", "value"));
+ LLSD result{ service("mapfunc", llsd::array(-12, "value")) };
+ ensure_equals("mapfunc() mismatch", result, llsd::map("i", 12, "str", "got value"));
}
template<> template<>
@@ -1400,8 +1406,8 @@ namespace tut
{
set_test_name("array LLSD result");
DispatchResult service;
- LLSD result{ service("arrayfunc", "ignored") };
- ensure_equals("arrayfunc() mismatch", result, llsd::array("a", "b", "c"));
+ LLSD result{ service("arrayfunc", llsd::array(-8, "word")) };
+ ensure_equals("arrayfunc() mismatch", result, llsd::array(8, "got word"));
}
template<> template<>
@@ -1453,12 +1459,12 @@ namespace tut
LLCaptureListener<LLSD> result;
service.post(llsd::map(
"op", "strfunc",
- "args", llsd::array(LLSD()),
+ "args", llsd::array("a string"),
"reqid", 17,
"reply", result.getName()));
LLSD reply{ result.get() };
ensure_equals("reqid not echoed", reply["reqid"].asInteger(), 17);
- ensure_equals("bad reply from strfunc", reply["data"].asString(), "a string");
+ ensure_equals("bad reply from strfunc", reply["data"].asString(), "got a string");
}
template<> template<>
@@ -1469,11 +1475,12 @@ namespace tut
LLCaptureListener<LLSD> result;
service.post(llsd::map(
"op", "mapfunc",
- "args", llsd::array(LLSD()),
+ "args", llsd::array(-7, "value"),
"reqid", 17,
"reply", result.getName()));
LLSD reply{ result.get() };
ensure_equals("reqid not echoed", reply["reqid"].asInteger(), 17);
- ensure_equals("bad reply from mapfunc", reply["key"], "value");
+ ensure_equals("bad i from mapfunc", reply["i"].asInteger(), 7);
+ ensure_equals("bad str from mapfunc", reply["str"], "got value");
}
} // namespace tut