Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
310-Gen-VariablesInGenerators.cpp File Reference
#include <catch2/catch.hpp>
Include dependency graph for 310-Gen-VariablesInGenerators.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Generate random doubles across different ranges", "[generator][example][advanced]")
 

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Generate random doubles across different ranges" ,
"" [generator][example][advanced] )

Definition at line 11 of file 310-Gen-VariablesInGenerators.cpp.

12 {
13 // Workaround for old libstdc++
14 using record = std::tuple<double, double>;
15 // Set up 3 ranges to generate numbers from
16 auto r = GENERATE(table<double, double>({
17 record{3, 4},
18 record{-4, -3},
19 record{10, 1000}
20 }));
21
22 // This will not compile (intentionally), because it accesses a variable
23 // auto number = GENERATE(take(50, random(std::get<0>(r), std::get<1>(r))));
24
25 // GENERATE_COPY copies all variables mentioned inside the expression
26 // thus this will work.
27 auto number = GENERATE_COPY(take(50, random(std::get<0>(r), std::get<1>(r))));
28
29 REQUIRE(std::abs(number) > 0);
30}
const mie::Vuint & r
Definition bn.cpp:28
#define GENERATE_COPY(...)
#define GENERATE(...)
#define REQUIRE(...)
Definition catch.hpp:185
GeneratorWrapper< T > take(size_t target, GeneratorWrapper< T > &&generator)
uint16_t random
Definition yubico_otp.c:47