move calls to cstdlib::getenv to env::getEnv
Wrapped the cstdlib::getenv() call into env::getEnv
so that it can be tested by mocking the env namespace,
by just dropping in test_env.cpp which implements those
methods and tying them a singleton upon which we can set
expectations.
Note: regardless of the approach taken to mock this, wrapping
this method is a good fix.
Change-Id: I65d22da08fc3dd76e6860f728c54e6c847ed07de
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 99c8020..37c2316 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -287,8 +287,8 @@
{
// Get list of return codes for removing sensors on device
std::string deviceRmRCs;
- auto devRmRCs = getenv("REMOVERCS");
- if (devRmRCs)
+ auto devRmRCs = env::getEnv("REMOVERCS");
+ if (!devRmRCs.empty())
{
deviceRmRCs.assign(devRmRCs);
}
@@ -534,10 +534,10 @@
}
{
- auto interval = getenv("INTERVAL");
- if (interval)
+ auto interval = env::getEnv("INTERVAL");
+ if (!interval.empty())
{
- _interval = strtoull(interval, NULL, 10);
+ _interval = strtoull(interval.c_str(), NULL, 10);
}
}
}