2026-07-03 19:55:55 +02:00
|
|
|
|
/*
|
|
|
|
|
|
ParameterDomain(Test) - document the handling of parameter type domain
|
|
|
|
|
|
|
|
|
|
|
|
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-domain-test.cpp
|
|
|
|
|
|
** unit test \ref ParameterDomain_test
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "test/run.hpp"
|
|
|
|
|
|
//#include "test/test-helper.hpp"
|
|
|
|
|
|
#include "lib/par/domain.hpp"
|
2026-07-19 23:44:30 +02:00
|
|
|
|
#include "test/diagnostic-output.hpp"////////////TODO
|
2026-07-03 19:55:55 +02:00
|
|
|
|
|
|
|
|
|
|
//#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....
|
|
|
|
|
|
|
|
|
|
|
|
class Thing
|
|
|
|
|
|
{ };
|
|
|
|
|
|
|
|
|
|
|
|
template<typename X>
|
|
|
|
|
|
struct Some
|
|
|
|
|
|
{
|
|
|
|
|
|
X x;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef Some<Thing> SomeThing;
|
2026-07-05 22:12:18 +02:00
|
|
|
|
|
2026-07-03 19:55:55 +02:00
|
|
|
|
}//(End)Test fixture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************//**
|
|
|
|
|
|
* @test cover properties of generic parameter containers.
|
|
|
|
|
|
*/
|
|
|
|
|
|
class ParameterDomain_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
|
run (Arg)
|
|
|
|
|
|
{
|
2026-07-05 22:12:18 +02:00
|
|
|
|
seedRand();
|
|
|
|
|
|
basics();
|
2026-07-20 23:12:24 +02:00
|
|
|
|
verify_valueLimits();
|
2026-07-19 23:44:30 +02:00
|
|
|
|
verify_valueAccess();
|
2026-07-03 19:55:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2026-07-05 22:12:18 +02:00
|
|
|
|
basics()
|
2026-07-03 19:55:55 +02:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-20 23:12:24 +02:00
|
|
|
|
void
|
|
|
|
|
|
verify_valueLimits()
|
|
|
|
|
|
{
|
|
|
|
|
|
SHOW_EXPR(preClamp<int> (23))
|
|
|
|
|
|
SHOW_EXPR(preClamp<int> (-55))
|
|
|
|
|
|
SHOW_EXPR(preClamp<uint> (23))
|
|
|
|
|
|
SHOW_EXPR(preClamp<uint> (-55))
|
|
|
|
|
|
SHOW_EXPR((sub_domain<uint,int>))
|
|
|
|
|
|
SHOW_EXPR((sub_domain<int,uint>))
|
|
|
|
|
|
SHOW_EXPR((sub_domain<short,long>))
|
2026-07-21 23:58:29 +02:00
|
|
|
|
SHOW_EXPR((sub_domain<long,short>))
|
2026-07-20 23:12:24 +02:00
|
|
|
|
SHOW_EXPR(std::numeric_limits<uint>::max())
|
|
|
|
|
|
SHOW_EXPR(std::numeric_limits<int>::max())
|
|
|
|
|
|
SHOW_EXPR(std::numeric_limits<uint>::lowest())
|
|
|
|
|
|
SHOW_EXPR(std::numeric_limits<int>::lowest())
|
|
|
|
|
|
|
|
|
|
|
|
SHOW_EXPR(preClamp<short> (INT64_MAX))
|
|
|
|
|
|
SHOW_EXPR(preClamp<short> (INT64_MIN))
|
2026-07-21 23:58:29 +02:00
|
|
|
|
|
|
|
|
|
|
SHOW_EXPR(preClamp<ushort> (numeric_limits<float>::max()))
|
|
|
|
|
|
SHOW_EXPR(preClamp<ushort> (numeric_limits<float>::lowest()))
|
|
|
|
|
|
|
|
|
|
|
|
SHOW_EXPR(preClamp<float> (numeric_limits<uint64_t>::max()))
|
|
|
|
|
|
SHOW_EXPR(preClamp<float> (numeric_limits<double>::lowest()))
|
|
|
|
|
|
|
|
|
|
|
|
SHOW_EXPR(preClamp<bool> (0.5));
|
|
|
|
|
|
SHOW_EXPR(preClamp<bool> (0.5 + numeric_limits<double>::epsilon()))
|
|
|
|
|
|
SHOW_EXPR(preClamp<bool> (numeric_limits<double>::min()))
|
2026-07-20 23:12:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-03 19:55:55 +02:00
|
|
|
|
void
|
2026-07-19 23:44:30 +02:00
|
|
|
|
verify_valueAccess()
|
2026-07-03 19:55:55 +02:00
|
|
|
|
{
|
2026-07-05 22:12:18 +02:00
|
|
|
|
BaseDomain<int> domInt;
|
|
|
|
|
|
Domain& d1{domInt};
|
|
|
|
|
|
|
|
|
|
|
|
int val1 = 1 + rani (1000);
|
|
|
|
|
|
ValBuff& src1 = asValBuff (val1);
|
|
|
|
|
|
|
|
|
|
|
|
uint target1{0};
|
|
|
|
|
|
CHECK (not target1);
|
|
|
|
|
|
|
2026-07-19 23:44:30 +02:00
|
|
|
|
TypeHandler<uint>& du1{d1};
|
|
|
|
|
|
du1.extractAs (target1, src1);
|
2026-07-05 22:12:18 +02:00
|
|
|
|
CHECK (target1 == uint(val1));
|
2026-07-19 23:44:30 +02:00
|
|
|
|
|
|
|
|
|
|
float target2{0};
|
|
|
|
|
|
|
|
|
|
|
|
TypeHandler<float>& df1{d1};
|
|
|
|
|
|
df1.extractAs (target2, src1);
|
|
|
|
|
|
CHECK (target2 == float(val1));
|
2026-07-03 19:55:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (ParameterDomain_test, "unit lib");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace lib::par::test
|