A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::tests::EnvVarTestCase Class Reference

EnvironmentVariable tests. More...

+ Inheritance diagram for ns3::tests::EnvVarTestCase:
+ Collaboration diagram for ns3::tests::EnvVarTestCase:

Public Member Functions

 EnvVarTestCase ()
 Constructor.
 
 ~EnvVarTestCase () override
 Destructor.
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
virtual ~TestCase ()
 Destructor.
 
std::string GetName () const
 
TestCaseoperator= (const TestCase &)=delete
 

Private Types

using KeyFoundType = EnvironmentVariable::KeyFoundType
 The return type from EnvironmentVariable::Get()
 
using KeyValueStore = EnvironmentVariable::Dictionary::KeyValueStore
 The key,value store.
 

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.
 
void CheckGet (const std::string &where, const std::string &key, KeyFoundType expect)
 Check the result from a Get.
 
void DoRun () override
 Run the tests.
 
void SetAndCheck (const std::string &where, const std::string &envValue, KeyValueStore expect)
 Set and Check the variable.
 
void SetCheckAndGet (const std::string &where, const std::string &envValue, KeyValueStore expectDict, const std::string &key, KeyFoundType expectValue)
 Set, Check, and Get a variable.
 
void SetVariable (const std::string &where, const std::string &value)
 Set the test environment variable.
 
void UnsetVariable (const std::string &where)
 Unset the test environment variable.
 

Private Attributes

const std::string m_delimiter {"|"}
 Always use a non-default delimiter.
 
const std::string m_variable {"NS_ENVVAR_TEST"}
 Test environment variable name.
 

Additional Inherited Members

- Public Types inherited from ns3::TestCase
enum class  Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 
- Static Public Attributes inherited from ns3::TestCase
static constexpr auto QUICK = Duration::QUICK
 Deprecated test duration simple enums.
 
static constexpr auto EXTENSIVE = Duration::EXTENSIVE
 
static constexpr auto TAKES_FOREVER = Duration::TAKES_FOREVER
 
- Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor.
 
void AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK)
 Add an individual child TestCase to this test suite.
 
TestCaseGetParent () const
 Get the parent of this TestCase.
 
bool IsStatusFailure () const
 Check if any tests failed.
 
bool IsStatusSuccess () const
 Check if all tests passed.
 
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found.
 
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.
 
bool MustAssertOnFailure () const
 Check if this run should assert on failure.
 
bool MustContinueOnFailure () const
 Check if this run should continue on failure.
 
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory.
 
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory.
 

Detailed Description

EnvironmentVariable tests.

Definition at line 36 of file environment-variable-test-suite.cc.

Member Typedef Documentation

◆ KeyFoundType

◆ KeyValueStore

Constructor & Destructor Documentation

◆ EnvVarTestCase()

ns3::tests::EnvVarTestCase::EnvVarTestCase ( )

Constructor.

Definition at line 115 of file environment-variable-test-suite.cc.

◆ ~EnvVarTestCase()

ns3::tests::EnvVarTestCase::~EnvVarTestCase ( )
override

Destructor.

Definition at line 120 of file environment-variable-test-suite.cc.

References UnsetVariable().

+ Here is the call graph for this function:

Member Function Documentation

◆ Check()

void ns3::tests::EnvVarTestCase::Check ( const std::string & where,
const std::string & envValue,
KeyValueStore expect )
private

Read envValue and check that it contains only the key,value pairs from expect.

Parameters
whereThe test condition being checked.
envValueThe environment variable to parse and check.
expectThe set of key,values expected.

Definition at line 147 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckGet()

void ns3::tests::EnvVarTestCase::CheckGet ( const std::string & where,
const std::string & key,
KeyFoundType expect )
private

Check the result from a Get.

Parameters
whereThe test condition being checked.
keyThe key to check.
expectThe expected result.

Definition at line 212 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoRun()

void ns3::tests::EnvVarTestCase::DoRun ( )
overrideprivatevirtual

Run the tests.

Implements ns3::TestCase.

Definition at line 236 of file environment-variable-test-suite.cc.

References Check(), CheckGet(), ns3::EnvironmentVariable::Get(), m_variable, NS_TEST_EXPECT_MSG_EQ, SetCheckAndGet(), and UnsetVariable().

+ Here is the call graph for this function:

◆ SetAndCheck()

void ns3::tests::EnvVarTestCase::SetAndCheck ( const std::string & where,
const std::string & envValue,
KeyValueStore expect )
private

Set and Check the variable.

Parameters
whereThe test condition being checked.
envValueThe environment variable to parse and check.
expectThe set of key,values expected.

Definition at line 203 of file environment-variable-test-suite.cc.

References Check(), and SetVariable().

Referenced by SetCheckAndGet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetCheckAndGet()

void ns3::tests::EnvVarTestCase::SetCheckAndGet ( const std::string & where,
const std::string & envValue,
KeyValueStore expectDict,
const std::string & key,
KeyFoundType expectValue )
private

Set, Check, and Get a variable.

Parameters
whereThe test condition being checked.
envValueThe environment variable to parse and check.
expectDictThe set of key,values expected.
keyThe key to check.
expectValueThe expected result.

Definition at line 225 of file environment-variable-test-suite.cc.

References CheckGet(), and SetAndCheck().

Referenced by DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetVariable()

void ns3::tests::EnvVarTestCase::SetVariable ( const std::string & where,
const std::string & value )
private

Set the test environment variable.

Parameters
whereThe test condition being checked.
valueThe value to set.

Definition at line 126 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnsetVariable()

void ns3::tests::EnvVarTestCase::UnsetVariable ( const std::string & where)
private

Unset the test environment variable.

Parameters
whereThe test condition being checked.

Definition at line 139 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_delimiter

const std::string ns3::tests::EnvVarTestCase::m_delimiter {"|"}
private

Always use a non-default delimiter.

Definition at line 108 of file environment-variable-test-suite.cc.

Referenced by Check(), and CheckGet().

◆ m_variable

const std::string ns3::tests::EnvVarTestCase::m_variable {"NS_ENVVAR_TEST"}
private

Test environment variable name.

Definition at line 111 of file environment-variable-test-suite.cc.

Referenced by Check(), CheckGet(), DoRun(), and SetVariable().


The documentation for this class was generated from the following file: