lumiera_/tests/core/steam/engine/node-base-test.cpp
Ichthyostega cf4bc380b0 Invocation: break-through with generic implementation
This changeset is a sketch how to switch the entire implementation of the ''Invocation Adatper''
over to a generic argument usage scheme. This requires the ability to
 - detect if some argument is actually a ''structured type''
 - investigate components of such a structured type to draw a distinction between »Buffer« and »Parameter«
 - ''lift'' the implementation of simple values to work on tuples
 - provide a way to ''bridge'' from ''tuple-style'' programming to ''array access''

As a building block, we use a new iteration-over-index construct,
based on an idea discussed in https://stackoverflow.com/q/53522781/444796
The trick is to pass a `std::integer_constant` to a λ-generic
2024-12-18 00:38:16 +01:00

128 lines
3.9 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
NodeBase(Test) - unit test to cover the render node base elements
Copyright (C)
2009, Hermann Vosseler <Ichthyostega@web.de>
  **Lumiera** 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. See the file COPYING for further details.
* *****************************************************************/
/** @file node-base-test.cpp
** Unit test \ref NodeBase_test covers elementary components of render nodes.
*/
#include "lib/test/run.hpp"
//#include "lib/test/test-helper.hpp"
#include "lib/meta/function.hpp"
#include "steam/engine/proc-node.hpp"
#include "steam/engine/turnout.hpp"
#include "steam/engine/turnout-system.hpp"
#include "steam/engine/feed-manifold.hpp"
#include "steam/engine/diagnostic-buffer-provider.hpp"
#include "steam/engine/buffhandle-attach.hpp"
//#include "lib/format-cout.hpp"
#include "lib/test/diagnostic-output.hpp"/////////////////////TODO
//#include "lib/util.hpp"
//using std::string;
using std::tuple;/////////////TODO
using std::array;
namespace steam {
namespace engine{
namespace test {
namespace { // Test fixture
/**
*/
}
/***************************************************************//**
* @test basic render node properties and behaviour.
*/
class NodeBase_test : public Test
{
virtual void
run (Arg)
{
seedRand();
verify_TurnoutSystem();
verify_FeedManifold();
UNIMPLEMENTED ("build a simple render node and then activate it");
}
/** @test the TurnoutSystem as transient coordinator for node invocation
*/
void
verify_TurnoutSystem()
{
Time nomTime{rani(10'000),0}; // drive test with a random »nominal Time« <10s with ms granularity
TurnoutSystem invoker{nomTime}; // a time spec is mandatory, all further parameters are optional
}
/** @test the FeedManifold as adapter between Engine and processing library
*/
void
verify_FeedManifold()
{
// some random numbers to test...
long r1 = rani(100);
// Type setup to build a suitable FeedManifold
using Buffer = long;
/////////////////////////////////////////////////////////////////////////////////TODO
using T1 = tuple<int,double>;
using T2 = array<int*,3>;
using T3 = int;
using T4 = int*;
using T5 = lib::HeteroData<int*>;
/////////////////////////////////////////////////////////////////////////////////TODO
auto fun_singleOut = [&](Buffer* buff) { *buff = r1; };
using M1 = FeedManifold<decltype(fun_singleOut)>;
CHECK (not M1::hasInput());
CHECK (not M1::hasParam());
M1 m1{fun_singleOut};
CHECK (1 == m1.outBuff.array().size());
SHOW_EXPR(m1.outArgs)
CHECK (nullptr == m1.outArgs );
// CHECK (m1.inArgs ); // does not compile because storage field is not provided
// CHECK (m1.param );
BufferProvider& provider = DiagnosticBufferProvider::build();
BuffHandle buff = provider.lockBufferFor<long> (-55);
CHECK (buff.isValid());
CHECK (buff.accessAs<long>() == -55);
m1.outBuff.createAt (0, buff);
CHECK (m1.outBuff[0].isValid());
CHECK (m1.outBuff[0].accessAs<long>() == -55);
SHOW_TYPE(M1::ArgI)
SHOW_TYPE(M1::TupI)
SHOW_TYPE(M1::ArgO)
SHOW_TYPE(M1::TupO)
m1.connect();
SHOW_EXPR(m1.outArgs)
SHOW_EXPR(m1.outBuff[0])
SHOW_EXPR(util::showAdr(*buff))
SHOW_EXPR(util::showAdr(*m1.outBuff[0]))
}
};
/** Register this test class... */
LAUNCHER (NodeBase_test, "unit node");
}}} // namespace steam::engine::test