2026-01-25 00:19:30 +01:00
|
|
|
|
/*
|
|
|
|
|
|
EngineCtx(Test) - calculation of (internal) buffer metadata type keys
|
|
|
|
|
|
|
|
|
|
|
|
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 engine-ctx-test.cpp
|
|
|
|
|
|
** unit test \ref EngineCtx_test
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2026-03-06 21:34:20 +01:00
|
|
|
|
#include "test/run.hpp"
|
|
|
|
|
|
#include "test/test-helper.hpp"
|
2026-01-25 00:19:30 +01:00
|
|
|
|
#include "steam/engine/engine-ctx.hpp"
|
2026-03-08 00:53:41 +01:00
|
|
|
|
#include "vault/mem/buffer-provider.hpp"
|
2026-01-25 00:19:30 +01:00
|
|
|
|
#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using util::isSameObject;
|
2026-03-08 00:53:41 +01:00
|
|
|
|
using vault::mem::BuffHandle;
|
|
|
|
|
|
using vault::mem::BufferProvider;
|
2026-01-25 00:19:30 +01:00
|
|
|
|
|
|
|
|
|
|
namespace steam {
|
|
|
|
|
|
namespace engine{
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
|
|
namespace { // Test fixture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//(End) Test helpers
|
|
|
|
|
|
|
|
|
|
|
|
using LERR_(LIFECYCLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************//**
|
|
|
|
|
|
* @test verify context with generic management services for Dependency Injection,
|
|
|
|
|
|
* used within the Render Node Network to hide global setup state.
|
|
|
|
|
|
*/
|
|
|
|
|
|
class EngineCtx_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
|
run (Arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
// seedRand();
|
|
|
|
|
|
simpleUsage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
simpleUsage()
|
|
|
|
|
|
{
|
|
|
|
|
|
auto& ctx = EngineCtx::access;
|
|
|
|
|
|
BufferProvider& provider = ctx().mem;
|
|
|
|
|
|
|
|
|
|
|
|
// in the default config (for tests) there is no separate cache provider
|
|
|
|
|
|
CHECK (isSameObject (provider, ctx().cache));
|
|
|
|
|
|
|
|
|
|
|
|
BuffHandle buff = provider.lockBufferFor<int>();
|
|
|
|
|
|
CHECK (buff.isValid());
|
|
|
|
|
|
CHECK (sizeof(int) <= buff.size());
|
|
|
|
|
|
|
|
|
|
|
|
buff.accessAs<int>() = -LIFE_AND_UNIVERSE_4EVER;
|
|
|
|
|
|
CHECK (buff.accessAs<int>() == -int(LIFE_AND_UNIVERSE_4EVER));
|
|
|
|
|
|
|
|
|
|
|
|
uint alternativeTruth = buff.accessAs<uint>();
|
|
|
|
|
|
CHECK (alternativeTruth == -LIFE_AND_UNIVERSE_4EVER);
|
|
|
|
|
|
|
|
|
|
|
|
buff.release();
|
|
|
|
|
|
CHECK (not buff.isValid());
|
|
|
|
|
|
VERIFY_ERROR (LIFECYCLE, buff.accessAs<int>() );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @todo automagically post on X with lots of UPERCASE LETTERS */
|
|
|
|
|
|
void
|
|
|
|
|
|
verify_disaster()
|
|
|
|
|
|
{
|
|
|
|
|
|
UNIMPLEMENTED ("general meltdown");
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (EngineCtx_test, "unit engine");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace steam::engine::test
|