summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-02-04 10:57:48 -0500
committerNat Goodspeed <nat@lindenlab.com>2011-02-04 10:57:48 -0500
commitf0c1c4f5b0b7ab37f0830e2b9e3dab09935c2700 (patch)
treed86be1c77d07e83776b07475afe3edf0405bdfd0 /indra/llcommon/tests
parentf2bb1b451cc37bcc2c09687fd52515d8b791d97a (diff)
Move FunctionsTriple data to function returning vector<same>.
We want to break out a couple different test methods that both need the same data. While we could define a std::vector<FunctionsTriple> in the lleventdispatcher_data class and initialize it using a classic {} initializer as in array_funcs(), using a separate function puts it closer to the tests consuming that data, and helps reduce clutter in the central data class. Either way, it's cool that BOOST_FOREACH() handles the gory details of iterating over a std::vector vs. a classic-C array.
Diffstat (limited to 'indra/llcommon/tests')
-rw-r--r--indra/llcommon/tests/lleventdispatcher_test.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/indra/llcommon/tests/lleventdispatcher_test.cpp b/indra/llcommon/tests/lleventdispatcher_test.cpp
index f9202307f7..f8cf93f838 100644
--- a/indra/llcommon/tests/lleventdispatcher_test.cpp
+++ b/indra/llcommon/tests/lleventdispatcher_test.cpp
@@ -1098,7 +1098,7 @@ namespace tut
// array-style call with empty array (or LLSD(), should be equivalent)
work(tr.name1, LLSD());
ensure_equals(tr.vars.i, 17);
-
+
tr.vars = Vars();
// map-style call with empty map (or LLSD(), should be equivalent)
work(tr.name2, LLSD());
@@ -1106,20 +1106,27 @@ namespace tut
}
}
- template<> template<>
- void object::test<19>()
+ // Break out function to return this data because we use it in a couple
+ // different tests.
+ std::vector<FunctionsTriple> array_funcs(Vars& v)
{
- set_test_name("call array-style functions with too-short arrays");
FunctionsTriple tests[] =
{
{ "freena_array", "freenb_array", g },
{ "smethodna_array", "smethodnb_array", g },
{ "methodna_array", "methodnb_array", v }
};
+ return std::vector<FunctionsTriple>(boost::begin(tests), boost::end(tests));
+ }
+
+ template<> template<>
+ void object::test<19>()
+ {
+ set_test_name("call array-style functions with too-short arrays");
// Could have two different too-short arrays, one for *na and one for
// *nb, but since they both take 5 params...
LLSD tooshort(LLSDArray("this")("array")("too")("short"));
- foreach(const FunctionsTriple& tr, tests)
+ foreach(const FunctionsTriple& tr, array_funcs(v))
{
call_exc(tr.name1, tooshort, "requires more arguments");
call_exc(tr.name2, tooshort, "requires more arguments");