LUMIERA.clone/tests/lib/par/parameter-test.cpp
Ichthyostega 87ce59da29 Parameters: sketch a prototype-builder API
...yet the actual problem remains that the value type of the
prototype remains a runtime-dynamic hidden implementation trait.

How can we remould the scale hidden within a parameter, while
in the regular setup, the scale is implemented as an immutable
entry placed into a registry?
2026-09-06 01:39:09 +02:00

137 lines
3 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.

/*
Parameter(Test) - verify generic parameter values
Copyright (C)
2026, 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 parameter-test.cpp
** unit test \ref Parameter_test
*/
#include "test/run.hpp"
//#include "test/test-helper.hpp"
#include "lib/par/parameter.hpp"
#include "test/diagnostic-output.hpp"/////////////TODO
//#include <utility>
//#include <string>
//#include <vector>
//using std::string;
//using std::vector;
//using std::swap;
namespace lib {
namespace par {
namespace test{
// using lumiera::error::LUMIERA_ERROR_LOGIC;
namespace {//Test fixture....
}//(End)Test fixture
/**************************************************************************//**
* @test cover properties of generic parameter containers.
*/
class Parameter_test : public Test
{
virtual void
run (Arg)
{
simpleUsage();
verify_Builder();
verify_Identity();
verify_ParamType();
verify_Automation();
}
void
simpleUsage()
{
CHECK (sizeof(Parameter) <= 4 * sizeof(void*));
CHECK (BASETYPE_MAX_SIZ <= sizeof(ValStorage));
Parameter par = Parameter::forType<int>().build();
CHECK (0 == par.getVal<int>());
par.setVal (12.3);
CHECK (12 == par.getVal<int>());
CHECK (12u == par.getVal<uint64_t>());
CHECK (12.0 == par.getVal<double>());
CHECK (true == par.getVal<bool>());
}
/** @test explore ways to define a parameter...
* @todo WIP 9/26 🔁 define ⟶ implement
*/
void
verify_Builder()
{
Parameter p1 = Parameter::forValue(123.45f).build();
CHECK (123.45f == p1.getVal<float>());
p1.setVal (12u);
CHECK (12.0 == p1.getVal<double>());
Parameter p2 = Parameter::from(p1)
.maxVal (sqrt(2))
.build();
SHOW_EXPR(p2.getVal<float>());
}
/** @test
* @todo WIP 9/26 🔁 define ⟶ implement
*/
void
verify_Identity()
{
}
/** @test
* @todo WIP 9/26 🔁 define ⟶ implement
*/
void
verify_ParamType()
{
}
/** @test
* @todo WIP 9/26 🔁 define ⟶ implement
*/
void
verify_Automation()
{
}
};
/** Register this test class... */
LAUNCHER (Parameter_test, "unit lib");
}}} // namespace lib::par::test