From 796001740394c660a93980db93c377b54257aa9b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 6 Nov 2024 02:13:23 +0100 Subject: [PATCH] Invocation: add some test coverage for the basic genrator function Nothing surprising here... Writing just some dull tests to avoid biting my nails while watching the US election.... --- src/lib/random.hpp | 2 +- tests/core/steam/engine/node-devel-test.cpp | 76 +++++++++++++++++++-- wiki/thinkPad.ichthyo.mm | 25 +++++-- 3 files changed, 90 insertions(+), 13 deletions(-) diff --git a/src/lib/random.hpp b/src/lib/random.hpp index 914d1a868..4cef79e84 100644 --- a/src/lib/random.hpp +++ b/src/lib/random.hpp @@ -98,7 +98,7 @@ namespace lib { /* ===== convenience accessors ===== */ - inline int rani() { return defaultGen.i32(); } + inline int rani() { return defaultGen.i32(); } ///< using default params: min ≡ 0, max ≡ numeric_limits inline uint64_t ranu() { return defaultGen.u64(); } inline double runi() { return defaultGen.uni(); } diff --git a/tests/core/steam/engine/node-devel-test.cpp b/tests/core/steam/engine/node-devel-test.cpp index b2037ded7..04ec403d2 100644 --- a/tests/core/steam/engine/node-devel-test.cpp +++ b/tests/core/steam/engine/node-devel-test.cpp @@ -1,8 +1,8 @@ /* - NodeDevel(Test) - verify proper render node operation and calldown + NodeDevel(Test) - Render Node development and test support Copyright (C) Lumiera.org - 2009, Hermann Vosseler + 2024, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -26,6 +26,9 @@ #include "lib/test/run.hpp" +#include "steam/engine/test-rand-ontology.hpp" ///////////TODO +#include "lib/test/diagnostic-output.hpp"/////////////////TODO +#include "lib/random.hpp" //#include "lib/util.hpp" @@ -36,18 +39,79 @@ namespace steam { namespace engine{ namespace test { + using lib::ranu; + + namespace { + /** uninitialised local storage that can be passed + * as working buffer and accessed as TestFrame */ + struct Buffer + : util::NonCopyable + { + alignas(TestFrame) + std::byte storage[sizeof(TestFrame)]; + + operator TestFrame* () { return std::launder (reinterpret_cast (&storage)); } + TestFrame* operator->() { return std::launder (reinterpret_cast (&storage)); } + TestFrame& operator* () { return * std::launder (reinterpret_cast (&storage)); } + }; + } /***************************************************************//** - * @test check render node operation modes and collaboration. + * @test verify support for developing Render Node functionality. */ class NodeDevel_test : public Test { - virtual void run(Arg) + virtual void + run (Arg) { - UNIMPLEMENTED ("operate some render nodes as linked together"); - } + lib::randomiseRandomness(); // inject entropy sees + + processing_generateFrame(); + processing_generateMultichan(); + } + + + /** @test function to generate random test data frames + */ + void + processing_generateFrame() + { + size_t frameNr = ranu(); + uint flavour = uint(ranu()); + + Buffer buff; + CHECK (not buff->isSane()); + + generateFrame (buff, frameNr, flavour); + CHECK ( buff->isSane()); + CHECK (*buff == TestFrame(frameNr,flavour)); + } + + /** @test function to generate an array of random test data frames + * for consecutive channels + */ + void + processing_generateMultichan() + { + size_t frameNr = ranu(); + uint flavour = uint(ranu()); + + uint channels = uint(1 + ranu() % 50); + CHECK (1 <= channels and channels <= 50); + + Buffer buffs[50]; + for (uint i=0; iisSane()); + + generateMultichan (channels, buffs[0], frameNr, flavour); + for (uint i=0; iisSane()); + CHECK (*(buffs[i]) == TestFrame(frameNr,flavour+i)); + } + } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6ed125fc1..2f7dc9abf 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57023,8 +57023,7 @@ also per reinterpret-cast mit std::launder, storage als std::byte mit sauberer Alignment-Angabe

- - + @@ -85744,9 +85743,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + + + + + + + + + + + + + + + @@ -91540,8 +91553,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + +