MCPcopy Create free account
hub / github.com/apache/singa / GetRandomSeedFromFlag

Function GetRandomSeedFromFlag

test/gtest/gtest-all.cc:536–547  ·  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

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