Commits

nat_linden committed 70402be

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.

Comments (0)

Files changed (1)

indra/llcommon/tests/lleventdispatcher_test.cpp

             // 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());
         }
     }
 
-    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");