| 544 | } |
| 545 | |
| 546 | Value TestParser::evaluateRandom(const std::string& funcCall) { |
| 547 | // Extract parameter from random(param) |
| 548 | std::string param = funcCall.substr(7, funcCall.length() - 8); // Remove "random(" and ")" |
| 549 | |
| 550 | if (param.empty()) { |
| 551 | // random() without parameter - return random integer 0-2^32 |
| 552 | return Value(randomEngine.nextRandomInteger()); |
| 553 | } |
| 554 | // random(max) - return random integer between 0 and max-1 |
| 555 | int32_t maxVal = 0; |
| 556 | try { |
| 557 | maxVal = static_cast<int32_t>(stoi(param)); |
| 558 | } catch (const std::exception&) { |
| 559 | throw TestException("Invalid random parameter [" + path + ":" + line + "]."); |
| 560 | } |
| 561 | if (maxVal == 0) { |
| 562 | throw TestException("Random max value must be positive [" + path + ":" + line + "]."); |
| 563 | } |
| 564 | return Value(randomEngine.nextRandomInteger(maxVal)); |
| 565 | } |
| 566 | |
| 567 | Value TestParser::evaluateRandomDotFunction(const std::string& funcCall) { |
| 568 | // Handle random.set_seed(value) and random.randInt32(max) |
nothing calls this directly
no test coverage detected