/* ReplaceableItem(Test) - adapter to take snapshot from non-assignable values Copyright (C) Lumiera.org 2017, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *****************************************************/ #include "lib/test/run.hpp" #include "lib/test/test-helper.hpp" #include "lib/util.hpp" #include "lib/time/timevalue.hpp" #include "lib/format-cout.hpp"////////////TODO #include "lib/replaceable-item.hpp" //#include //#include //#include //#include //#include namespace lib { namespace wrapper { namespace test{ using ::Test; using lib::test::randStr; using lib::test::randTime; using util::isSameObject; using time::Time; using time::Duration; // using std::ref; // using std::vector; using std::string; using std::rand; namespace { // Test helper: yet another ctor/dtor counting class long cntTracker = 0; struct Tracker { uint i_; Tracker() : i_(rand() % 500) { ++cntTracker; } Tracker(Tracker const& ot) : i_(ot.i_) { ++cntTracker; } ~Tracker() { --cntTracker; } }; struct NonAssign : Tracker { using Tracker::Tracker; NonAssign& operator= (NonAssign const&) =delete; }; } // (END) Test helpers /***************************************************************************//** * @test use the ItemWrapper to define inline-storage holding values, * pointers and references. Verify correct behaviour in each case, * including (self)assignment, empty check, invalid dereferentiation. * * @see wrapper.hpp */ class ReplaceableItem_test : public Test { virtual void run (Arg) { ulong l1 (rand() % 1000); ulong l2 (rand() % 1000); string s1 (randStr(50)); string s2 (randStr(50)); const char* cp (s1.c_str()); Time t1{randTime()}, t2{randTime()}; Duration d1{randTime()}, d2{randTime()}; verifyWrapper (l1, l2); verifyWrapper