diff --git a/src/lib/test/test-helper.hpp b/src/lib/test/test-helper.hpp index 4419e6f48..4bc0ed053 100644 --- a/src/lib/test/test-helper.hpp +++ b/src/lib/test/test-helper.hpp @@ -66,7 +66,7 @@ namespace test{ roughEQ (F val, N target, F limit =ROUGH_PRECISION) { REQUIRE (0 < limit); - return abs (val/target - F(1)) < limit; + return abs (val - target) < limit * abs(target); } //////////////////////////////////////////////////////////////////////////TICKET #1360 looks like this problem was solved several times diff --git a/tests/core/steam/engine/node-devel-test.cpp b/tests/core/steam/engine/node-devel-test.cpp index cc4c24e48..46518a59e 100644 --- a/tests/core/steam/engine/node-devel-test.cpp +++ b/tests/core/steam/engine/node-devel-test.cpp @@ -20,11 +20,12 @@ #include "lib/hash-combine.hpp" #include "steam/engine/test-rand-ontology.hpp" ///////////TODO #include "lib/test/diagnostic-output.hpp"/////////////////TODO +#include "lib/iter-zip.hpp" #include "lib/random.hpp" //#include "lib/util.hpp" -//using std::string; +using lib::zip; namespace steam { @@ -69,6 +70,7 @@ namespace test { processing_generateFrame(); processing_generateMultichan(); processing_manipulateFrame(); + processing_combineFrames(); } @@ -104,7 +106,7 @@ namespace test { for (uint i=0; iisSane()); - generateMultichan (channels, buffs[0], frameNr, flavour); + generateMultichan (buffs[0], channels, frameNr, flavour); for (uint i=0; iisSane()); @@ -124,7 +126,7 @@ namespace test { iBuff.buildData(frameNr,flavour); oBuff.buildData(frameNr,flavour); CHECK (iBuff->isPristine()); - CHECK (iBuff->isPristine()); + CHECK (oBuff->isPristine()); uint64_t param = defaultGen.u64(); manipulateFrame (oBuff, iBuff, param); @@ -132,14 +134,15 @@ namespace test { CHECK (not oBuff->isPristine()); CHECK ( iBuff->isPristine()); - for (uint i=0; idata64().size(); ++i) + for (auto [iDat,oDat] : zip (iBuff->data64() + ,oBuff->data64())) { + CHECK (oDat != iDat); uint64_t feed = param; - uint64_t data = iBuff->data64()[i]; - lib::hash::combine (feed, data); - CHECK (data == iBuff->data64()[i]); - CHECK (feed != iBuff->data64()[i]); - CHECK (feed == oBuff->data64()[i]); + lib::hash::combine (feed, iDat); + CHECK (feed != param); + CHECK (feed != iDat); + CHECK (feed == oDat); } // can also process in-place manipulateFrame (iBuff, iBuff, param); @@ -147,6 +150,41 @@ namespace test { CHECK ( iBuff->isValid()); CHECK (*iBuff == *oBuff); // second invocation exactly reproduced data from first invocation } + + /** @test function to mix two test data frames + */ + void + processing_combineFrames() + { + size_t frameNr = defaultGen.u64(); + uint flavour = defaultGen.u64(); + + Buffer i1Buff, i2Buff, oBuff; + i1Buff.buildData(frameNr,flavour+0); + i2Buff.buildData(frameNr,flavour+1); + oBuff.buildData(); + CHECK (i1Buff->isPristine()); + CHECK (i2Buff->isPristine()); + CHECK (oBuff->isPristine()); + + double mix = defaultGen.uni(); + combineFrames (oBuff, i1Buff, i2Buff, mix); + CHECK ( oBuff->isValid()); + CHECK (not oBuff->isPristine()); + CHECK ( i1Buff->isPristine()); + CHECK ( i2Buff->isPristine()); + + for (auto [oDat,i1Dat,i2Dat] : zip (oBuff->data() + ,i1Buff->data() + ,i2Buff->data())) + CHECK (oDat == std::lround((1-mix)*i1Dat + mix*i2Dat)); + + // can also process in-place + combineFrames (i1Buff, i1Buff, i2Buff, mix); + CHECK (not i1Buff->isPristine()); + CHECK ( i1Buff->isValid()); + CHECK (*i1Buff == *oBuff); // second invocation exactly reproduced data from first invocation + } }; diff --git a/tests/core/steam/engine/test-rand-ontology.cpp b/tests/core/steam/engine/test-rand-ontology.cpp index eea99625e..29c74d63a 100644 --- a/tests/core/steam/engine/test-rand-ontology.cpp +++ b/tests/core/steam/engine/test-rand-ontology.cpp @@ -25,9 +25,12 @@ #include "steam/engine/test-rand-ontology.hpp" #include "lib/hash-combine.hpp" +#include "lib/iter-zip.hpp" -//#include +#include +using std::lround; +using lib::zip; namespace steam { @@ -67,7 +70,7 @@ namespace test { * which will be offset commonly by adding the \a flavour parameter. */ void - generateMultichan (uint chanCnt, TestFrame* buffArry, size_t frameNr, uint flavour) + generateMultichan (TestFrame* buffArry, uint chanCnt, size_t frameNr, uint flavour) { REQUIRE (buffArry); for (uint i=0; idata64().size(); ++i) - out->data64()[i] = calculate(param, in->data64()[i]); + for (auto& [res,src] : zip (out->data64(), in->data64())) + res = calculate(param, src); out->markChecksum(); } @@ -101,13 +104,15 @@ namespace test { * each result byte is the linear interpolation between the corresponding inputs. */ void - combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, int mix) + combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, double mix) { REQUIRE (srcA); REQUIRE (srcB); REQUIRE (out); - for (size_t i=0; i < srcA->data().size(); ++i) - out->data()[i] = char((1-mix) * srcA->data()[i] + mix * srcB->data()[i]); + for (auto& [res,inA,inB] : zip (out->data() + ,srcA->data() + ,srcB->data())) + res = lround((1-mix)*inA + mix*inB); out->markChecksum(); } diff --git a/tests/core/steam/engine/test-rand-ontology.hpp b/tests/core/steam/engine/test-rand-ontology.hpp index 76b21fe84..827caca6b 100644 --- a/tests/core/steam/engine/test-rand-ontology.hpp +++ b/tests/core/steam/engine/test-rand-ontology.hpp @@ -35,16 +35,16 @@ namespace test { using std::string; /** produce sequences of frames with (reproducible) random data */ - void generateFrame (TestFrame* buff, size_t frameNr, uint flavour); + void generateFrame (TestFrame* buff, size_t frameNr =0, uint flavour =0); /** produce planar multi channel output of random data frames */ - void generateMultichan (uint chanCnt, TestFrame* buffArry, size_t frameNr, uint flavour); + void generateMultichan (TestFrame* buffArry, uint chanCnt, size_t frameNr =0, uint flavour =0); /** »process« random frame date by hash-chaining with a parameter */ void manipulateFrame (TestFrame* out, TestFrame const* in, uint64_t param); /** mix two random data frames by a parameter-controlled proportion */ - void combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, int mix); + void combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, double mix); diff --git a/tests/core/steam/engine/testframe.cpp b/tests/core/steam/engine/testframe.cpp index 64e76d194..d0a805306 100644 --- a/tests/core/steam/engine/testframe.cpp +++ b/tests/core/steam/engine/testframe.cpp @@ -314,8 +314,7 @@ namespace test { bool TestFrame::contentEquals (TestFrame const& o) const { - return header_ == o.header_ - and data() == o.data(); + return data() == o.data(); } @@ -331,8 +330,8 @@ namespace test { TestFrame::buildData() { auto gen = buildDataGenFrom (accessHeader().distinction); - for (char& dat : data()) - dat = char(gen.i(CHAR_MAX)); + for (uint64_t& dat : data64()) + dat = gen.u64(); markChecksum(); } @@ -343,8 +342,8 @@ namespace test { TestFrame::matchDistinction() const { auto gen = buildDataGenFrom (accessHeader().distinction); - for (char const& dat : data()) - if (dat != char(gen.i(CHAR_MAX))) + for (uint64_t const& dat : data64()) + if (dat != gen.u64()) return false; return true; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index bda391fd9..c53e9131a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -52490,6 +52490,9 @@ + + + @@ -52531,6 +52534,22 @@ + + + + + + + + + + + + + + + + @@ -52545,9 +52564,10 @@ - + - + + @@ -52559,7 +52579,7 @@ - + @@ -52894,7 +52914,7 @@ - + @@ -53092,7 +53112,7 @@ - + @@ -53259,7 +53279,7 @@ - + @@ -53274,7 +53294,7 @@ - + @@ -53288,6 +53308,7 @@ + @@ -54845,8 +54866,7 @@ in value-type-binding.hpp

- - + @@ -93379,6 +93399,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

+ + @@ -93627,12 +93649,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - - - - + + + + @@ -93641,7 +93663,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- +