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

Function Int32FromGTestEnv

tests/gtest/gtest-all.cc:11052–11074  ·  view source on GitHub ↗

Reads and returns a 32-bit integer stored in the environment variable corresponding to the given flag; if it isn't set or doesn't represent a valid 32-bit integer, returns default_value.

Source from the content-addressed store, hash-verified

11050// variable corresponding to the given flag; if it isn't set or
11051// doesn't represent a valid 32-bit integer, returns default_value.
11052Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
11053#if defined(GTEST_GET_INT32_FROM_ENV_)
11054 return GTEST_GET_INT32_FROM_ENV_(flag, default_value);
11055#else
11056 const std::string env_var = FlagToEnvVar(flag);
11057 const char* const string_value = posix::GetEnv(env_var.c_str());
11058 if (string_value == nullptr) {
11059 // The environment variable is not set.
11060 return default_value;
11061 }
11062
11063 Int32 result = default_value;
11064 if (!ParseInt32(Message() << "Environment variable " << env_var,
11065 string_value, &result)) {
11066 printf("The default value %s is used.\n",
11067 (Message() << default_value).GetString().c_str());
11068 fflush(stdout);
11069 return default_value;
11070 }
11071
11072 return result;
11073#endif // defined(GTEST_GET_INT32_FROM_ENV_)
11074}
11075
11076// As a special case for the 'output' flag, if GTEST_OUTPUT is not
11077// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build

Callers 1

gtest-all.ccFile · 0.85

Calls 5

FlagToEnvVarFunction · 0.85
GetEnvFunction · 0.85
ParseInt32Function · 0.85
GetStringMethod · 0.80
MessageFunction · 0.70

Tested by

no test coverage detected