diff options
Diffstat (limited to 'test/acm_random.h')
-rw-r--r-- | test/acm_random.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/acm_random.h b/test/acm_random.h index 514894eda..84c6c7529 100644 --- a/test/acm_random.h +++ b/test/acm_random.h @@ -35,6 +35,13 @@ class ACMRandom { return (rand() >> 8) & 0xff; } + uint8_t Rand8Extremes(void) { + // Returns a random value near 0 or near 255, to better exercise + // saturation behavior. + const uint8_t r = Rand8(); + return r < 128 ? r << 4 : r >> 4; + } + int PseudoUniform(int range) { return (rand() >> 8) % range; } |