diff --git a/src/lib/scoped-collection.hpp b/src/lib/scoped-collection.hpp index efb572c69..261707ba7 100644 --- a/src/lib/scoped-collection.hpp +++ b/src/lib/scoped-collection.hpp @@ -360,6 +360,7 @@ namespace lib { + ///////////////////////////////////////////////////////TICKET #967 : the following can be written better now. Also should be named 'emplace' /** push a new element of default type * to the end of this container * @note EX_STRONG */ @@ -551,7 +552,7 @@ namespace lib { /** \par usage * Pass an instance of this builder functor as 2nd parameter * to ScopedCollections's ctor. (an anonymous instance is OK). - * Using this variant of the compiler switches the collection to RAII-style: + * Using this variant of the ctor switches the collection to RAII-style: * It will immediately try to create all the embedded objects, invoking this * builder functor for each "slot" to hold such an embedded object. Actually, * this "slot" is an ElementHolder instance, which provides functions for diff --git a/tests/library/scoped-collection-test.cpp b/tests/library/scoped-collection-test.cpp index 6a9f6ecfe..1c194b96c 100644 --- a/tests/library/scoped-collection-test.cpp +++ b/tests/library/scoped-collection-test.cpp @@ -65,7 +65,7 @@ namespace test{ , trigger_(trigger) { if (trigger == getVal()) - throw new error::Fatal ("Subversive Bomb", LUMIERA_ERROR_SUBVERSIVE); + throw error::Fatal ("Subversive Bomb", LUMIERA_ERROR_SUBVERSIVE); } SubDummy() @@ -290,7 +290,7 @@ namespace test{ CHECK (0 == Dummy::checksum()); { int rr = rand() % 100; - int trigger = 101; + int trigger = 100 + 5 + 1; // prevents the bomb from exploding (since rr < 100) CollD coll (6, Populator(rr, trigger)); @@ -304,6 +304,13 @@ namespace test{ CHECK (coll[3].acc(0) == 3 + rr + trigger); CHECK (coll[4].acc(0) == 4 + rr); CHECK (coll[5].acc(0) == 5 + rr + trigger); + // what does this check prove? + // - the container was indeed populated with DubDummy objects + // since the overridden version of Dummy::acc() did run and + // reveal the trigger value + // - the population was indeed done with the anonymous Populator + // instance fed to the ctor, since this object was "marked" with + // the random value rr, and adds this mark to the built values. coll.clear(); CHECK (0 == Dummy::checksum());