MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / GetRandomSeedFromFlag

Function GetRandomSeedFromFlag

tests/gtest/gtest-all.cc:522–533  ·  view source on GitHub ↗

Returns a random seed in range [1, kMaxRandomSeed] based on the given --gtest_random_seed flag value.

Source from the content-addressed store, hash-verified

520// Returns a random seed in range [1, kMaxRandomSeed] based on the
521// given --gtest_random_seed flag value.
522inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
523 const unsigned int raw_seed = (random_seed_flag == 0) ?
524 static_cast<unsigned int>(GetTimeInMillis()) :
525 static_cast<unsigned int>(random_seed_flag);
526
527 // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
528 // it's easy to type.
529 const int normalized_seed =
530 static_cast<int>((raw_seed - 1U) %
531 static_cast<unsigned int>(kMaxRandomSeed)) + 1;
532 return normalized_seed;
533}
534
535// Returns the first valid random seed after 'seed'. The behavior is
536// undefined if 'seed' is invalid. The seed after kMaxRandomSeed is

Callers 1

RunAllTestsMethod · 0.85

Calls 1

GetTimeInMillisFunction · 0.85

Tested by

no test coverage detected