From 064484450eae11e3f160f07d7047e6c1e09d37aa Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 12 Nov 2024 22:35:54 +0100 Subject: [PATCH] Library: adapt some existing usages to the convenience API --- src/lib/random.hpp | 4 -- src/lib/test/run.hpp | 5 +++ tests/core/steam/engine/node-devel-test.cpp | 13 +++---- tests/core/steam/engine/node-linkage-test.cpp | 2 + tests/library/stat/statistic-test.cpp | 2 +- wiki/thinkPad.ichthyo.mm | 37 ++++++++++--------- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/lib/random.hpp b/src/lib/random.hpp index bbad87741..32998df69 100644 --- a/src/lib/random.hpp +++ b/src/lib/random.hpp @@ -160,10 +160,6 @@ namespace lib { return dist (defaultGen.generator_); } - /// @deprecated - inline uint64_t ranu() { return defaultGen.u64(); } - inline double runi() { return defaultGen.uni(); } - /** inject true randomness into the #defaultGen */ void randomiseRandomness(); diff --git a/src/lib/test/run.hpp b/src/lib/test/run.hpp index 123362ca7..c716cceb8 100644 --- a/src/lib/test/run.hpp +++ b/src/lib/test/run.hpp @@ -113,6 +113,11 @@ namespace test { using ::test::Arg; using ::test::Test; using ::test::Launch; +using lib::rani; +using lib::ranHash; +using lib::ranRange; +using lib::ranNormal; +using lib::defaultGen; // and provide shortcut for registration #define LAUNCHER(_TEST_CLASS_, _GROUPS_) \ diff --git a/tests/core/steam/engine/node-devel-test.cpp b/tests/core/steam/engine/node-devel-test.cpp index 04ec403d2..9d78b0efb 100644 --- a/tests/core/steam/engine/node-devel-test.cpp +++ b/tests/core/steam/engine/node-devel-test.cpp @@ -39,7 +39,6 @@ namespace steam { namespace engine{ namespace test { - using lib::ranu; namespace { /** uninitialised local storage that can be passed @@ -66,7 +65,7 @@ namespace test { virtual void run (Arg) { - lib::randomiseRandomness(); // inject entropy sees + seedRand(); processing_generateFrame(); processing_generateMultichan(); @@ -78,8 +77,8 @@ namespace test { void processing_generateFrame() { - size_t frameNr = ranu(); - uint flavour = uint(ranu()); + size_t frameNr = defaultGen.u64(); + uint flavour = defaultGen.u64(); Buffer buff; CHECK (not buff->isSane()); @@ -95,10 +94,10 @@ namespace test { void processing_generateMultichan() { - size_t frameNr = ranu(); - uint flavour = uint(ranu()); + size_t frameNr = defaultGen.u64(); + uint flavour = defaultGen.u64(); - uint channels = uint(1 + ranu() % 50); + uint channels = 1 + rani(50); CHECK (1 <= channels and channels <= 50); Buffer buffs[50]; diff --git a/tests/core/steam/engine/node-linkage-test.cpp b/tests/core/steam/engine/node-linkage-test.cpp index 029e7d941..bceb408b4 100644 --- a/tests/core/steam/engine/node-linkage-test.cpp +++ b/tests/core/steam/engine/node-linkage-test.cpp @@ -58,6 +58,8 @@ namespace test { virtual void run (Arg) { + seedRand(); + build_connected_nodes(); generate_turnout_system(); trigger_node_port_invocation(); diff --git a/tests/library/stat/statistic-test.cpp b/tests/library/stat/statistic-test.cpp index f332e61a7..96371399f 100644 --- a/tests/library/stat/statistic-test.cpp +++ b/tests/library/stat/statistic-test.cpp @@ -165,7 +165,7 @@ namespace test{ void check_TimeSeriesLinearRegression() { - auto dirt = [] { return runi() - 0.5; }; + auto dirt = [] { return ranRange(-0.5,+0.5); }; auto fun = [&](uint i){ auto x = double(i)/NUM_POINTS; return x*x; }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6f8e5cdf8..772f9394c 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57246,7 +57246,7 @@ - + @@ -57278,13 +57278,13 @@ - + - + @@ -57348,7 +57348,7 @@ - + @@ -57363,8 +57363,8 @@ - - + + @@ -57414,11 +57414,14 @@ + + - + + - + @@ -57454,7 +57457,7 @@ - + @@ -57467,8 +57470,7 @@ an einigen wenigen Stellen wird eigens dafür gesorgt, daß die grenz inclusiv ist

- - +
@@ -57485,8 +57487,7 @@ rani(max)

- - +
@@ -57509,13 +57510,13 @@
- - - + + + - - + +