this also supersedes and removes the initial implementation draft for attribute binding with the 'setAttribute' API The elementary part of diff application incl. setting new attribute values works by now.
130 lines
3.2 KiB
C++
130 lines
3.2 KiB
C++
/*
|
|
TreeMutator(Test) - customisable intermediary to abstract tree changing operations
|
|
|
|
Copyright (C) Lumiera.org
|
|
2015, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
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/format-util.hpp"
|
|
#include "lib/test/test-helper.hpp"
|
|
#include "lib/diff/tree-mutator.hpp"
|
|
#include "lib/format-cout.hpp"
|
|
#include "lib/util.hpp"
|
|
|
|
//#include <utility>
|
|
#include <string>
|
|
//#include <vector>
|
|
|
|
using util::isnil;
|
|
using std::string;
|
|
//using std::vector;
|
|
//using std::swap;
|
|
|
|
using util::typeStr;
|
|
|
|
|
|
namespace lib {
|
|
namespace diff{
|
|
namespace test{
|
|
|
|
// using lumiera::error::LUMIERA_ERROR_LOGIC;
|
|
|
|
namespace {//Test fixture....
|
|
|
|
|
|
|
|
}//(End)Test fixture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************//**
|
|
* @test Demonstrate a customisable component for flexible bindings
|
|
* to enable generic tree changing and mutating operations to
|
|
* arbitrary hierarchical data structures.
|
|
*
|
|
* @see TreeMutator
|
|
* @see GenNodeBasic_test
|
|
* @see GenericRecordRepresentation_test
|
|
* @see GenericTreeRepresentation_test
|
|
*/
|
|
class TreeMutator_test : public Test
|
|
{
|
|
|
|
virtual void
|
|
run (Arg)
|
|
{
|
|
simpleAttributeBinding();
|
|
sequenceIteration();
|
|
copy_and_move();
|
|
}
|
|
|
|
|
|
void
|
|
simpleAttributeBinding()
|
|
{
|
|
string localData;
|
|
auto mutator =
|
|
TreeMutator::build()
|
|
.change("data", [&](string val)
|
|
{
|
|
cout << "\"data\" closure received something "<<val<<endl;
|
|
localData = val;
|
|
});
|
|
|
|
cout << "concrete TreeMutator size=" << sizeof(mutator)
|
|
<< " type="<< typeStr(mutator)
|
|
<< endl;
|
|
|
|
CHECK (isnil (localData));
|
|
string testValue{"that would be acceptable"};
|
|
mutator.assignElm ({"lore", testValue});
|
|
CHECK ( isnil (localData)); // nothing happens, nothing changed
|
|
mutator.assignElm ({"data", testValue});
|
|
CHECK (!isnil (localData));
|
|
cout << "localData changed to: "<<localData<<endl;
|
|
CHECK (localData == "that would be acceptable");
|
|
}
|
|
|
|
|
|
void
|
|
sequenceIteration()
|
|
{
|
|
}
|
|
|
|
|
|
void
|
|
copy_and_move()
|
|
{
|
|
}
|
|
};
|
|
|
|
|
|
/** Register this test class... */
|
|
LAUNCHER (TreeMutator_test, "unit common");
|
|
|
|
|
|
|
|
}}} // namespace lib::diff::test
|