c++11 uses another hashtable implementation. This uncovered some poorly written tests, which relied on objects being returned in a specific order. As far as poissible, we're using generic query functions now to get our test objects. But these tests still rely on a specifically crafted test index content, which as such is acceptable IMHO. The only remaining problem is that we check the order of generated output in some tests, and this order is still implementation dependent.
126 lines
4.2 KiB
C++
126 lines
4.2 KiB
C++
/*
|
|
PlacementIndexQuery(Test) - querying the placement index through the generic query interface
|
|
|
|
Copyright (C) Lumiera.org
|
|
2009, 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 "proc/mobject/session/scope-query.hpp"
|
|
#include "proc/mobject/session/session-service-explore-scope.hpp"
|
|
#include "proc/mobject/session/placement-index-query-resolver.hpp"
|
|
#include "proc/mobject/session/test-scopes.hpp"
|
|
#include "common/query/query-resolver.hpp"
|
|
#include "lib/util.hpp"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace proc {
|
|
namespace mobject {
|
|
namespace session {
|
|
namespace test {
|
|
|
|
using lumiera::QueryResolver;
|
|
using session::PathQuery;
|
|
using session::ContentsQuery;
|
|
using util::isSameObject;
|
|
using std::string;
|
|
using std::cout;
|
|
using std::endl;
|
|
|
|
|
|
/************************************************************************//**
|
|
* @test accessing the PlacementIndex through the generic query interface,
|
|
* for discovering scope contents and containing scope.
|
|
*
|
|
* @todo change that to use a more realistic test session, based on the actual model types //////////////// TICKET #532
|
|
*
|
|
* @see mobject::session::PlacementIndex
|
|
* @see mobject::session::QueryResolver
|
|
* @see mobject::session::ContentsQuery
|
|
*/
|
|
class PlacementIndexQuery_test : public Test
|
|
{
|
|
|
|
virtual void
|
|
run (Arg)
|
|
{
|
|
checkQueryResolver();
|
|
checkQueryOperations();
|
|
}
|
|
|
|
void
|
|
checkQueryResolver()
|
|
{
|
|
PPIdx index = build_testScopes();
|
|
QueryResolver const& resolver1 (SessionServiceExploreScope::getResolver());
|
|
QueryResolver const& resolver2 (SessionServiceExploreScope::getResolver());
|
|
|
|
CHECK (isSameObject (resolver1, resolver2));
|
|
|
|
PlacementMO& root1 = index->getRoot();
|
|
PlacementMO& root2 = SessionServiceExploreScope::getScopeRoot();
|
|
CHECK (isSameObject (root1, root2));
|
|
|
|
PlacementMO& elm1 = *ContentsQuery<TestSubMO2>(root1).resolveBy(resolver1);
|
|
PlacementMO& elm2 = *ContentsQuery<TestSubMO1>(root1).resolveBy(resolver1);
|
|
PlacementMO& elm3 = *(index->getReferrers(elm1));
|
|
CHECK (isSameObject (elm3, elm2));
|
|
// relying on the specific setup of the test index
|
|
// MO1 is the sole "referrer" of MO2 (the only content within MO2's scope)
|
|
// root \ TestSubMO2 \ TestSubMO1
|
|
}
|
|
|
|
void
|
|
checkQueryOperations()
|
|
{
|
|
// Prepare an (test)Index (dummy "session")
|
|
PPIdx index = build_testScopes();
|
|
PlacementMO& root = index->getRoot();
|
|
PlacementIndexQueryResolver resolver(*index);
|
|
|
|
cout << "explore contents depth-first..." << endl;
|
|
discover (ContentsQuery<MObject>(root).resolveBy(resolver));
|
|
|
|
PlacementMO& elm = *ContentsQuery<TestSubMO1>(root).resolveBy(resolver); ////////////////////// TICKET #532
|
|
|
|
cout << "path to root starting at " << string(elm) << endl;
|
|
discover (PathQuery<MObject> (elm).resolveBy(resolver));
|
|
}
|
|
|
|
|
|
template<class IT>
|
|
void
|
|
discover (IT result)
|
|
{
|
|
for ( ; result; ++result)
|
|
cout << string(*result) << endl;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
/** Register this test class... */
|
|
LAUNCHER (PlacementIndexQuery_test, "unit session");
|
|
|
|
|
|
}}}} // namespace proc::mobject::session::test
|