MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / Int32FromGTestEnv

Function Int32FromGTestEnv

rtpose_wrapper/src/gtest/gtest-all.cpp:8518–8536  ·  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

8516// variable corresponding to the given flag; if it isn't set or
8517// doesn't represent a valid 32-bit integer, returns default_value.
8518Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
8519 const String env_var = FlagToEnvVar(flag);
8520 const char* const string_value = posix::GetEnv(env_var.c_str());
8521 if (string_value == NULL) {
8522 // The environment variable is not set.
8523 return default_value;
8524 }
8525
8526 Int32 result = default_value;
8527 if (!ParseInt32(Message() << "Environment variable " << env_var,
8528 string_value, &result)) {
8529 printf("The default value %s is used.\n",
8530 (Message() << default_value).GetString().c_str());
8531 fflush(stdout);
8532 return default_value;
8533 }
8534
8535 return result;
8536}
8537
8538// Reads and returns the string environment variable corresponding to
8539// the given flag; if it's not set, returns default_value.

Callers 1

gtest-all.cppFile · 0.85

Calls 4

FlagToEnvVarFunction · 0.85
GetEnvFunction · 0.85
ParseInt32Function · 0.85
MessageFunction · 0.70

Tested by

no test coverage detected