You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
978 B
44 lines
978 B
#include <rng.h>
|
|
#include <rng/crand.h>
|
|
|
|
#include <cstdio>
|
|
|
|
using namespace rng;
|
|
|
|
void r(Random& r)
|
|
{
|
|
u8 bytes[32];
|
|
r.next_bytes(bytes);
|
|
u32 n = r.next<u32>();
|
|
f64 f = r.next<f64>();
|
|
f = r.next_f64();
|
|
std::array<char, 10> nn = r.next<std::array<char, 10>>();
|
|
}
|
|
|
|
void rng_test()
|
|
{
|
|
crand _r(123);
|
|
Random& r = _r;
|
|
printf("%lu %lu %lu\n", r.next_u64(), r.next_u64(), r.next_u64());
|
|
printf("%d %d %d\n", r.next_i32(), r.next_i32(), r.next_i32());
|
|
printf("%u %u %u\n", r.next_u32(), r.next_u32(), r.next_u32());
|
|
|
|
union {
|
|
volatile u64 u;
|
|
u8 b[sizeof(u64)];
|
|
std::array<u8, sizeof(u64)> a;
|
|
} thing = {0};
|
|
|
|
r.next_bytes(thing.b, sizeof(u64));
|
|
printf("chaos: %lu, %lu, %lu\n", thing.u, (r.next_bytes(thing.a), thing.u), (r.next_bytes(thing.b), thing.u));
|
|
|
|
// TODO: these aren't implemented yet in the base Random huh...
|
|
printf("---\n%u %d %d %u\n", r.next_u32(10, 20), r.next_i32(10, 20), r.next_i32(10), r.next_u32(10));
|
|
}
|
|
int main()
|
|
{
|
|
rng_test();
|
|
|
|
return 0;
|
|
}
|