stc
Loading...
Searching...
No Matches
TestEnvVariable.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "stc/Environment.hpp"
4
5namespace stc::testutil {
6
11 std::string name;
12
13 [[nodiscard("Discarding this object will immediately delete the environment variable")]]
15 const std::string& name,
16 const std::string& initValue = ""
17 ) : name(name) {
18 if (!initValue.empty()) {
20 name.c_str(), initValue.c_str()
21 );
22 }
23 }
24
26 if (!name.empty()) {
27 stc::setEnv(name.c_str(), nullptr);
28 }
29 }
30};
31
32}
Definition CaptureStream.hpp:6
void setEnv(const char *name, const char *value, bool replace=true)
Definition Environment.hpp:44
Definition TestEnvVariable.hpp:10
std::string name
Definition TestEnvVariable.hpp:11
TestEnvVariable(const std::string &name, const std::string &initValue="")
Definition TestEnvVariable.hpp:14
~TestEnvVariable()
Definition TestEnvVariable.hpp:25