generator: tweak generate_random_data logic
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fb02ef9a23
commit
d907c9db6e
|
@ -186,13 +186,18 @@ auto Generator::generate_blocks(unsigned int k_blocks) -> std::string {
|
|||
|
||||
auto Generator::generate_random_data(uint n) -> std::string {
|
||||
// fmt::print("n -> {}\n", n); // debugging
|
||||
if (n < 0){
|
||||
/* this should not be possible */
|
||||
fmt::print("[*] error: n cannot be < 0\n");
|
||||
throw std::invalid_argument("n cannot be < 0");
|
||||
} else if (n > pow(2,20)){
|
||||
fmt::print("[*] error: n cannot be > 2^20\n");
|
||||
throw std::invalid_argument("n cannot be > 2^20");
|
||||
if (n == 0) {
|
||||
// do not do this..?
|
||||
const std::string msg{"zero bytes requested, bailing\n"};
|
||||
fmt::print("[*] error: {}", msg);
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
// pre-computed 2^20
|
||||
if (n > 1048576) {
|
||||
const std::string msg{"n cannot be > 2^20\n"};
|
||||
fmt::print("[*] error: {}", msg);
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
std::string r;
|
||||
|
|
Reference in New Issue