EnvironmentVariable tests. More...
Public Member Functions | |
EnvVarTestCase () | |
Constructor. More... | |
~EnvVarTestCase () override | |
Destructor. More... | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. More... | |
std::string | GetName () const |
TestCase & | operator= (const TestCase &)=delete |
Private Types | |
using | KeyFoundType = EnvironmentVariable::KeyFoundType |
The return type from EnvironmentVariable::Get() More... | |
using | KeyValueStore = EnvironmentVariable::Dictionary::KeyValueStore |
The key,value store. More... | |
Private Member Functions | |
void | Check (const std::string &where, const std::string &envValue, KeyValueStore expect) |
Read envValue and check that it contains only the key,value pairs from expect . More... | |
void | CheckGet (const std::string &where, const std::string &key, KeyFoundType expect) |
Check the result from a Get. More... | |
void | DoRun () override |
Run the tests. More... | |
void | SetAndCheck (const std::string &where, const std::string &envValue, KeyValueStore expect) |
Set and Check the variable. More... | |
void | SetCheckAndGet (const std::string &where, const std::string &envValue, KeyValueStore expectDict, const std::string &key, KeyFoundType expectValue) |
Set, Check, and Get a variable. More... | |
void | SetVariable (const std::string &where, const std::string &value) |
Set the test environment variable. More... | |
void | UnsetVariable (const std::string &where) |
Unset the test environment variable. More... | |
Private Attributes | |
const std::string | m_delimiter {"|"} |
Always use a non-default delimiter. More... | |
const std::string | m_variable {"NS_ENVVAR_TEST"} |
Test environment variable name. More... | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
enum | TestDuration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. More... | |
void | AddTestCase (TestCase *testCase, TestDuration duration=QUICK) |
Add an individual child TestCase to this test suite. More... | |
TestCase * | GetParent () const |
Get the parent of this TestCase. More... | |
bool | IsStatusFailure () const |
Check if any tests failed. More... | |
bool | IsStatusSuccess () const |
Check if all tests passed. More... | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. More... | |
void | ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line) |
Log the failure of this TestCase. More... | |
bool | MustAssertOnFailure () const |
Check if this run should assert on failure. More... | |
bool | MustContinueOnFailure () const |
Check if this run should continue on failure. More... | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. More... | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. More... | |
EnvironmentVariable tests.
Definition at line 47 of file environment-variable-test-suite.cc.
The return type from EnvironmentVariable::Get()
Definition at line 64 of file environment-variable-test-suite.cc.
|
private |
The key,value store.
Definition at line 61 of file environment-variable-test-suite.cc.
ns3::tests::EnvVarTestCase::EnvVarTestCase | ( | ) |
Constructor.
Definition at line 126 of file environment-variable-test-suite.cc.
|
override |
Destructor.
Definition at line 131 of file environment-variable-test-suite.cc.
References UnsetVariable().
|
private |
Read envValue
and check that it contains only the key,value pairs from expect
.
where | The test condition being checked. |
envValue | The environment variable to parse and check. |
expect | The set of key,values expected. |
Definition at line 158 of file environment-variable-test-suite.cc.
References ns3::EnvironmentVariable::GetDictionary(), m_delimiter, m_variable, and NS_TEST_EXPECT_MSG_EQ.
Referenced by DoRun(), and SetAndCheck().
|
private |
Check the result from a Get.
where | The test condition being checked. |
key | The key to check. |
expect | The expected result. |
Definition at line 223 of file environment-variable-test-suite.cc.
References ns3::EnvironmentVariable::Get(), m_delimiter, m_variable, and NS_TEST_EXPECT_MSG_EQ.
Referenced by DoRun(), and SetCheckAndGet().
|
overrideprivatevirtual |
Run the tests.
Implements ns3::TestCase.
Definition at line 247 of file environment-variable-test-suite.cc.
References Check(), CheckGet(), ns3::EnvironmentVariable::Get(), m_variable, NS_TEST_EXPECT_MSG_EQ, SetCheckAndGet(), and UnsetVariable().
|
private |
Set and Check the variable.
where | The test condition being checked. |
envValue | The environment variable to parse and check. |
expect | The set of key,values expected. |
Definition at line 214 of file environment-variable-test-suite.cc.
References Check(), and SetVariable().
Referenced by SetCheckAndGet().
|
private |
Set, Check, and Get a variable.
where | The test condition being checked. |
envValue | The environment variable to parse and check. |
expectDict | The set of key,values expected. |
key | The key to check. |
expectValue | The expected result. |
Definition at line 236 of file environment-variable-test-suite.cc.
References CheckGet(), and SetAndCheck().
Referenced by DoRun().
|
private |
Set the test environment variable.
where | The test condition being checked. |
value | The value to set. |
Definition at line 137 of file environment-variable-test-suite.cc.
References ns3::EnvironmentVariable::Clear(), m_variable, NS_TEST_EXPECT_MSG_EQ, NS_TEST_EXPECT_MSG_NE, and ns3::EnvironmentVariable::Set().
Referenced by SetAndCheck().
|
private |
Unset the test environment variable.
where | The test condition being checked. |
Definition at line 150 of file environment-variable-test-suite.cc.
References ns3::EnvironmentVariable::Clear(), NS_TEST_EXPECT_MSG_EQ, and ns3::EnvironmentVariable::Unset().
Referenced by ~EnvVarTestCase(), and DoRun().
|
private |
Always use a non-default delimiter.
Definition at line 119 of file environment-variable-test-suite.cc.
Referenced by Check(), and CheckGet().
|
private |
Test environment variable name.
Definition at line 122 of file environment-variable-test-suite.cc.
Referenced by Check(), CheckGet(), DoRun(), and SetVariable().