Expand description
Generate random data in such a way as to make rare edge-cases very likely.
Disclaimer: the random number generators used in this crate are NOT CRYPTOGRAPHICALLY SECURE. Only use these generators for generating testing inputs, do not rely on them for cryptographic purposes in production code! For instance, you may test a cryptographic tool with these generators, but you may not deploy code that relies on these generators for security in production.
For instance, if generating a random f32
by uniformly sampling 32 bits of
data, certain values will rarely appear, such as NAN
and INFINITY
. When
doing randomized testing, like fuzzing, it isn’t very useful to repeatedly
generate well-behaved data. It is much more useful if we can artificially
increase the likelihood of these special values, so that we test with them
more often.
Additionally, some random number crates will never generate certain
problematic bit-patterns, such as NAN
.
This crate is based on the fastrand crate.
This crate can work with no_std
, if you disable the std
feature. You
cannot use the global functions when in a no_std
environment. In that
case, you can explicitly instantiate Wdg and call the methods on it.
They are equivalent.
If using std
, it’s more ergonomic to use the global functions in the
[global_functions] module.
Structs§
- Wdg
- A weird data generator
Functions§
- f32
- Generate a random f32, such that special or problematic values are much more common than normal.
- f64
- Generate a random f64, such that special or problematic values are much more common than normal.
- get_
seed - Gives back the current seed that is being held by the thread-local generator.
- i8
- Generate a random i8 , such that special or problematic values are much more common than normal.
- i16
- Generate a random i16 , such that special or problematic values are much more common than normal.
- i32
- Generate a random i32 , such that special or problematic values are much more common than normal.
- i64
- Generate a random i64 , such that special or problematic values are much more common than normal.
- i128
- Generate a random i128 , such that special or problematic values are much more common than normal.
- isize
- Generate a random isize , such that special or problematic values are much more common than normal.
- nan_f32
- There are multiple bit patterns that are equivalent to a
NAN
. This generator covers all possibleNAN
values as specified in IEEE-754, even ones that Rust would normally not generate. - nan_f64
- Generates a random f64
NAN
value. - normal_
f32 - Generate a random f32 normal value
- normal_
f64 - Generate a random f64 normal value
- seed
- Initialize the thread-local generator with the given seed.
- special_
f32 - Generate a random f32 “special” value
- special_
f64 - Generate a random f64 “special” value
- special_
i8 - Generate a random i8 “special” value
- special_
i16 - Generate a random i16 “special” value
- special_
i32 - Generate a random i32 “special” value
- special_
i64 - Generate a random i64 “special” value
- special_
i128 - Generate a random i128 “special” value
- special_
isize - Generate a random isize “special” value
- special_
u8 - Generate a random u8 “special” value
- special_
u16 - Generate a random u16 “special” value
- special_
u32 - Generate a random u32 “special” value
- special_
u64 - Generate a random u64 “special” value
- special_
u128 - Generate a random u128 “special” value
- special_
usize - Generate a random usize “special” value
- subnormal_
f32 - Generates a random f32 denormal value.
- subnormal_
f64 - Generates a random f64 denormal value.
- u8
- Generate a random u8 , such that special or problematic values are much more common than normal.
- u16
- Generate a random u16 , such that special or problematic values are much more common than normal.
- u32
- Generate a random u32 , such that special or problematic values are much more common than normal.
- u64
- Generate a random u64 , such that special or problematic values are much more common than normal.
- u128
- Generate a random u128 , such that special or problematic values are much more common than normal.
- usize
- Generate a random usize , such that special or problematic values are much more common than normal.