MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / GetRandomSeedFromFlag

Function GetRandomSeedFromFlag

test/common/gtest/gtest.cpp:542–553  ·  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

540// Returns a random seed in range [1, kMaxRandomSeed] based on the
541// given --gtest_random_seed flag value.
542inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
543 const unsigned int raw_seed = (random_seed_flag == 0) ?
544 static_cast<unsigned int>(GetTimeInMillis()) :
545 static_cast<unsigned int>(random_seed_flag);
546
547 // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
548 // it's easy to type.
549 const int normalized_seed =
550 static_cast<int>((raw_seed - 1U) %
551 static_cast<unsigned int>(kMaxRandomSeed)) + 1;
552 return normalized_seed;
553}
554
555// Returns the first valid random seed after 'seed'. The behavior is
556// 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