core: check-style for core/{examples,helper,test}
This commit is contained in:
@@ -70,7 +70,7 @@ int main (int argc, char *argv[])
|
||||
// Non-option arguments
|
||||
int nonOpt1 = 1;
|
||||
int nonOpt2 = 1;
|
||||
|
||||
|
||||
// Cache the initial values. Normally one wouldn't do this,
|
||||
// but we want to demonstrate that CommandLine has changed them.
|
||||
const int intDef = intArg;
|
||||
@@ -87,8 +87,8 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
const int nonOpt1Def = nonOpt1;
|
||||
const int nonOpt2Def = nonOpt2;
|
||||
|
||||
|
||||
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.Usage ("CommandLine example program.\n"
|
||||
"\n"
|
||||
@@ -106,14 +106,14 @@ int main (int argc, char *argv[])
|
||||
std::cout << std::endl;
|
||||
std::cout << cmd.GetName () << ":" << std::endl;
|
||||
std::cout << "Initial values:" << std::endl;
|
||||
|
||||
|
||||
std::cout << std::left << std::setw (10) << "intArg:"
|
||||
<< intDef
|
||||
<< std::endl;
|
||||
std::cout << std::setw (10) << "boolArg:"
|
||||
<< std::boolalpha << boolDef << std::noboolalpha
|
||||
<< std::endl;
|
||||
|
||||
|
||||
std::cout << std::setw (10) << "strArg:"
|
||||
<< "\"" << strDef << "\""
|
||||
<< std::endl;
|
||||
@@ -140,7 +140,7 @@ int main (int argc, char *argv[])
|
||||
std::cout << std::setw (10) << "boolArg:"
|
||||
<< std::boolalpha << boolArg << std::noboolalpha
|
||||
<< std::endl;
|
||||
|
||||
|
||||
std::cout << std::setw (10) << "strArg:"
|
||||
<< "\"" << strArg << "\""
|
||||
<< std::endl;
|
||||
@@ -149,7 +149,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
struct TypeId::AttributeInformation info;
|
||||
tid.LookupAttributeByName (attrName, &info);
|
||||
|
||||
|
||||
std::cout << std::setw (10) << "anti:"
|
||||
<< "\""
|
||||
<< info.initialValue->SerializeToString (info.checker)
|
||||
|
||||
@@ -102,32 +102,31 @@ Murmur3 (64-bit version) 312094 100 4191464 134.301
|
||||
\endverbatim
|
||||
*/
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Hasher");
|
||||
|
||||
namespace Hash
|
||||
{
|
||||
namespace Hash {
|
||||
|
||||
/**
|
||||
* \ingroup hash
|
||||
* Namespace for hasher-example.
|
||||
*/
|
||||
namespace Example
|
||||
{
|
||||
|
||||
namespace Example {
|
||||
|
||||
/**
|
||||
* Keep track of collisions
|
||||
*/
|
||||
class Collider {
|
||||
class Collider
|
||||
{
|
||||
|
||||
public:
|
||||
std::string m_name; /**< Name of this hash. */
|
||||
Hasher m_hash; /**< The hash. */
|
||||
|
||||
/** The size of hash function being tested. */
|
||||
enum Bits {
|
||||
enum Bits
|
||||
{
|
||||
Bits32, /**< Use 32-bit hash function. */
|
||||
Bits64 /**< Use 64-bit hash function. */
|
||||
};
|
||||
@@ -154,7 +153,7 @@ public:
|
||||
bool Add (const std::string phrase)
|
||||
{
|
||||
uint64_t h = GetHash (phrase);
|
||||
|
||||
|
||||
// Check for collisions
|
||||
if (m_dict.count (h) > 0)
|
||||
{
|
||||
@@ -168,14 +167,14 @@ public:
|
||||
// new phrase generating a real collision
|
||||
// alphabetize
|
||||
if ( m_dict[h] < phrase)
|
||||
{
|
||||
{
|
||||
m_coll.push_back (std::make_pair (h, phrase));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_coll.push_back (std::make_pair (h, m_dict[h]));
|
||||
m_dict[h] = phrase;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,9 +193,11 @@ public:
|
||||
|
||||
switch (m_bits)
|
||||
{
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
case Bits32: name += " (32-bit version)"; break;
|
||||
case Bits64: name += " (64-bit version)"; break;
|
||||
default: name += " (unknown!?!)";
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -205,7 +206,7 @@ public:
|
||||
void Report () const
|
||||
{
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
std::cout << GetName () << ": " << m_coll.size () << " collisions:"
|
||||
<< std::endl;
|
||||
for (collision_t::const_iterator it = m_coll.begin ();
|
||||
@@ -213,10 +214,10 @@ public:
|
||||
++it)
|
||||
{
|
||||
uint64_t h = it->first;
|
||||
|
||||
std::cout << std::setfill ('0') << std::hex << std::setw(8) << h
|
||||
<< std::dec << std::setfill(' ') << " "
|
||||
<< std::setw(20) << std::left
|
||||
|
||||
std::cout << std::setfill ('0') << std::hex << std::setw (8) << h
|
||||
<< std::dec << std::setfill (' ') << " "
|
||||
<< std::setw (20) << std::left
|
||||
<< m_dict.find (h)->second
|
||||
<< it->second
|
||||
<< std::right
|
||||
@@ -224,7 +225,6 @@ public:
|
||||
}
|
||||
} // Report ()
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -234,24 +234,24 @@ private:
|
||||
* \return The hash value, using the number of bits set in the constructor.
|
||||
*/
|
||||
uint64_t GetHash (const std::string phrase)
|
||||
{
|
||||
m_hash.clear ();
|
||||
uint64_t h = 0;
|
||||
{
|
||||
m_hash.clear ();
|
||||
uint64_t h = 0;
|
||||
|
||||
if (m_bits == Bits32)
|
||||
{
|
||||
h = m_hash.GetHash32 (phrase);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = m_hash.GetHash64 (phrase);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
if (m_bits == Bits32)
|
||||
{
|
||||
h = m_hash.GetHash32 (phrase);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = m_hash.GetHash64 (phrase);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/** Hash function. */
|
||||
enum Bits m_bits;
|
||||
|
||||
|
||||
/** Hashed dictionary of first instance of each hash. */
|
||||
typedef std::map <uint64_t, std::string> hashdict_t;
|
||||
|
||||
@@ -262,15 +262,16 @@ private:
|
||||
typedef std::vector < std::pair<uint64_t, std::string> > collision_t;
|
||||
|
||||
/** The list of collisions. */
|
||||
collision_t m_coll;
|
||||
collision_t m_coll;
|
||||
|
||||
}; // class Collider
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Word list and hashers to test.
|
||||
*/
|
||||
class Dictionary {
|
||||
class Dictionary
|
||||
{
|
||||
public:
|
||||
/** Constructor. */
|
||||
Dictionary ()
|
||||
@@ -298,22 +299,22 @@ public:
|
||||
{
|
||||
if (phrase.size () == 0)
|
||||
{
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
int newPhrases = 0;
|
||||
for (std::vector <Collider>::iterator it = m_hashes.begin ();
|
||||
it != m_hashes.end ();
|
||||
++it)
|
||||
{
|
||||
newPhrases += it->Add (phrase);
|
||||
}
|
||||
it != m_hashes.end ();
|
||||
++it)
|
||||
{
|
||||
newPhrases += it->Add (phrase);
|
||||
}
|
||||
|
||||
if (newPhrases)
|
||||
{
|
||||
++m_nphrases;
|
||||
m_words.push_back (phrase);
|
||||
}
|
||||
if (newPhrases)
|
||||
{
|
||||
++m_nphrases;
|
||||
m_words.push_back (phrase);
|
||||
}
|
||||
} // Add ()
|
||||
|
||||
/**
|
||||
@@ -325,10 +326,10 @@ public:
|
||||
* \f[
|
||||
* E(collisions) = n - k + k (1 - 1/k)^n
|
||||
* \f]
|
||||
*
|
||||
*
|
||||
* where <i>n</i> is the number of entries in the table, and
|
||||
* <i>k</i> is the number of buckets.
|
||||
*
|
||||
*
|
||||
* This form is numerically unstable for low collision rates.
|
||||
* Expanding for large \f$ k \f$ we get
|
||||
*
|
||||
@@ -349,7 +350,7 @@ public:
|
||||
* \right]}
|
||||
* \right\}
|
||||
* \f}
|
||||
*
|
||||
*
|
||||
* For simplicity, we'll use the first two terms
|
||||
* of the second form.
|
||||
*/
|
||||
@@ -362,9 +363,9 @@ public:
|
||||
long double k64 = static_cast<long double> (0xFFFFFFFFFFFFFFFFULL);
|
||||
|
||||
long double n = m_nphrases;
|
||||
long double Ec32 = n * (n - 1) / ( 2 * k32) * (1 - (n - 2)/(3 * k32));
|
||||
long double Ec64 = n * (n - 1) / ( 2 * k64) * (1 - (n - 2)/(3 * k64));
|
||||
|
||||
long double Ec32 = n * (n - 1) / ( 2 * k32) * (1 - (n - 2) / (3 * k32));
|
||||
long double Ec64 = n * (n - 1) / ( 2 * k64) * (1 - (n - 2) / (3 * k64));
|
||||
|
||||
// Output collisions
|
||||
std::cout << "" << std::endl;
|
||||
std::cout << "Number of words or phrases: " << n << std::endl;
|
||||
@@ -373,13 +374,13 @@ public:
|
||||
std::cout << "Expected number of collisions: (64-bit table) " << Ec64
|
||||
<< std::endl;
|
||||
} // ReportExpectedCollisions
|
||||
|
||||
|
||||
|
||||
|
||||
/** Print the collisions for each Collider. */
|
||||
void Report () const
|
||||
{
|
||||
ReportExpectedCollisions ();
|
||||
|
||||
|
||||
for (std::vector <Collider>::const_iterator it = m_hashes.begin ();
|
||||
it != m_hashes.end ();
|
||||
++it)
|
||||
@@ -400,7 +401,7 @@ public:
|
||||
Hasher h = m_hashes[hindex].m_hash;
|
||||
int start = clock ();
|
||||
for (std::vector<std::string>::const_iterator w = m_words.begin ();
|
||||
w != m_words.end();
|
||||
w != m_words.end ();
|
||||
++w)
|
||||
{
|
||||
for (uint32_t i = 0; i < reps; ++i)
|
||||
@@ -411,7 +412,7 @@ public:
|
||||
int stop = clock ();
|
||||
double delta = stop - start;
|
||||
double per = 1e9 * delta / (m_nphrases * reps * CLOCKS_PER_SEC);
|
||||
|
||||
|
||||
std::cout << std::left
|
||||
<< std::setw (32) << m_hashes[hindex].GetName ()
|
||||
<< std::right
|
||||
@@ -420,7 +421,7 @@ public:
|
||||
<< std::setw (10) << stop - start
|
||||
<< std::setw (12) << per
|
||||
<< std::endl;
|
||||
|
||||
|
||||
} // TimeOne ()
|
||||
|
||||
/** Report the execution time of each hash across the entire Dictionary. */
|
||||
@@ -435,7 +436,7 @@ public:
|
||||
<< std::setw (10) << "Ticks"
|
||||
<< std::setw (12) << "ns/hash"
|
||||
<< std::endl;
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < m_hashes.size (); ++i)
|
||||
{
|
||||
TimeOne (i);
|
||||
@@ -457,7 +458,7 @@ class DictFiles
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* CommandLine callback function to add a file argument to the list.
|
||||
*
|
||||
@@ -470,7 +471,7 @@ public:
|
||||
{
|
||||
m_files.push_back (file);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -496,27 +497,27 @@ public:
|
||||
{
|
||||
std::string dictFile = *it;
|
||||
std::cout << "Dictionary file: " << dictFile << std::endl;
|
||||
|
||||
|
||||
// Find collisions
|
||||
|
||||
|
||||
// Open the file
|
||||
std::ifstream dictStream;
|
||||
dictStream.open (dictFile.c_str () );
|
||||
if (! dictStream.is_open () )
|
||||
if (!dictStream.is_open () )
|
||||
{
|
||||
std::cerr << "Failed to open dictionary file."
|
||||
<< "'" << dictFile << "'"
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
while (dictStream.good () )
|
||||
{
|
||||
std::string phrase;
|
||||
getline (dictStream, phrase);
|
||||
dict.Add (phrase);
|
||||
} // while
|
||||
|
||||
|
||||
dictStream.close ();
|
||||
|
||||
} // for m_files
|
||||
@@ -538,7 +539,7 @@ private:
|
||||
using namespace ns3;
|
||||
using namespace ns3::Hash::Example;
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
std::cout << std::endl;
|
||||
@@ -550,8 +551,8 @@ main (int argc, char *argv[])
|
||||
CommandLine cmd;
|
||||
cmd.Usage ("Find hash collisions in the dictionary.");
|
||||
cmd.AddValue ("dict", "Dictionary file to hash",
|
||||
MakeCallback(&DictFiles::Add,
|
||||
&files));
|
||||
MakeCallback (&DictFiles::Add,
|
||||
&files));
|
||||
cmd.AddValue ("time", "Run timing test", timing);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
@@ -569,11 +570,11 @@ main (int argc, char *argv[])
|
||||
dict.Add ( Collider ("Murmur3",
|
||||
Hasher ( Create<Hash::Function::Murmur3> () ),
|
||||
Collider::Bits64));
|
||||
|
||||
|
||||
files.ReadInto (dict);
|
||||
|
||||
|
||||
dict.Report ();
|
||||
|
||||
|
||||
if (timing)
|
||||
{
|
||||
dict.Time ();
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
using namespace ns3;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/**
|
||||
* Example Callback function.
|
||||
*
|
||||
@@ -50,7 +50,8 @@ CbOne (double a, double b)
|
||||
}
|
||||
|
||||
/** Example Callback class. */
|
||||
class MyCb {
|
||||
class MyCb
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Example Callback class method.
|
||||
@@ -58,7 +59,8 @@ public:
|
||||
* \param [in] a The argument.
|
||||
* \returns -5
|
||||
*/
|
||||
int CbTwo (double a) {
|
||||
int CbTwo (double a)
|
||||
{
|
||||
std::cout << "invoke cbTwo a=" << a << std::endl;
|
||||
return -5;
|
||||
}
|
||||
@@ -70,8 +72,8 @@ public:
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
// return type: double
|
||||
// first arg type: double
|
||||
// second arg type: double
|
||||
@@ -108,14 +110,14 @@ int main (int argc, char *argv[])
|
||||
NS_ASSERT (two.IsNull ());
|
||||
|
||||
#if 0
|
||||
// The below type mismatch between CbOne() and callback two will fail to
|
||||
// The below type mismatch between CbOne() and callback two will fail to
|
||||
// compile if enabled in this program.
|
||||
two = MakeCallback (&CbOne);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// This is a slightly different example, in which the code will compile
|
||||
// but because callbacks are type-safe, will cause a fatal error at runtime
|
||||
// but because callbacks are type-safe, will cause a fatal error at runtime
|
||||
// (the difference here is that Assign() is called instead of operator=)
|
||||
Callback<void, float> three;
|
||||
three.Assign (MakeCallback (&CbOne));
|
||||
|
||||
@@ -48,7 +48,7 @@ PtrExample::PtrExample ()
|
||||
{
|
||||
std::cout << "PtrExample constructor" << std::endl;
|
||||
}
|
||||
PtrExample::~PtrExample()
|
||||
PtrExample::~PtrExample ()
|
||||
{
|
||||
std::cout << "PtrExample destructor" << std::endl;
|
||||
}
|
||||
@@ -94,10 +94,10 @@ ClearPtr (void)
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
{
|
||||
// Create a new object of type PtrExample, store it in global
|
||||
// Create a new object of type PtrExample, store it in global
|
||||
// variable g_ptr
|
||||
Ptr<PtrExample> p = CreateObject<PtrExample> ();
|
||||
p->Method ();
|
||||
@@ -106,7 +106,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
// Create a new object of type PtrExample, store it in global
|
||||
// Create a new object of type PtrExample, store it in global
|
||||
// variable g_ptr, get a hold on the previous PtrExample object.
|
||||
Ptr<PtrExample> p = CreateObject<PtrExample> ();
|
||||
Ptr<PtrExample> prev = StorePtr (p);
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
using namespace ns3;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/**
|
||||
* Round a double number to the given precision.
|
||||
* For example, `dround(0.234, 0.1) = 0.2`
|
||||
* For example, `dround(0.234, 0.1) = 0.2`
|
||||
* and `dround(0.257, 0.1) = 0.3`
|
||||
* \param [in] number The number to round.
|
||||
* \param [in] precision The least significant digit to keep in the rounding.
|
||||
@@ -50,9 +50,13 @@ double dround (double number, double precision)
|
||||
{
|
||||
number /= precision;
|
||||
if (number >= 0)
|
||||
number = std::floor (number + 0.5);
|
||||
{
|
||||
number = std::floor (number + 0.5);
|
||||
}
|
||||
else
|
||||
number = std::ceil (number - 0.5);
|
||||
{
|
||||
number = std::ceil (number - 0.5);
|
||||
}
|
||||
number *= precision;
|
||||
return number;
|
||||
}
|
||||
@@ -68,13 +72,13 @@ double dround (double number, double precision)
|
||||
*/
|
||||
static GnuplotDataset
|
||||
Histogram (Ptr<RandomVariableStream> rndvar,
|
||||
unsigned int probes, double precision,
|
||||
const std::string& title, bool impulses = false)
|
||||
unsigned int probes, double precision,
|
||||
const std::string& title, bool impulses = false)
|
||||
{
|
||||
typedef std::map<double, unsigned int> histogram_maptype;
|
||||
histogram_maptype histogram;
|
||||
|
||||
for(unsigned int i = 0; i < probes; ++i)
|
||||
for (unsigned int i = 0; i < probes; ++i)
|
||||
{
|
||||
double val = dround ( rndvar->GetValue (), precision );
|
||||
|
||||
@@ -89,8 +93,8 @@ Histogram (Ptr<RandomVariableStream> rndvar,
|
||||
data.SetStyle (Gnuplot2dDataset::IMPULSES);
|
||||
}
|
||||
|
||||
for(histogram_maptype::const_iterator hi = histogram.begin ();
|
||||
hi != histogram.end (); ++hi)
|
||||
for (histogram_maptype::const_iterator hi = histogram.begin ();
|
||||
hi != histogram.end (); ++hi)
|
||||
{
|
||||
data.Add (hi->first, (double)hi->second / (double)probes / precision);
|
||||
}
|
||||
@@ -104,8 +108,8 @@ Histogram (Ptr<RandomVariableStream> rndvar,
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
unsigned int probes = 1000000;
|
||||
double precision = 0.01;
|
||||
|
||||
@@ -122,7 +126,7 @@ int main (int argc, char *argv[])
|
||||
x->SetAttribute ("Max", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x, probes, precision,
|
||||
"UniformRandomVariable [0.0 .. 1.0)") );
|
||||
"UniformRandomVariable [0.0 .. 1.0)") );
|
||||
plot.AddDataset ( Gnuplot2dFunction ("1.0",
|
||||
"0 <= x && x <= 1 ? 1.0 : 0") );
|
||||
|
||||
@@ -139,7 +143,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Mean", DoubleValue (0.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"ExponentialRandomVariable m=0.5") );
|
||||
"ExponentialRandomVariable m=0.5") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 0.5",
|
||||
"ExpDist(x, 0.5)") );
|
||||
@@ -148,7 +152,7 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Mean", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"ExponentialRandomVariable m=1") );
|
||||
"ExponentialRandomVariable m=1") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.0",
|
||||
"ExpDist(x, 1.0)") );
|
||||
@@ -157,7 +161,7 @@ int main (int argc, char *argv[])
|
||||
x3->SetAttribute ("Mean", DoubleValue (1.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"ExponentialRandomVariable m=1.5") );
|
||||
"ExponentialRandomVariable m=1.5") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.5",
|
||||
"ExpDist(x, 1.5)") );
|
||||
@@ -175,21 +179,21 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Shape", DoubleValue (1.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"ParetoRandomVariable scale=1.0 shape=1.5") );
|
||||
"ParetoRandomVariable scale=1.0 shape=1.5") );
|
||||
|
||||
Ptr<ParetoRandomVariable> x2 = CreateObject<ParetoRandomVariable> ();
|
||||
x2->SetAttribute ("Scale", DoubleValue (1.0));
|
||||
x2->SetAttribute ("Shape", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"ParetoRandomVariable scale=1.0 shape=2.0") );
|
||||
"ParetoRandomVariable scale=1.0 shape=2.0") );
|
||||
|
||||
Ptr<ParetoRandomVariable> x3 = CreateObject<ParetoRandomVariable> ();
|
||||
x3->SetAttribute ("Scale", DoubleValue (1.0));
|
||||
x3->SetAttribute ("Shape", DoubleValue (2.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"ParetoRandomVariable scale=1.0 shape=2.5") );
|
||||
"ParetoRandomVariable scale=1.0 shape=2.5") );
|
||||
|
||||
gnuplots.AddPlot (plot);
|
||||
}
|
||||
@@ -204,21 +208,21 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Shape", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"WeibullRandomVariable scale=1.0 shape=1.0") );
|
||||
"WeibullRandomVariable scale=1.0 shape=1.0") );
|
||||
|
||||
Ptr<WeibullRandomVariable> x2 = CreateObject<WeibullRandomVariable> ();
|
||||
x2->SetAttribute ("Scale", DoubleValue (1.0));
|
||||
x2->SetAttribute ("Shape", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"WeibullRandomVariable scale=1.0 shape=2.0") );
|
||||
"WeibullRandomVariable scale=1.0 shape=2.0") );
|
||||
|
||||
Ptr<WeibullRandomVariable> x3 = CreateObject<WeibullRandomVariable> ();
|
||||
x3->SetAttribute ("Scale", DoubleValue (1.0));
|
||||
x3->SetAttribute ("Shape", DoubleValue (3.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"WeibullRandomVariable scale=1.0 shape=3.0") );
|
||||
"WeibullRandomVariable scale=1.0 shape=3.0") );
|
||||
|
||||
gnuplots.AddPlot (plot);
|
||||
}
|
||||
@@ -234,7 +238,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Variance", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"NormalRandomVariable m=0.0 v=1.0") );
|
||||
"NormalRandomVariable m=0.0 v=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0",
|
||||
"NormalDist(x,0.0,1.0)") );
|
||||
@@ -244,7 +248,7 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Variance", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"NormalRandomVariable m=0.0 v=2.0") );
|
||||
"NormalRandomVariable m=0.0 v=2.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)",
|
||||
"NormalDist(x,0.0,sqrt(2.0))") );
|
||||
@@ -254,7 +258,7 @@ int main (int argc, char *argv[])
|
||||
x3->SetAttribute ("Variance", DoubleValue (3.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"NormalRandomVariable m=0.0 v=3.0") );
|
||||
"NormalRandomVariable m=0.0 v=3.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)",
|
||||
"NormalDist(x,0.0,sqrt(3.0))") );
|
||||
@@ -313,7 +317,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Sigma", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=1.0") );
|
||||
"LogNormalRandomVariable m=0.0 s=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 1.0)",
|
||||
"LogNormalDist(x, 0.0, 1.0)") );
|
||||
@@ -323,14 +327,14 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Sigma", DoubleValue (0.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=0.5") );
|
||||
"LogNormalRandomVariable m=0.0 s=0.5") );
|
||||
|
||||
Ptr<LogNormalRandomVariable> x3 = CreateObject<LogNormalRandomVariable> ();
|
||||
x3->SetAttribute ("Mu", DoubleValue (0.0));
|
||||
x3->SetAttribute ("Sigma", DoubleValue (0.25));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=0.25") );
|
||||
"LogNormalRandomVariable m=0.0 s=0.25") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 0.25)",
|
||||
"LogNormalDist(x, 0.0, 0.25)") );
|
||||
@@ -340,14 +344,14 @@ int main (int argc, char *argv[])
|
||||
x4->SetAttribute ("Sigma", DoubleValue (0.125));
|
||||
|
||||
plot.AddDataset ( Histogram (x4, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=0.125") );
|
||||
"LogNormalRandomVariable m=0.0 s=0.125") );
|
||||
|
||||
Ptr<LogNormalRandomVariable> x5 = CreateObject<LogNormalRandomVariable> ();
|
||||
x5->SetAttribute ("Mu", DoubleValue (0.0));
|
||||
x5->SetAttribute ("Sigma", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x5, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=2.0") );
|
||||
"LogNormalRandomVariable m=0.0 s=2.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 2.0)",
|
||||
"LogNormalDist(x, 0.0, 2.0)") );
|
||||
@@ -357,7 +361,7 @@ int main (int argc, char *argv[])
|
||||
x6->SetAttribute ("Sigma", DoubleValue (2.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x6, probes, precision,
|
||||
"LogNormalRandomVariable m=0.0 s=2.5") );
|
||||
"LogNormalRandomVariable m=0.0 s=2.5") );
|
||||
|
||||
gnuplots.AddPlot (plot);
|
||||
}
|
||||
@@ -373,7 +377,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Mean", DoubleValue (0.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.5") );
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.5") );
|
||||
|
||||
Ptr<TriangularRandomVariable> x2 = CreateObject<TriangularRandomVariable> ();
|
||||
x2->SetAttribute ("Min", DoubleValue (0.0));
|
||||
@@ -381,7 +385,7 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Mean", DoubleValue (0.4));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.4") );
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.4") );
|
||||
|
||||
Ptr<TriangularRandomVariable> x3 = CreateObject<TriangularRandomVariable> ();
|
||||
x3->SetAttribute ("Min", DoubleValue (0.0));
|
||||
@@ -389,7 +393,7 @@ int main (int argc, char *argv[])
|
||||
x3->SetAttribute ("Mean", DoubleValue (0.65));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.65") );
|
||||
"TriangularRandomVariable [0.0 .. 1.0) m=0.65") );
|
||||
|
||||
gnuplots.AddPlot (plot);
|
||||
}
|
||||
@@ -408,7 +412,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Beta", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"GammaRandomVariable a=1.0 b=1.0") );
|
||||
"GammaRandomVariable a=1.0 b=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.0, 1.0)",
|
||||
"GammaDist(x, 1.0, 1.0)") );
|
||||
@@ -418,7 +422,7 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Beta", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"GammaRandomVariable a=1.5 b=1.0") );
|
||||
"GammaRandomVariable a=1.5 b=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.5, 1.0)",
|
||||
"GammaDist(x, 1.5, 1.0)") );
|
||||
@@ -428,7 +432,7 @@ int main (int argc, char *argv[])
|
||||
x3->SetAttribute ("Beta", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"GammaRandomVariable a=2.0 b=1.0") );
|
||||
"GammaRandomVariable a=2.0 b=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 1.0)",
|
||||
"GammaDist(x, 2.0, 1.0)") );
|
||||
@@ -438,7 +442,7 @@ int main (int argc, char *argv[])
|
||||
x4->SetAttribute ("Beta", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x4, probes, precision,
|
||||
"GammaRandomVariable a=4.0 b=1.0") );
|
||||
"GammaRandomVariable a=4.0 b=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 4.0, 1.0)",
|
||||
"GammaDist(x, 4.0, 1.0)") );
|
||||
@@ -448,7 +452,7 @@ int main (int argc, char *argv[])
|
||||
x5->SetAttribute ("Beta", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x5, probes, precision,
|
||||
"GammaRandomVariable a=2.0 b=2.0") );
|
||||
"GammaRandomVariable a=2.0 b=2.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 2.0)",
|
||||
"GammaDist(x, 2.0, 2.0)") );
|
||||
@@ -458,7 +462,7 @@ int main (int argc, char *argv[])
|
||||
x6->SetAttribute ("Beta", DoubleValue (3.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x6, probes, precision,
|
||||
"GammaRandomVariable a=2.5 b=3.0") );
|
||||
"GammaRandomVariable a=2.5 b=3.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 3.0)",
|
||||
"GammaDist(x, 2.5, 3.0)") );
|
||||
@@ -468,7 +472,7 @@ int main (int argc, char *argv[])
|
||||
x7->SetAttribute ("Beta", DoubleValue (4.5));
|
||||
|
||||
plot.AddDataset ( Histogram (x7, probes, precision,
|
||||
"GammaRandomVariable a=2.5 b=4.5") );
|
||||
"GammaRandomVariable a=2.5 b=4.5") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 4.5)",
|
||||
"GammaDist(x, 2.5, 4.5)") );
|
||||
@@ -489,7 +493,7 @@ int main (int argc, char *argv[])
|
||||
x1->SetAttribute ("Lambda", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x1, probes, precision,
|
||||
"ErlangRandomVariable k=1 {/Symbol l}=1.0") );
|
||||
"ErlangRandomVariable k=1 {/Symbol l}=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 1, 1.0)",
|
||||
"ErlangDist(x, 1, 1.0)") );
|
||||
@@ -499,7 +503,7 @@ int main (int argc, char *argv[])
|
||||
x2->SetAttribute ("Lambda", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x2, probes, precision,
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=1.0") );
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 1.0)",
|
||||
"ErlangDist(x, 2, 1.0)") );
|
||||
@@ -509,7 +513,7 @@ int main (int argc, char *argv[])
|
||||
x3->SetAttribute ("Lambda", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x3, probes, precision,
|
||||
"ErlangRandomVariable k=3 {/Symbol l}=1.0") );
|
||||
"ErlangRandomVariable k=3 {/Symbol l}=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 3, 1.0)",
|
||||
"ErlangDist(x, 3, 1.0)") );
|
||||
@@ -519,7 +523,7 @@ int main (int argc, char *argv[])
|
||||
x4->SetAttribute ("Lambda", DoubleValue (1.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x4, probes, precision,
|
||||
"ErlangRandomVariable k=5 {/Symbol l}=1.0") );
|
||||
"ErlangRandomVariable k=5 {/Symbol l}=1.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 5, 1.0)",
|
||||
"ErlangDist(x, 5, 1.0)") );
|
||||
@@ -529,7 +533,7 @@ int main (int argc, char *argv[])
|
||||
x5->SetAttribute ("Lambda", DoubleValue (2.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x5, probes, precision,
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=2.0") );
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=2.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 2.0)",
|
||||
"ErlangDist(x, 2, 2.0)") );
|
||||
@@ -539,7 +543,7 @@ int main (int argc, char *argv[])
|
||||
x6->SetAttribute ("Lambda", DoubleValue (3.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x6, probes, precision,
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=3.0") );
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=3.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 3.0)",
|
||||
"ErlangDist(x, 2, 3.0)") );
|
||||
@@ -549,7 +553,7 @@ int main (int argc, char *argv[])
|
||||
x7->SetAttribute ("Lambda", DoubleValue (5.0));
|
||||
|
||||
plot.AddDataset ( Histogram (x7, probes, precision,
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=5.0") );
|
||||
"ErlangRandomVariable k=2 {/Symbol l}=5.0") );
|
||||
|
||||
plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 5.0)",
|
||||
"ErlangDist(x, 2, 5.0)") );
|
||||
|
||||
@@ -46,33 +46,33 @@ using namespace ns3;
|
||||
NS_LOG_COMPONENT_DEFINE ("TestSync");
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/** Check that the event functions run in the intended order. */
|
||||
bool gFirstRun = false;
|
||||
|
||||
/** An event method called many times from the background thread. */
|
||||
void
|
||||
void
|
||||
inserted_function (void)
|
||||
{
|
||||
NS_ASSERT (gFirstRun);
|
||||
NS_LOG_UNCOND ("inserted_function() called at " <<
|
||||
NS_LOG_UNCOND ("inserted_function() called at " <<
|
||||
Simulator::Now ().GetSeconds () << " s");
|
||||
}
|
||||
|
||||
/** An event method called many times from the main thread. */
|
||||
void
|
||||
void
|
||||
background_function (void)
|
||||
{
|
||||
NS_ASSERT (gFirstRun);
|
||||
NS_LOG_UNCOND ("background_function() called at " <<
|
||||
NS_LOG_UNCOND ("background_function() called at " <<
|
||||
Simulator::Now ().GetSeconds () << " s");
|
||||
}
|
||||
|
||||
/** An event method called once from the main thread. */
|
||||
void
|
||||
void
|
||||
first_function (void)
|
||||
{
|
||||
NS_LOG_UNCOND ("first_function() called at " <<
|
||||
NS_LOG_UNCOND ("first_function() called at " <<
|
||||
Simulator::Now ().GetSeconds () << " s");
|
||||
gFirstRun = true;
|
||||
}
|
||||
@@ -96,15 +96,15 @@ void
|
||||
FakeNetDevice::Doit3 (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
std::this_thread::sleep_for (std::chrono::seconds(1));
|
||||
std::this_thread::sleep_for (std::chrono::seconds (1));
|
||||
|
||||
for (uint32_t i = 0; i < 10000; ++i)
|
||||
{
|
||||
//
|
||||
// Exercise the realtime relative now path
|
||||
//
|
||||
Simulator::ScheduleWithContext(Simulator::NO_CONTEXT, Seconds(0.0), MakeEvent (&inserted_function));
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds(1));
|
||||
Simulator::ScheduleWithContext (Simulator::NO_CONTEXT, Seconds (0.0), MakeEvent (&inserted_function));
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds (1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,20 +117,20 @@ FakeNetDevice::Doit3 (void)
|
||||
* thread with an instance of FakeNetDevice, which schedules many instances of
|
||||
* \c inserted_function.
|
||||
*/
|
||||
void
|
||||
void
|
||||
test (void)
|
||||
{
|
||||
GlobalValue::Bind ("SimulatorImplementationType",
|
||||
GlobalValue::Bind ("SimulatorImplementationType",
|
||||
StringValue ("ns3::RealtimeSimulatorImpl"));
|
||||
|
||||
FakeNetDevice fnd;
|
||||
|
||||
//
|
||||
//
|
||||
// Make sure ScheduleNow works when the system isn't running
|
||||
//
|
||||
Simulator::ScheduleWithContext(0xffffffff, Seconds(0.0), MakeEvent (&first_function));
|
||||
Simulator::ScheduleWithContext (0xffffffff, Seconds (0.0), MakeEvent (&first_function));
|
||||
|
||||
//
|
||||
//
|
||||
// drive the progression of m_currentTs at a ten millisecond rate from the main thread
|
||||
//
|
||||
for (double d = 0.; d < 14.999; d += 0.01)
|
||||
@@ -139,7 +139,7 @@ test (void)
|
||||
}
|
||||
|
||||
Ptr<SystemThread> st3 = Create<SystemThread> (
|
||||
MakeCallback (&FakeNetDevice::Doit3, &fnd));
|
||||
MakeCallback (&FakeNetDevice::Doit3, &fnd));
|
||||
st3->Start ();
|
||||
|
||||
Simulator::Stop (Seconds (15.0));
|
||||
@@ -156,7 +156,7 @@ main (int argc, char *argv[])
|
||||
{
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
test ();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* Example program that demonstrates how to replace the time printer.
|
||||
*
|
||||
* This program creates a sample object and schedules some methods to
|
||||
* occur at future times. When run with no arguments, it prints out
|
||||
* occur at future times. When run with no arguments, it prints out
|
||||
* something like this:
|
||||
* \code
|
||||
* $ ./waf --run sample-log-time-format
|
||||
@@ -56,7 +56,7 @@
|
||||
* once the simulator object is instantiated (after Simulator::Run ()
|
||||
* is called).
|
||||
*
|
||||
* To change the format, one can schedule (at simulation time 0) a
|
||||
* To change the format, one can schedule (at simulation time 0) a
|
||||
* replacement function for printing time. This can be demonstrated
|
||||
* by setting the 'replace-time-printer' parameter to true:
|
||||
* \code
|
||||
@@ -77,10 +77,10 @@
|
||||
* (which was the default for ns-3 versions 3.26 and earlier).
|
||||
*
|
||||
* In addition, the 'resolution' program argument allows one to experiment
|
||||
* with changing ns-3's time resolution from its default of Time::NS, such
|
||||
* with changing ns-3's time resolution from its default of Time::NS, such
|
||||
* as Time::PS or Time::FS; the precision changes accordingly.
|
||||
*
|
||||
* The maximum useful precision is 20 decimal digits, since Time is
|
||||
* The maximum useful precision is 20 decimal digits, since Time is
|
||||
* signed 64 bits.
|
||||
*/
|
||||
|
||||
@@ -93,10 +93,10 @@
|
||||
using namespace ns3;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/**
|
||||
* Pre-ns-3.26 TimePrinter equivalent (was called LogTimePrinter).
|
||||
*
|
||||
*
|
||||
* Prior to ns-3.26, the time printer used default C++ iostream precision
|
||||
* This function sets it back to the format used before ns-3.26
|
||||
*
|
||||
|
||||
@@ -29,29 +29,29 @@
|
||||
*
|
||||
* This program can be run from waf such as
|
||||
* `./waf --run sample-random-variable-stream`
|
||||
*
|
||||
* This program is about as simple as possible to display the use of ns-3
|
||||
*
|
||||
* This program is about as simple as possible to display the use of ns-3
|
||||
* to generate random numbers. By default, the uniform random variate that
|
||||
* will be printed is 0.816532. Because ns-3 uses a fixed seed for the
|
||||
* pseudo-random number generator, this program should always output the
|
||||
* same number. Likewise, ns-3 simulations using random variables will
|
||||
* behave deterministically unless the user changes the Run number or the
|
||||
* Seed.
|
||||
*
|
||||
*
|
||||
* There are three primary mechanisms to change the seed or run numbers
|
||||
* from their default integer value of 1:
|
||||
*
|
||||
* 1. Through explicit call of SeedManager::SetSeed () and
|
||||
* SeedManager::SetRun () (commented out below)
|
||||
*
|
||||
* 1. Through explicit call of SeedManager::SetSeed () and
|
||||
* SeedManager::SetRun () (commented out below)
|
||||
* 2. Through the passing of command line arguments such as:
|
||||
* `./waf --command-template="%s --RngRun=<value>" --run program-name`
|
||||
* 3. Through the use of the NS_GLOBAL_VALUE environment variable, such as:
|
||||
* `$ NS_GLOBAL_VALUE="RngRun=<value>" ./waf --run program-name`
|
||||
*
|
||||
*
|
||||
* For instance, setting the run number to 3 will change the program output to
|
||||
* 0.775417
|
||||
*
|
||||
* Consult the ns-3 manual for more information about the use of the
|
||||
*
|
||||
* Consult the ns-3 manual for more information about the use of the
|
||||
* random number generator
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,29 +31,29 @@ using namespace ns3;
|
||||
/**
|
||||
* This program can be run from waf such as
|
||||
* `./waf --run sample-random-variable`
|
||||
*
|
||||
* This program is about as simple as possible to display the use of ns-3
|
||||
*
|
||||
* This program is about as simple as possible to display the use of ns-3
|
||||
* to generate random numbers. By default, the uniform random variate that
|
||||
* will be outputted is 0.816532. Because ns-3 uses a fixed seed for the
|
||||
* pseudo-random number generator, this program should always output the
|
||||
* same number. Likewise, ns-3 simulations using random variables will
|
||||
* behave deterministically unless the user changes the Run number or the
|
||||
* Seed.
|
||||
*
|
||||
*
|
||||
* There are three primary mechanisms to change the seed or run numbers
|
||||
* from their default integer value of 1:
|
||||
*
|
||||
* 1. Through explicit call of SeedManager::SetSeed () and
|
||||
* SeedManager::SetRun () (commented out below)
|
||||
* 1. Through explicit call of SeedManager::SetSeed () and
|
||||
* SeedManager::SetRun () (commented out below)
|
||||
* 2. Through the passing of command line arguments such as:
|
||||
* ./waf --command-template="%s --RngRun=<value>" --run program-name`
|
||||
* 3. Through the use of the NS_GLOBAL_VALUE environment variable, such as:
|
||||
* `$ NS_GLOBAL_VALUE="RngRun=<value>" ./waf --run program-name`
|
||||
*
|
||||
*
|
||||
* For instance, setting the run number to 3 will change the program output to
|
||||
* 0.775417
|
||||
*
|
||||
* Consult the ns-3 manual for more information about the use of the
|
||||
*
|
||||
* Consult the ns-3 manual for more information about the use of the
|
||||
* random number generator
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,23 +46,25 @@ namespace {
|
||||
|
||||
class Timestamp
|
||||
{
|
||||
public:
|
||||
public:
|
||||
Timestamp () :
|
||||
last(0),
|
||||
diff(0)
|
||||
last (0),
|
||||
diff (0)
|
||||
{
|
||||
stamp ();
|
||||
}
|
||||
|
||||
void stamp () {
|
||||
|
||||
void stamp ()
|
||||
{
|
||||
time_t seconds = time (NULL);
|
||||
diff = seconds - last;
|
||||
last = seconds;
|
||||
}
|
||||
|
||||
std::string string () {
|
||||
std::string string ()
|
||||
{
|
||||
std::string now = ctime ( &last );
|
||||
now.resize(now.length () - 1); // trim trailing newline
|
||||
now.resize (now.length () - 1); // trim trailing newline
|
||||
return now;
|
||||
}
|
||||
|
||||
@@ -71,14 +73,14 @@ class Timestamp
|
||||
|
||||
}; // class Timestamp
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Execute a function periodically.
|
||||
*/
|
||||
class Hold : public SimpleRefCount<Hold>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
Hold (Time wait, Time interval)
|
||||
{
|
||||
m_wait = wait;
|
||||
@@ -90,15 +92,14 @@ public:
|
||||
|
||||
Hold (Ptr<RandomVariableStream> rng)
|
||||
: m_rng (rng)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void Event (void)
|
||||
{
|
||||
double delta = m_rng->GetValue ();
|
||||
Time delay = Seconds (delta);
|
||||
NS_LOG_LOGIC ("event delay: " << delay);
|
||||
|
||||
|
||||
Simulator::Schedule (delay, &Hold::Event, this);
|
||||
|
||||
// Switch work load every 10 * m_interval of simulation time
|
||||
@@ -106,9 +107,9 @@ public:
|
||||
bool even = (ratio.GetHigh () % 2);
|
||||
Time work = m_wait * (even ? 3 : 1);
|
||||
m_condition.TimedWait ( work.GetNanoSeconds () );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Ptr<RandomVariableStream> m_rng;
|
||||
SystemCondition m_condition;
|
||||
@@ -143,7 +144,7 @@ main (int argc, char ** argv)
|
||||
<< "average event sleep time: " << wait.As (Time::MS) << "\n"
|
||||
<< "total simulation run time: " << stop.As (Time::S)
|
||||
<< std::endl;
|
||||
|
||||
|
||||
Ptr<Hold> h = Create<Hold> (wait, interval);
|
||||
h->Event ();
|
||||
|
||||
@@ -158,13 +159,13 @@ main (int argc, char ** argv)
|
||||
std::cout << "Start wall clock: " << ts.string ()
|
||||
<< " (" << ts.last << ")"
|
||||
<< std::endl;
|
||||
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
ts.stamp ();
|
||||
std::cout << "Elapsed wall clock: " << ts.diff << "s" << std::endl;
|
||||
|
||||
|
||||
|
||||
Simulator::Destroy ();
|
||||
|
||||
}
|
||||
|
||||
@@ -35,13 +35,14 @@
|
||||
using namespace ns3;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/** Simple model object to illustrate event handling. */
|
||||
class MyModel
|
||||
{
|
||||
public:
|
||||
/** Start model execution by scheduling a HandleEvent. */
|
||||
void Start (void);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Simple event handler.
|
||||
|
||||
@@ -36,7 +36,7 @@ using namespace ns3;
|
||||
NS_LOG_COMPONENT_DEFINE ("TestStringValueFormatting");
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup string-value-formatting
|
||||
*
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
* \returns the test variable
|
||||
*/
|
||||
Ptr<RandomVariableStream> GetTestVariable (void) const;
|
||||
|
||||
private:
|
||||
Ptr<RandomVariableStream> m_testVariable; //!< The test variable
|
||||
};
|
||||
@@ -81,8 +82,7 @@ FormattingTestObject::GetTypeId (void)
|
||||
}
|
||||
|
||||
FormattingTestObject::FormattingTestObject ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Ptr<RandomVariableStream>
|
||||
FormattingTestObject::GetTestVariable (void) const
|
||||
@@ -104,13 +104,14 @@ public:
|
||||
* Set an attribute by name
|
||||
* \param name the attribute
|
||||
* \param value the attribute value
|
||||
*/
|
||||
*/
|
||||
void SetAttribute (std::string name, const AttributeValue &value);
|
||||
/**
|
||||
* Create an Object as configured by SetAttribute
|
||||
* \returns the newly created Object
|
||||
*/
|
||||
Ptr<Object> CreateFromFactory (void);
|
||||
|
||||
private:
|
||||
ObjectFactory m_factory; //!< Object factory
|
||||
};
|
||||
@@ -135,7 +136,7 @@ FormattingTestObjectHelper::CreateFromFactory (void)
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
// CreateObject parsing
|
||||
|
||||
@@ -32,15 +32,16 @@ namespace ns3 {
|
||||
EventGarbageCollector::EventGarbageCollector ()
|
||||
: m_nextCleanupSize (CHUNK_INIT_SIZE),
|
||||
m_events ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
EventGarbageCollector::Track (EventId event)
|
||||
{
|
||||
m_events.insert (event);
|
||||
if (m_events.size () >= m_nextCleanupSize)
|
||||
Cleanup ();
|
||||
{
|
||||
Cleanup ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -54,7 +55,9 @@ void
|
||||
EventGarbageCollector::Shrink ()
|
||||
{
|
||||
while (m_nextCleanupSize > m_events.size ())
|
||||
m_nextCleanupSize >>= 1;
|
||||
{
|
||||
m_nextCleanupSize >>= 1;
|
||||
}
|
||||
Grow ();
|
||||
}
|
||||
|
||||
@@ -70,14 +73,20 @@ EventGarbageCollector::Cleanup ()
|
||||
m_events.erase (iter++);
|
||||
}
|
||||
else
|
||||
break; // EventIds are sorted by timestamp => further events are not expired for sure
|
||||
{
|
||||
break; // EventIds are sorted by timestamp => further events are not expired for sure
|
||||
}
|
||||
}
|
||||
|
||||
// If after cleanup we are still over the limit, increase the limit.
|
||||
if (m_events.size () >= m_nextCleanupSize)
|
||||
Grow ();
|
||||
{
|
||||
Grow ();
|
||||
}
|
||||
else
|
||||
Shrink ();
|
||||
{
|
||||
Shrink ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ int64_t RandomVariableStreamHelper::AssignStreams (std::string path, int64_t str
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_ASSERT (stream >= 0);
|
||||
Config::MatchContainer mc = Config::LookupMatches (path);
|
||||
|
||||
|
||||
std::size_t i = 0;
|
||||
for ( ; i < mc.GetN (); ++i)
|
||||
{
|
||||
|
||||
@@ -41,11 +41,12 @@ using namespace ns3;
|
||||
* Test class for TracedValue callbacks.
|
||||
* \see attribute_ValueClassTest
|
||||
*/
|
||||
class ValueClassTest
|
||||
class ValueClassTest
|
||||
{
|
||||
public:
|
||||
ValueClassTest () {}
|
||||
|
||||
ValueClassTest ()
|
||||
{}
|
||||
|
||||
/**
|
||||
* TracedValue callback signature for ValueClassTest
|
||||
*
|
||||
@@ -80,14 +81,16 @@ ATTRIBUTE_HELPER_CPP (ValueClassTest);
|
||||
class Derived : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void) {
|
||||
static TypeId GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Derived")
|
||||
.AddConstructor<Derived> ()
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
Derived () {}
|
||||
Derived ()
|
||||
{}
|
||||
};
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Derived);
|
||||
@@ -95,12 +98,14 @@ NS_OBJECT_ENSURE_REGISTERED (Derived);
|
||||
class AttributeObjectTest : public Object
|
||||
{
|
||||
public:
|
||||
enum Test_e {
|
||||
enum Test_e
|
||||
{
|
||||
TEST_A,
|
||||
TEST_B,
|
||||
TEST_C
|
||||
};
|
||||
static TypeId GetTypeId (void) {
|
||||
static TypeId GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::AttributeObjectTest")
|
||||
.AddConstructor<AttributeObjectTest> ()
|
||||
.SetParent<Object> ()
|
||||
@@ -208,11 +213,11 @@ public:
|
||||
MakePointerAccessor (&AttributeObjectTest::m_ptr),
|
||||
MakePointerChecker<Derived> ())
|
||||
.AddAttribute ("PointerInitialized", "help text",
|
||||
StringValue("ns3::Derived"),
|
||||
StringValue ("ns3::Derived"),
|
||||
MakePointerAccessor (&AttributeObjectTest::m_ptrInitialized),
|
||||
MakePointerChecker<Derived> ())
|
||||
.AddAttribute ("PointerInitialized2", "help text",
|
||||
StringValue("ns3::Derived[]"),
|
||||
StringValue ("ns3::Derived[]"),
|
||||
MakePointerAccessor (&AttributeObjectTest::m_ptrInitialized2),
|
||||
MakePointerChecker<Derived> ())
|
||||
.AddAttribute ("Callback", "help text",
|
||||
@@ -239,33 +244,79 @@ public:
|
||||
NS_UNUSED (m_enumSetGet);
|
||||
}
|
||||
|
||||
virtual ~AttributeObjectTest (void) {};
|
||||
virtual ~AttributeObjectTest (void)
|
||||
{}
|
||||
|
||||
void AddToVector1 (void) { m_vector1.push_back (CreateObject<Derived> ()); }
|
||||
void AddToVector2 (void) { m_vector2.push_back (CreateObject<Derived> ()); }
|
||||
void AddToVector1 (void)
|
||||
{
|
||||
m_vector1.push_back (CreateObject<Derived> ());
|
||||
}
|
||||
void AddToVector2 (void)
|
||||
{
|
||||
m_vector2.push_back (CreateObject<Derived> ());
|
||||
}
|
||||
|
||||
void AddToMap1 (uint32_t i) { m_map1.insert (std::pair <uint32_t, Ptr<Derived> > (i, CreateObject<Derived> ())); }
|
||||
void AddToMap1 (uint32_t i)
|
||||
{
|
||||
m_map1.insert (std::pair <uint32_t, Ptr<Derived> > (i, CreateObject<Derived> ()));
|
||||
}
|
||||
|
||||
void InvokeCb (double a, int b, float c) { m_cb (a,b,c); }
|
||||
void InvokeCb (double a, int b, float c)
|
||||
{
|
||||
m_cb (a,b,c);
|
||||
}
|
||||
|
||||
void InvokeCbValue (int8_t a)
|
||||
{
|
||||
if (!m_cbValue.IsNull ()) {
|
||||
if (!m_cbValue.IsNull ())
|
||||
{
|
||||
m_cbValue (a);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void DoSetTestB (bool v) { m_boolTestA = v; }
|
||||
bool DoGetTestB (void) const { return m_boolTestA; }
|
||||
int16_t DoGetInt16 (void) const { return m_int16SetGet; }
|
||||
void DoSetInt16 (int16_t v) { m_int16SetGet = v; }
|
||||
std::size_t DoGetVectorN (void) const { return m_vector2.size (); }
|
||||
Ptr<Derived> DoGetVector (std::size_t i) const { return m_vector2[i]; }
|
||||
bool DoSetIntSrc (int8_t v) { m_intSrc2 = v; return true; }
|
||||
int8_t DoGetIntSrc (void) const { return m_intSrc2; }
|
||||
bool DoSetEnum (Test_e v) { m_enumSetGet = v; return true; }
|
||||
Test_e DoGetEnum (void) const { return m_enumSetGet; }
|
||||
void DoSetTestB (bool v)
|
||||
{
|
||||
m_boolTestA = v;
|
||||
}
|
||||
bool DoGetTestB (void) const
|
||||
{
|
||||
return m_boolTestA;
|
||||
}
|
||||
int16_t DoGetInt16 (void) const
|
||||
{
|
||||
return m_int16SetGet;
|
||||
}
|
||||
void DoSetInt16 (int16_t v)
|
||||
{
|
||||
m_int16SetGet = v;
|
||||
}
|
||||
std::size_t DoGetVectorN (void) const
|
||||
{
|
||||
return m_vector2.size ();
|
||||
}
|
||||
Ptr<Derived> DoGetVector (std::size_t i) const
|
||||
{
|
||||
return m_vector2[i];
|
||||
}
|
||||
bool DoSetIntSrc (int8_t v)
|
||||
{
|
||||
m_intSrc2 = v;
|
||||
return true;
|
||||
}
|
||||
int8_t DoGetIntSrc (void) const
|
||||
{
|
||||
return m_intSrc2;
|
||||
}
|
||||
bool DoSetEnum (Test_e v)
|
||||
{
|
||||
m_enumSetGet = v;
|
||||
return true;
|
||||
}
|
||||
Test_e DoGetEnum (void) const
|
||||
{
|
||||
return m_enumSetGet;
|
||||
}
|
||||
|
||||
bool m_boolTestA;
|
||||
bool m_boolTest;
|
||||
@@ -300,7 +351,7 @@ private:
|
||||
NS_OBJECT_ENSURE_REGISTERED (AttributeObjectTest);
|
||||
|
||||
// ===========================================================================
|
||||
// Test case template used for generic Attribute Value types -- used to make
|
||||
// Test case template used for generic Attribute Value types -- used to make
|
||||
// sure that Attributes work as expected.
|
||||
// ===========================================================================
|
||||
template <typename T>
|
||||
@@ -319,17 +370,15 @@ private:
|
||||
template <typename T>
|
||||
AttributeTestCase<T>::AttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
AttributeTestCase<T>::~AttributeTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
template <typename T> bool
|
||||
AttributeTestCase<T>::CheckGetCodePaths (
|
||||
Ptr<Object> p,
|
||||
Ptr<Object> p,
|
||||
std::string attributeName,
|
||||
std::string expectedString,
|
||||
T expectedValue)
|
||||
@@ -443,7 +492,7 @@ AttributeTestCase<IntegerValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestInt16", "-2", IntegerValue (-2));
|
||||
@@ -553,7 +602,7 @@ AttributeTestCase<UintegerValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestUint8", "1", UintegerValue (1));
|
||||
@@ -578,7 +627,7 @@ AttributeTestCase<UintegerValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
|
||||
|
||||
//
|
||||
// Try and set the Attribute past the most positive value of the unsigned
|
||||
// Try and set the Attribute past the most positive value of the unsigned
|
||||
// 8-bit range.
|
||||
//
|
||||
ok = p->SetAttributeFailSafe ("TestUint8", UintegerValue (256));
|
||||
@@ -624,7 +673,7 @@ AttributeTestCase<DoubleValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestFloat", "-1.1", DoubleValue ((float)-1.1));
|
||||
@@ -650,7 +699,7 @@ AttributeTestCase<EnumValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestEnum", "TestA", EnumValue (AttributeObjectTest::TEST_A));
|
||||
@@ -666,7 +715,7 @@ AttributeTestCase<EnumValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestEnumSetGet", "TestB", EnumValue (AttributeObjectTest::TEST_B));
|
||||
@@ -691,11 +740,11 @@ AttributeTestCase<EnumValue>::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe() via StringValue");
|
||||
|
||||
//
|
||||
// Try to set the Attribute to a bogus enum using the StringValue type and
|
||||
// Try to set the Attribute to a bogus enum using the StringValue type and
|
||||
// make sure the underlying value doesn't change.
|
||||
//
|
||||
ok = p->SetAttributeFailSafe ("TestEnum", StringValue ("TestD"));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() to TEST_D"); //
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() to TEST_D"); //
|
||||
|
||||
ok = CheckGetCodePaths (p, "TestEnum", "TestB", EnumValue (AttributeObjectTest::TEST_B));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Error in SetAttributeFailSafe() but value changes");
|
||||
@@ -722,7 +771,7 @@ AttributeTestCase<TimeValue>::DoRun (void)
|
||||
|
||||
// The test vectors assume ns resolution
|
||||
Time::SetResolution (Time::NS);
|
||||
|
||||
|
||||
//
|
||||
// Set value
|
||||
//
|
||||
@@ -738,7 +787,7 @@ AttributeTestCase<TimeValue>::DoRun (void)
|
||||
ok = CheckGetCodePaths (p, "TestTimeWithBounds", "+3000000000.0ns", TimeValue (Seconds (3)));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Attributes can have limits other than the intrinsic limits of the
|
||||
// underlying data types. These limits are specified in the Object.
|
||||
@@ -788,11 +837,13 @@ class RandomVariableStreamAttributeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
RandomVariableStreamAttributeTestCase (std::string description);
|
||||
virtual ~RandomVariableStreamAttributeTestCase () {}
|
||||
virtual ~RandomVariableStreamAttributeTestCase ()
|
||||
{}
|
||||
|
||||
void InvokeCbValue (int8_t a)
|
||||
{
|
||||
if (!m_cbValue.IsNull ()) {
|
||||
if (!m_cbValue.IsNull ())
|
||||
{
|
||||
m_cbValue (a);
|
||||
}
|
||||
}
|
||||
@@ -802,15 +853,17 @@ private:
|
||||
|
||||
Callback<void,int8_t> m_cbValue;
|
||||
|
||||
void NotifyCallbackValue (int8_t a) { m_gotCbValue = a; }
|
||||
void NotifyCallbackValue (int8_t a)
|
||||
{
|
||||
m_gotCbValue = a;
|
||||
}
|
||||
|
||||
int16_t m_gotCbValue;
|
||||
};
|
||||
|
||||
RandomVariableStreamAttributeTestCase::RandomVariableStreamAttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamAttributeTestCase::DoRun (void)
|
||||
@@ -842,7 +895,8 @@ class ObjectVectorAttributeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
ObjectVectorAttributeTestCase (std::string description);
|
||||
virtual ~ObjectVectorAttributeTestCase () {}
|
||||
virtual ~ObjectVectorAttributeTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -850,8 +904,7 @@ private:
|
||||
|
||||
ObjectVectorAttributeTestCase::ObjectVectorAttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ObjectVectorAttributeTestCase::DoRun (void)
|
||||
@@ -907,7 +960,8 @@ class ObjectMapAttributeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
ObjectMapAttributeTestCase (std::string description);
|
||||
virtual ~ObjectMapAttributeTestCase () {}
|
||||
virtual ~ObjectMapAttributeTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -915,8 +969,7 @@ private:
|
||||
|
||||
ObjectMapAttributeTestCase::ObjectMapAttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ObjectMapAttributeTestCase::DoRun (void)
|
||||
@@ -973,7 +1026,8 @@ class IntegerTraceSourceAttributeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
IntegerTraceSourceAttributeTestCase (std::string description);
|
||||
virtual ~IntegerTraceSourceAttributeTestCase () {}
|
||||
virtual ~IntegerTraceSourceAttributeTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -981,8 +1035,7 @@ private:
|
||||
|
||||
IntegerTraceSourceAttributeTestCase::IntegerTraceSourceAttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
IntegerTraceSourceAttributeTestCase::DoRun (void)
|
||||
@@ -995,7 +1048,7 @@ IntegerTraceSourceAttributeTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
p->GetAttribute ("IntegerTraceSource1", iv);
|
||||
@@ -1026,7 +1079,7 @@ IntegerTraceSourceAttributeTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
p->GetAttribute ("IntegerTraceSource2", iv);
|
||||
@@ -1058,30 +1111,30 @@ IntegerTraceSourceAttributeTestCase::DoRun (void)
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Trace sources used like Attributes must also work as trace sources. Make
|
||||
// Trace sources used like Attributes must also work as trace sources. Make
|
||||
// sure we can use them that way.
|
||||
// ===========================================================================
|
||||
class IntegerTraceSourceTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
IntegerTraceSourceTestCase (std::string description);
|
||||
virtual ~IntegerTraceSourceTestCase () {}
|
||||
virtual ~IntegerTraceSourceTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
void NotifySource1 (int8_t old, int8_t n)
|
||||
{
|
||||
NS_UNUSED (old);
|
||||
m_got1 = n;
|
||||
void NotifySource1 (int8_t old, int8_t n)
|
||||
{
|
||||
NS_UNUSED (old);
|
||||
m_got1 = n;
|
||||
}
|
||||
int64_t m_got1;
|
||||
};
|
||||
|
||||
IntegerTraceSourceTestCase::IntegerTraceSourceTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
IntegerTraceSourceTestCase::DoRun (void)
|
||||
@@ -1134,23 +1187,24 @@ IntegerTraceSourceTestCase::DoRun (void)
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Trace sources used like Attributes must also work as trace sources. Make
|
||||
// Trace sources used like Attributes must also work as trace sources. Make
|
||||
// sure we can use them that way.
|
||||
// ===========================================================================
|
||||
class TracedCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
TracedCallbackTestCase (std::string description);
|
||||
virtual ~TracedCallbackTestCase () {}
|
||||
virtual ~TracedCallbackTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
void NotifySource2 (double a, int b, float c)
|
||||
{
|
||||
NS_UNUSED (b);
|
||||
NS_UNUSED (c);
|
||||
m_got2 = a;
|
||||
void NotifySource2 (double a, int b, float c)
|
||||
{
|
||||
NS_UNUSED (b);
|
||||
NS_UNUSED (c);
|
||||
m_got2 = a;
|
||||
}
|
||||
|
||||
double m_got2;
|
||||
@@ -1158,8 +1212,7 @@ private:
|
||||
|
||||
TracedCallbackTestCase::TracedCallbackTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TracedCallbackTestCase::DoRun (void)
|
||||
@@ -1171,13 +1224,13 @@ TracedCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (p, 0, "Unable to CreateObject");
|
||||
|
||||
//
|
||||
// Initialize the
|
||||
// Initialize the
|
||||
//
|
||||
m_got2 = 4.3;
|
||||
|
||||
//
|
||||
// Invoke the callback that lies at the heart of this test. We have a
|
||||
// method InvokeCb() that just executes m_cb(). The variable m_cb is
|
||||
// method InvokeCb() that just executes m_cb(). The variable m_cb is
|
||||
// declared as a TracedCallback<double, int, float>. This kind of beast
|
||||
// is like a callback but can call a list of targets. This list should
|
||||
// be empty so nothing should happen now. Specifically, m_got2 shouldn't
|
||||
@@ -1202,7 +1255,7 @@ TracedCallbackTestCase::DoRun (void)
|
||||
|
||||
//
|
||||
// Now, disconnect the trace sink and see what happens when we invoke the
|
||||
// callback again. Of course, the trace should not happen and m_got2
|
||||
// callback again. Of course, the trace should not happen and m_got2
|
||||
// should remain unchanged.
|
||||
//
|
||||
ok = p->TraceDisconnectWithoutContext ("Source2", MakeCallback (&TracedCallbackTestCase::NotifySource2, this));
|
||||
@@ -1220,16 +1273,17 @@ class PointerAttributeTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
PointerAttributeTestCase (std::string description);
|
||||
virtual ~PointerAttributeTestCase () {}
|
||||
virtual ~PointerAttributeTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
void NotifySource2 (double a, int b, float c)
|
||||
{
|
||||
void NotifySource2 (double a, int b, float c)
|
||||
{
|
||||
NS_UNUSED (b);
|
||||
NS_UNUSED (c);
|
||||
m_got2 = a;
|
||||
m_got2 = a;
|
||||
}
|
||||
|
||||
double m_got2;
|
||||
@@ -1237,8 +1291,7 @@ private:
|
||||
|
||||
PointerAttributeTestCase::PointerAttributeTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
PointerAttributeTestCase::DoRun (void)
|
||||
@@ -1278,7 +1331,7 @@ PointerAttributeTestCase::DoRun (void)
|
||||
//
|
||||
// We should be able to use the Attribute Get() just like GetObject<type>,
|
||||
// So see if we can get a Ptr<Object> out of the Ptr<Derived> we stored.
|
||||
// This should be a pointer to the same physical memory since its the
|
||||
// This should be a pointer to the same physical memory since its the
|
||||
// same object.
|
||||
//
|
||||
p->GetAttribute ("Pointer", ptr);
|
||||
@@ -1309,7 +1362,7 @@ PointerAttributeTestCase::DoRun (void)
|
||||
Ptr<Derived> storedPtr3 = ptr3.Get<Derived> ();
|
||||
NS_TEST_ASSERT_MSG_NE (storedPtr, storedPtr3, "ptr and ptr3 both have PointerInitialized pointing to the same object");
|
||||
|
||||
//
|
||||
//
|
||||
// Test whether object factory creates the objects properly
|
||||
//
|
||||
ObjectFactory factory;
|
||||
@@ -1336,11 +1389,13 @@ class CallbackValueTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
CallbackValueTestCase (std::string description);
|
||||
virtual ~CallbackValueTestCase () {}
|
||||
virtual ~CallbackValueTestCase ()
|
||||
{}
|
||||
|
||||
void InvokeCbValue (int8_t a)
|
||||
{
|
||||
if (!m_cbValue.IsNull ()) {
|
||||
if (!m_cbValue.IsNull ())
|
||||
{
|
||||
m_cbValue (a);
|
||||
}
|
||||
}
|
||||
@@ -1350,15 +1405,17 @@ private:
|
||||
|
||||
Callback<void,int8_t> m_cbValue;
|
||||
|
||||
void NotifyCallbackValue (int8_t a) { m_gotCbValue = a; }
|
||||
void NotifyCallbackValue (int8_t a)
|
||||
{
|
||||
m_gotCbValue = a;
|
||||
}
|
||||
|
||||
int16_t m_gotCbValue;
|
||||
};
|
||||
|
||||
CallbackValueTestCase::CallbackValueTestCase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CallbackValueTestCase::DoRun (void)
|
||||
@@ -1376,7 +1433,7 @@ CallbackValueTestCase::DoRun (void)
|
||||
//
|
||||
// NotifyCallbackValue is going to be the target of the callback and will just set
|
||||
// m_gotCbValue to its single parameter. This will be the parameter from the
|
||||
// callback invocation. The method InvokeCbValue() just invokes the m_cbValue
|
||||
// callback invocation. The method InvokeCbValue() just invokes the m_cbValue
|
||||
// callback if it is non-null.
|
||||
//
|
||||
m_gotCbValue = 1;
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup build-profile-tests
|
||||
@@ -47,7 +47,8 @@ class BuildProfileTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
BuildProfileTestCase ();
|
||||
virtual ~BuildProfileTestCase () {}
|
||||
virtual ~BuildProfileTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -55,8 +56,7 @@ private:
|
||||
|
||||
BuildProfileTestCase::BuildProfileTestCase (void)
|
||||
: TestCase ("Check build profile macros")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BuildProfileTestCase::DoRun (void)
|
||||
@@ -64,6 +64,7 @@ BuildProfileTestCase::DoRun (void)
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
#ifdef NS3_BUILD_PROFILE_DEBUG
|
||||
std::cout << GetName () << ": running in build profile debug" << std::endl;
|
||||
NS_BUILD_DEBUG (++i; ++j);
|
||||
@@ -76,13 +77,18 @@ BuildProfileTestCase::DoRun (void)
|
||||
#else
|
||||
NS_TEST_ASSERT_MSG_EQ (0, 1, ": no build profile case executed");
|
||||
#endif
|
||||
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
|
||||
if (i == 1)
|
||||
std::cout << "build profile executed first statement." << std::endl;
|
||||
{
|
||||
std::cout << "build profile executed first statement." << std::endl;
|
||||
}
|
||||
NS_TEST_ASSERT_MSG_EQ (i, 1,
|
||||
"build profile failed to execute first statement");
|
||||
if (j == 1)
|
||||
std::cout << "build profile executed second statement." << std::endl;
|
||||
{
|
||||
std::cout << "build profile executed second statement." << std::endl;
|
||||
}
|
||||
NS_TEST_ASSERT_MSG_EQ (j, 1,
|
||||
"build profile failed to execute second statement");
|
||||
}
|
||||
@@ -110,6 +116,6 @@ BuildProfileTestSuite::BuildProfileTestSuite ()
|
||||
static BuildProfileTestSuite g_BuildProfileTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -30,21 +30,29 @@ class BasicCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
BasicCallbackTestCase ();
|
||||
virtual ~BasicCallbackTestCase () {}
|
||||
virtual ~BasicCallbackTestCase ()
|
||||
{}
|
||||
|
||||
void Target1 (void) { m_test1 = true; }
|
||||
int Target2 (void) { m_test2 = true; return 2; }
|
||||
void Target3 (double a)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
m_test3 = true;
|
||||
void Target1 (void)
|
||||
{
|
||||
m_test1 = true;
|
||||
}
|
||||
int Target4 (double a, int b)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
NS_UNUSED (b);
|
||||
m_test4 = true;
|
||||
return 4;
|
||||
int Target2 (void)
|
||||
{
|
||||
m_test2 = true;
|
||||
return 2;
|
||||
}
|
||||
void Target3 (double a)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
m_test3 = true;
|
||||
}
|
||||
int Target4 (double a, int b)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
NS_UNUSED (b);
|
||||
m_test4 = true;
|
||||
return 4;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -61,19 +69,19 @@ static bool gBasicCallbackTest5;
|
||||
static bool gBasicCallbackTest6;
|
||||
static bool gBasicCallbackTest7;
|
||||
|
||||
void
|
||||
void
|
||||
BasicCallbackTarget5 (void)
|
||||
{
|
||||
gBasicCallbackTest5 = true;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
BasicCallbackTarget6 (int)
|
||||
{
|
||||
gBasicCallbackTest6 = true;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
BasicCallbackTarget7 (int a)
|
||||
{
|
||||
gBasicCallbackTest7 = true;
|
||||
@@ -82,8 +90,7 @@ BasicCallbackTarget7 (int a)
|
||||
|
||||
BasicCallbackTestCase::BasicCallbackTestCase ()
|
||||
: TestCase ("Check basic Callback mechansim")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BasicCallbackTestCase::DoSetup (void)
|
||||
@@ -101,7 +108,7 @@ void
|
||||
BasicCallbackTestCase::DoRun (void)
|
||||
{
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// function returning void and execute it.
|
||||
//
|
||||
Callback<void> target1 (this, &BasicCallbackTestCase::Target1);
|
||||
@@ -109,7 +116,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// function that returns an int and execute it.
|
||||
//
|
||||
Callback<int> target2;
|
||||
@@ -118,7 +125,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// function that returns void, takes a double parameter, and execute it.
|
||||
//
|
||||
Callback<void, double> target3 = Callback<void, double> (this, &BasicCallbackTestCase::Target3);
|
||||
@@ -126,7 +133,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// Make sure we can declare and compile a Callback pointing to a member
|
||||
// function that returns void, takes two parameters, and execute it.
|
||||
//
|
||||
Callback<int, double, int> target4 = Callback<int, double, int> (this, &BasicCallbackTestCase::Target4);
|
||||
@@ -134,7 +141,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// function that returns void, and execute it. This is a lower level call
|
||||
// than MakeCallback so we have got to include at least two arguments to make
|
||||
// sure that the constructor is properly disambiguated. If the arguments are
|
||||
@@ -145,7 +152,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest5, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// function that returns void, takes one integer argument and execute it.
|
||||
// We also need to provide two dummy arguments to the constructor here.
|
||||
//
|
||||
@@ -154,7 +161,7 @@ BasicCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest6, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// function that returns int, takes one integer argument and execute it.
|
||||
// We also need to provide two dummy arguments to the constructor here.
|
||||
//
|
||||
@@ -170,21 +177,29 @@ class MakeCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
MakeCallbackTestCase ();
|
||||
virtual ~MakeCallbackTestCase () {}
|
||||
virtual ~MakeCallbackTestCase ()
|
||||
{}
|
||||
|
||||
void Target1 (void) { m_test1 = true; }
|
||||
int Target2 (void) { m_test2 = true; return 2; }
|
||||
void Target3 (double a)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
m_test3 = true;
|
||||
void Target1 (void)
|
||||
{
|
||||
m_test1 = true;
|
||||
}
|
||||
int Target4 (double a, int b)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
NS_UNUSED (b);
|
||||
m_test4 = true;
|
||||
return 4;
|
||||
int Target2 (void)
|
||||
{
|
||||
m_test2 = true;
|
||||
return 2;
|
||||
}
|
||||
void Target3 (double a)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
m_test3 = true;
|
||||
}
|
||||
int Target4 (double a, int b)
|
||||
{
|
||||
NS_UNUSED (a);
|
||||
NS_UNUSED (b);
|
||||
m_test4 = true;
|
||||
return 4;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -201,19 +216,19 @@ static bool gMakeCallbackTest5;
|
||||
static bool gMakeCallbackTest6;
|
||||
static bool gMakeCallbackTest7;
|
||||
|
||||
void
|
||||
void
|
||||
MakeCallbackTarget5 (void)
|
||||
{
|
||||
gMakeCallbackTest5 = true;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
MakeCallbackTarget6 (int)
|
||||
{
|
||||
gMakeCallbackTest6 = true;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
MakeCallbackTarget7 (int a)
|
||||
{
|
||||
gMakeCallbackTest7 = true;
|
||||
@@ -222,8 +237,7 @@ MakeCallbackTarget7 (int a)
|
||||
|
||||
MakeCallbackTestCase::MakeCallbackTestCase ()
|
||||
: TestCase ("Check MakeCallback() mechanism")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
MakeCallbackTestCase::DoSetup (void)
|
||||
@@ -241,7 +255,7 @@ void
|
||||
MakeCallbackTestCase::DoRun (void)
|
||||
{
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// function returning void and execute it.
|
||||
//
|
||||
Callback<void> target1 = MakeCallback (&MakeCallbackTestCase::Target1, this);
|
||||
@@ -249,7 +263,7 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// function that returns an int and execute it.
|
||||
//
|
||||
Callback<int> target2 = MakeCallback (&MakeCallbackTestCase::Target2, this);
|
||||
@@ -257,7 +271,7 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// function that returns void, takes a double parameter, and execute it.
|
||||
//
|
||||
Callback<void, double> target3 = MakeCallback (&MakeCallbackTestCase::Target3, this);
|
||||
@@ -265,7 +279,7 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// function that returns void, takes two parameters, and execute it.
|
||||
//
|
||||
Callback<int, double, int> target4 = MakeCallback (&MakeCallbackTestCase::Target4, this);
|
||||
@@ -273,7 +287,7 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a non-member
|
||||
// Make sure we can declare and make a Callback pointing to a non-member
|
||||
// function that returns void, and execute it. This uses a higher level call
|
||||
// than in the basic tests so we do not need to include any dummy arguments
|
||||
// here.
|
||||
@@ -283,9 +297,9 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest5, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// function that returns void, takes one integer argument and execute it.
|
||||
// This uses a higher level call than in the basic tests so we do not need to
|
||||
// This uses a higher level call than in the basic tests so we do not need to
|
||||
// include any dummy arguments here.
|
||||
//
|
||||
Callback<void, int> target6 = MakeCallback (&MakeCallbackTarget6);
|
||||
@@ -293,9 +307,9 @@ MakeCallbackTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest6, true, "Callback did not fire");
|
||||
|
||||
//
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// Make sure we can declare and compile a Callback pointing to a non-member
|
||||
// function that returns int, takes one integer argument and execute it.
|
||||
// This uses a higher level call than in the basic tests so we do not need to
|
||||
// This uses a higher level call than in the basic tests so we do not need to
|
||||
// include any dummy arguments here.
|
||||
//
|
||||
Callback<int, int> target7 = MakeCallback (&MakeCallbackTarget7);
|
||||
@@ -310,7 +324,8 @@ class MakeBoundCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
MakeBoundCallbackTestCase ();
|
||||
virtual ~MakeBoundCallbackTestCase () {}
|
||||
virtual ~MakeBoundCallbackTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -340,13 +355,13 @@ static int gMakeBoundCallbackTest9b;
|
||||
static int gMakeBoundCallbackTest9c;
|
||||
static int gMakeBoundCallbackTest9d;
|
||||
|
||||
void
|
||||
void
|
||||
MakeBoundCallbackTarget1 (int a)
|
||||
{
|
||||
gMakeBoundCallbackTest1 = a;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
MakeBoundCallbackTarget2 (bool *a)
|
||||
{
|
||||
gMakeBoundCallbackTest2 = a;
|
||||
@@ -413,8 +428,7 @@ MakeBoundCallbackTarget9 (int a, int b, int c, int d)
|
||||
|
||||
MakeBoundCallbackTestCase::MakeBoundCallbackTestCase ()
|
||||
: TestCase ("Check MakeBoundCallback() mechanism")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
MakeBoundCallbackTestCase::DoSetup (void)
|
||||
@@ -450,18 +464,18 @@ MakeBoundCallbackTestCase::DoRun (void)
|
||||
// This is slightly tricky to explain. A bound Callback allows us to package
|
||||
// up arguments for use later. The arguments are bound when the callback is
|
||||
// created and the code that fires the Callback does not know they are there.
|
||||
//
|
||||
//
|
||||
// Since the callback is *declared* according to the way it will be used, the
|
||||
// arguments are not seen there. However, the target function of the callback
|
||||
// will have the provided arguments present. The MakeBoundCallback template
|
||||
// function is what connects the two together and where you provide the
|
||||
// function is what connects the two together and where you provide the
|
||||
// arguments to be bound.
|
||||
//
|
||||
// Here we declare a Callback that returns a void and takes no parameters.
|
||||
// MakeBoundCallback connects this Callback to a target function that returns
|
||||
// void and takes an integer argument. That integer argument is bound to the
|
||||
// void and takes an integer argument. That integer argument is bound to the
|
||||
// value 1234. When the Callback is fired, no integer argument is provided
|
||||
// directly. The argument is provided by bound Callback mechanism.
|
||||
// directly. The argument is provided by bound Callback mechanism.
|
||||
//
|
||||
Callback<void> target1 = MakeBoundCallback (&MakeBoundCallbackTarget1, 1234);
|
||||
target1 ();
|
||||
@@ -538,9 +552,13 @@ class NullifyCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
NullifyCallbackTestCase ();
|
||||
virtual ~NullifyCallbackTestCase () {}
|
||||
virtual ~NullifyCallbackTestCase ()
|
||||
{}
|
||||
|
||||
void Target1 (void) { m_test1 = true; }
|
||||
void Target1 (void)
|
||||
{
|
||||
m_test1 = true;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -551,8 +569,7 @@ private:
|
||||
|
||||
NullifyCallbackTestCase::NullifyCallbackTestCase ()
|
||||
: TestCase ("Check Nullify() and IsNull()")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
NullifyCallbackTestCase::DoSetup (void)
|
||||
@@ -564,7 +581,7 @@ void
|
||||
NullifyCallbackTestCase::DoRun (void)
|
||||
{
|
||||
//
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// Make sure we can declare and make a Callback pointing to a member
|
||||
// function returning void and execute it.
|
||||
//
|
||||
Callback<void> target1 = MakeCallback (&NullifyCallbackTestCase::Target1, this);
|
||||
@@ -586,9 +603,13 @@ class MakeCallbackTemplatesTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
MakeCallbackTemplatesTestCase ();
|
||||
virtual ~MakeCallbackTemplatesTestCase () {}
|
||||
virtual ~MakeCallbackTemplatesTestCase ()
|
||||
{}
|
||||
|
||||
void Target1 (void) { m_test1 = true; }
|
||||
void Target1 (void)
|
||||
{
|
||||
m_test1 = true;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -596,6 +617,7 @@ private:
|
||||
bool m_test1;
|
||||
};
|
||||
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
void TestFZero (void) {}
|
||||
void TestFOne (int) {}
|
||||
void TestFTwo (int, int) {}
|
||||
@@ -610,21 +632,29 @@ void TestFRThree (int &, int &, int &) {}
|
||||
void TestFRFour (int &, int &, int &, int &) {}
|
||||
void TestFRFive (int &, int &, int &, int &, int &) {}
|
||||
void TestFRSix (int &, int &, int &, int &, int &, int &) {}
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
|
||||
class CallbackTestParent
|
||||
{
|
||||
public:
|
||||
void PublicParent (void) {}
|
||||
void PublicParent (void)
|
||||
{}
|
||||
|
||||
protected:
|
||||
void ProtectedParent (void) {}
|
||||
static void StaticProtectedParent (void) {}
|
||||
void ProtectedParent (void)
|
||||
{}
|
||||
static void StaticProtectedParent (void)
|
||||
{}
|
||||
|
||||
private:
|
||||
void PrivateParent (void) {}
|
||||
void PrivateParent (void)
|
||||
{}
|
||||
};
|
||||
|
||||
class CallbackTestClass : public CallbackTestParent
|
||||
{
|
||||
public:
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
void TestZero (void) {}
|
||||
void TestOne (int) {}
|
||||
void TestTwo (int, int) {}
|
||||
@@ -639,6 +669,7 @@ public:
|
||||
void TestCFour (int, int, int, int) const {}
|
||||
void TestCFive (int, int, int, int, int) const {}
|
||||
void TestCSix (int, int, int, int, int, int) const {}
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
|
||||
void CheckParentalRights (void)
|
||||
{
|
||||
@@ -655,8 +686,7 @@ public:
|
||||
|
||||
MakeCallbackTemplatesTestCase::MakeCallbackTemplatesTestCase ()
|
||||
: TestCase ("Check various MakeCallback() template functions")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
MakeCallbackTemplatesTestCase::DoRun (void)
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup commandline-tests
|
||||
@@ -61,7 +61,8 @@ public:
|
||||
*/
|
||||
CommandLineTestCaseBase (std::string description);
|
||||
/** Destructor */
|
||||
virtual ~CommandLineTestCaseBase () {}
|
||||
virtual ~CommandLineTestCaseBase ()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Exercise the CommandLine with the provided arguments
|
||||
@@ -79,8 +80,7 @@ int CommandLineTestCaseBase::m_count = 0;
|
||||
|
||||
CommandLineTestCaseBase::CommandLineTestCaseBase (std::string description)
|
||||
: TestCase (description)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineTestCaseBase::Parse (CommandLine &cmd, int n, ...)
|
||||
@@ -88,14 +88,14 @@ CommandLineTestCaseBase::Parse (CommandLine &cmd, int n, ...)
|
||||
std::stringstream ss;
|
||||
ss << GetParent ()->GetName () << "-testcase-" << m_count << "-" << GetName ();
|
||||
++m_count;
|
||||
|
||||
|
||||
int argc = n + 1; // test name will go in argv[0], other n to follow
|
||||
char ** argv = new char* [argc + 1]; // extra entry for final null
|
||||
argv[argc] = 0;
|
||||
|
||||
argv[0] = new char [strlen (ss.str ().c_str ()) + 1];
|
||||
strcpy (argv[0], ss.str ().c_str ());
|
||||
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, n);
|
||||
for (int i = 1; i < argc; ++i)
|
||||
@@ -124,7 +124,9 @@ class CommandLineBooleanTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineBooleanTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineBooleanTestCase () {} /**< Destructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineBooleanTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
@@ -133,8 +135,7 @@ private:
|
||||
|
||||
CommandLineBooleanTestCase::CommandLineBooleanTestCase ()
|
||||
: CommandLineTestCaseBase ("boolean")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineBooleanTestCase::DoRun (void)
|
||||
@@ -172,18 +173,19 @@ CommandLineBooleanTestCase::DoRun (void)
|
||||
class CommandLineIntTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineIntTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineIntTestCase () {} /**< Destructor */
|
||||
|
||||
private:
|
||||
CommandLineIntTestCase (); /**< Constructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineIntTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
|
||||
};
|
||||
|
||||
CommandLineIntTestCase::CommandLineIntTestCase ()
|
||||
: CommandLineTestCaseBase ("int")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineIntTestCase::DoRun (void)
|
||||
@@ -211,18 +213,18 @@ CommandLineIntTestCase::DoRun (void)
|
||||
class CommandLineUnsignedIntTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineUnsignedIntTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineUnsignedIntTestCase () {} /**< Destructor */
|
||||
|
||||
private:
|
||||
CommandLineUnsignedIntTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineUnsignedIntTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
|
||||
};
|
||||
|
||||
CommandLineUnsignedIntTestCase::CommandLineUnsignedIntTestCase ()
|
||||
: CommandLineTestCaseBase ("unsigned-int")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineUnsignedIntTestCase::DoRun (void)
|
||||
@@ -247,18 +249,19 @@ CommandLineUnsignedIntTestCase::DoRun (void)
|
||||
class CommandLineStringTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineStringTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineStringTestCase () {} /**< Destructor */
|
||||
|
||||
private:
|
||||
CommandLineStringTestCase (); /**< Constructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineStringTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
|
||||
};
|
||||
|
||||
CommandLineStringTestCase::CommandLineStringTestCase ()
|
||||
: CommandLineTestCaseBase ("string")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineStringTestCase::DoRun (void)
|
||||
@@ -284,7 +287,9 @@ class CommandLineOrderTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineOrderTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineOrderTestCase () {} /**< Destructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineOrderTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
@@ -293,8 +298,7 @@ private:
|
||||
|
||||
CommandLineOrderTestCase::CommandLineOrderTestCase ()
|
||||
: CommandLineTestCaseBase ("order")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineOrderTestCase::DoRun (void)
|
||||
@@ -317,7 +321,9 @@ class CommandLineInvalidTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineInvalidTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineInvalidTestCase () {} /**< Destructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineInvalidTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
@@ -326,8 +332,7 @@ private:
|
||||
|
||||
CommandLineInvalidTestCase::CommandLineInvalidTestCase ()
|
||||
: CommandLineTestCaseBase ("invalid")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineInvalidTestCase::DoRun (void)
|
||||
@@ -350,7 +355,9 @@ class CommandLineNonOptionTestCase : public CommandLineTestCaseBase
|
||||
{
|
||||
public:
|
||||
CommandLineNonOptionTestCase (); /**< Constructor */
|
||||
virtual ~CommandLineNonOptionTestCase () {} /**< Destructor */
|
||||
/** Destructor */
|
||||
virtual ~CommandLineNonOptionTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void); /**< Run the test */
|
||||
@@ -359,8 +366,7 @@ private:
|
||||
|
||||
CommandLineNonOptionTestCase::CommandLineNonOptionTestCase ()
|
||||
: CommandLineTestCaseBase ("nonoption")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CommandLineNonOptionTestCase::DoRun (void)
|
||||
@@ -381,10 +387,10 @@ CommandLineNonOptionTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (myStr, "MyStr", "CommandLine did not leave a non-option unmodified.");
|
||||
|
||||
Parse (cmd, 5, "false", "6", "newValue", "extraVal1", "extraVal2");
|
||||
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (myBool, false, "CommandLine did not correctly set a boolean non-option");
|
||||
NS_TEST_ASSERT_MSG_EQ (myInt
|
||||
, 6, "CommandLine did not correctly set an integer non-option value to 5");
|
||||
, 6, "CommandLine did not correctly set an integer non-option value to 5");
|
||||
NS_TEST_ASSERT_MSG_EQ (myStr, "newValue", "CommandLine did not leave a non-option unmodified.");
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (cmd.GetNExtraNonOptions (), 2, "CommandLine did not parse the correct number of extra non-options.");
|
||||
@@ -421,7 +427,7 @@ CommandLineTestSuite::CommandLineTestSuite ()
|
||||
static CommandLineTestSuite g_commandLineTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup config-tests
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
* \param a test object a
|
||||
*/
|
||||
void AddNodeA (Ptr<ConfigTestObject> a);
|
||||
/**
|
||||
/**
|
||||
* Add node B function
|
||||
* \param b test object b
|
||||
*/
|
||||
@@ -161,25 +161,25 @@ ConfigTestObject::SetNodeB (Ptr<ConfigTestObject> b)
|
||||
m_nodeB = b;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ConfigTestObject::AddNodeA (Ptr<ConfigTestObject> a)
|
||||
{
|
||||
m_nodesA.push_back (a);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ConfigTestObject::AddNodeB (Ptr<ConfigTestObject> b)
|
||||
{
|
||||
m_nodesB.push_back (b);
|
||||
}
|
||||
|
||||
int8_t
|
||||
int8_t
|
||||
ConfigTestObject::GetA (void) const
|
||||
{
|
||||
return m_a;
|
||||
}
|
||||
|
||||
int8_t
|
||||
int8_t
|
||||
ConfigTestObject::GetB (void) const
|
||||
{
|
||||
return m_b;
|
||||
@@ -198,9 +198,11 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
/** Constructor. */
|
||||
DerivedConfigTestObject (void) {}
|
||||
DerivedConfigTestObject (void)
|
||||
{}
|
||||
/** Destructor */
|
||||
virtual ~DerivedConfigTestObject (void) {}
|
||||
virtual ~DerivedConfigTestObject (void)
|
||||
{}
|
||||
};
|
||||
|
||||
TypeId
|
||||
@@ -208,7 +210,7 @@ DerivedConfigTestObject::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("DerivedConfigTestObject")
|
||||
.SetParent<ConfigTestObject> ()
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -225,13 +227,19 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
/** Constructor. */
|
||||
BaseConfigObject (void) : m_x(15) {}
|
||||
BaseConfigObject (void) : m_x (15)
|
||||
{}
|
||||
/** Destructor. */
|
||||
virtual ~BaseConfigObject (void) {}
|
||||
virtual ~BaseConfigObject (void)
|
||||
{}
|
||||
|
||||
private:
|
||||
int8_t m_x; //!< X attribute target.
|
||||
/** Silence unused variable warning. */
|
||||
void Increment (void) { m_x++; }
|
||||
void Increment (void)
|
||||
{
|
||||
m_x++;
|
||||
}
|
||||
};
|
||||
|
||||
TypeId
|
||||
@@ -243,7 +251,7 @@ BaseConfigObject::GetTypeId (void)
|
||||
IntegerValue (10),
|
||||
MakeIntegerAccessor (&BaseConfigObject::m_x),
|
||||
MakeIntegerChecker<int8_t> ())
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -260,9 +268,11 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
/** Constructor. */
|
||||
DerivedConfigObject (void) {}
|
||||
DerivedConfigObject (void)
|
||||
{}
|
||||
/** Destructor. */
|
||||
virtual ~DerivedConfigObject (void) {}
|
||||
virtual ~DerivedConfigObject (void)
|
||||
{}
|
||||
};
|
||||
|
||||
TypeId
|
||||
@@ -270,7 +280,7 @@ DerivedConfigObject::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("DerivedConfigObject")
|
||||
.SetParent<BaseConfigObject> ()
|
||||
;
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -285,7 +295,8 @@ public:
|
||||
/** Constructor. */
|
||||
RootNamespaceConfigTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~RootNamespaceConfigTestCase () {}
|
||||
virtual ~RootNamespaceConfigTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -293,15 +304,14 @@ private:
|
||||
|
||||
RootNamespaceConfigTestCase::RootNamespaceConfigTestCase ()
|
||||
: TestCase ("Check ability to register a root namespace and use it")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RootNamespaceConfigTestCase::DoRun (void)
|
||||
{
|
||||
IntegerValue iv;
|
||||
//
|
||||
// Create an object and register its attributes directly in the root
|
||||
// Create an object and register its attributes directly in the root
|
||||
// namespace.
|
||||
//
|
||||
Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
|
||||
@@ -346,7 +356,8 @@ public:
|
||||
/** Constructor. */
|
||||
UnderRootNamespaceConfigTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~UnderRootNamespaceConfigTestCase () {}
|
||||
virtual ~UnderRootNamespaceConfigTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -354,15 +365,14 @@ private:
|
||||
|
||||
UnderRootNamespaceConfigTestCase::UnderRootNamespaceConfigTestCase ()
|
||||
: TestCase ("Check ability to register an object under the root namespace and use it")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
UnderRootNamespaceConfigTestCase::DoRun (void)
|
||||
{
|
||||
IntegerValue iv;
|
||||
//
|
||||
// Create an object and register its attributes directly in the root
|
||||
// Create an object and register its attributes directly in the root
|
||||
// namespace.
|
||||
//
|
||||
Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
|
||||
@@ -458,7 +468,8 @@ public:
|
||||
/** Constructor. */
|
||||
ObjectVectorConfigTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~ObjectVectorConfigTestCase () {}
|
||||
virtual ~ObjectVectorConfigTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -466,8 +477,7 @@ private:
|
||||
|
||||
ObjectVectorConfigTestCase::ObjectVectorConfigTestCase ()
|
||||
: TestCase ("Check ability to configure vectors of Object using regular expressions")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ObjectVectorConfigTestCase::DoRun (void)
|
||||
@@ -493,7 +503,7 @@ ObjectVectorConfigTestCase::DoRun (void)
|
||||
a->SetNodeB (b);
|
||||
|
||||
//
|
||||
// Add four objects to the ObjectVector Attribute at the bottom of the
|
||||
// Add four objects to the ObjectVector Attribute at the bottom of the
|
||||
// object hierarchy. By this point, we believe that the Attributes
|
||||
// will be initialized correctly.
|
||||
//
|
||||
@@ -615,17 +625,18 @@ public:
|
||||
/** Constructor. */
|
||||
ObjectVectorTraceConfigTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~ObjectVectorTraceConfigTestCase () {}
|
||||
virtual ~ObjectVectorTraceConfigTestCase ()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Trace callback without context.
|
||||
* \param oldValue The old value.
|
||||
* \param newValue The new value.
|
||||
*/
|
||||
void Trace (int16_t oldValue, int16_t newValue)
|
||||
{
|
||||
NS_UNUSED (oldValue);
|
||||
m_newValue = newValue;
|
||||
void Trace (int16_t oldValue, int16_t newValue)
|
||||
{
|
||||
NS_UNUSED (oldValue);
|
||||
m_newValue = newValue;
|
||||
}
|
||||
/**
|
||||
* Trace callback with context path.
|
||||
@@ -634,10 +645,10 @@ public:
|
||||
* \param newValue The new value.
|
||||
*/
|
||||
void TraceWithPath (std::string path, int16_t old, int16_t newValue)
|
||||
{
|
||||
NS_UNUSED (old);
|
||||
m_newValue = newValue;
|
||||
m_path = path;
|
||||
{
|
||||
NS_UNUSED (old);
|
||||
m_newValue = newValue;
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -649,8 +660,7 @@ private:
|
||||
|
||||
ObjectVectorTraceConfigTestCase::ObjectVectorTraceConfigTestCase ()
|
||||
: TestCase ("Check ability to trace connect through vectors of Object using regular expressions")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
@@ -676,7 +686,7 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
a->SetNodeB (b);
|
||||
|
||||
//
|
||||
// Add four objects to the ObjectVector Attribute at the bottom of the
|
||||
// Add four objects to the ObjectVector Attribute at the bottom of the
|
||||
// object hierarchy. By this point, we believe that the Attributes
|
||||
// will be initialized correctly.
|
||||
//
|
||||
@@ -691,29 +701,29 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
|
||||
//
|
||||
// Do a trace connect to some of the sources. We already checked parsing of
|
||||
// the regular expressions, so we'll concentrate on the tracing part of the
|
||||
// the regular expressions, so we'll concentrate on the tracing part of the
|
||||
// puzzle here.
|
||||
//
|
||||
Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ObjectVectorTraceConfigTestCase::Trace, this));
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '0' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '0' above, we should see
|
||||
// the trace fire.
|
||||
//
|
||||
m_newValue = 0;
|
||||
obj0->SetAttribute ("Source", IntegerValue (-1));
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '1' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '1' above, we should see
|
||||
// the trace fire.
|
||||
//
|
||||
m_newValue = 0;
|
||||
obj1->SetAttribute ("Source", IntegerValue (-2));
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
|
||||
|
||||
//
|
||||
//
|
||||
// If we bug the trace source referred to by index '2' which is skipped above,
|
||||
// we should not see the trace fire.
|
||||
//
|
||||
@@ -721,8 +731,8 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
obj2->SetAttribute ("Source", IntegerValue (-3));
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '3' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '3' above, we should see
|
||||
// the trace fire.
|
||||
//
|
||||
m_newValue = 0;
|
||||
@@ -732,11 +742,11 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
//
|
||||
// Do a trace connect (with context) to some of the sources.
|
||||
//
|
||||
Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
|
||||
MakeCallback (&ObjectVectorTraceConfigTestCase::TraceWithPath, this));
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '0' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '0' above, we should see
|
||||
// the trace fire with the expected context path.
|
||||
//
|
||||
m_newValue = 0;
|
||||
@@ -745,8 +755,8 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/0/Source", "Trace 0 did not provide expected context");
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '1' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '1' above, we should see
|
||||
// the trace fire with the expected context path.
|
||||
//
|
||||
m_newValue = 0;
|
||||
@@ -755,7 +765,7 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
|
||||
|
||||
//
|
||||
//
|
||||
// If we bug the trace source referred to by index '2' which is skipped above,
|
||||
// we should not see the trace fire.
|
||||
//
|
||||
@@ -764,8 +774,8 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
|
||||
obj2->SetAttribute ("Source", IntegerValue (-3));
|
||||
NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
|
||||
|
||||
//
|
||||
// If we bug the trace source referred to by index '3' above, we should see
|
||||
//
|
||||
// If we bug the trace source referred to by index '3' above, we should see
|
||||
// the trace fire with the expected context path.
|
||||
//
|
||||
m_newValue = 0;
|
||||
@@ -789,7 +799,8 @@ public:
|
||||
/** Constructor. */
|
||||
SearchAttributesOfParentObjectsTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~SearchAttributesOfParentObjectsTestCase () {}
|
||||
virtual ~SearchAttributesOfParentObjectsTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -798,8 +809,7 @@ private:
|
||||
|
||||
SearchAttributesOfParentObjectsTestCase::SearchAttributesOfParentObjectsTestCase ()
|
||||
: TestCase ("Check that attributes of base class are searchable from paths including objects of derived class")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
SearchAttributesOfParentObjectsTestCase::DoRun (void)
|
||||
@@ -819,7 +829,7 @@ SearchAttributesOfParentObjectsTestCase::DoRun (void)
|
||||
root->SetNodeA (a);
|
||||
|
||||
//
|
||||
// BaseConfigObject has attribute X, but we aggregate DerivedConfigObject
|
||||
// BaseConfigObject has attribute X, but we aggregate DerivedConfigObject
|
||||
// instead
|
||||
//
|
||||
Ptr<DerivedConfigObject> derived = CreateObject<DerivedConfigObject> ();
|
||||
@@ -857,7 +867,7 @@ ConfigTestSuite::ConfigTestSuite ()
|
||||
static ConfigTestSuite g_configTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup event-garbage-tests
|
||||
@@ -62,12 +62,10 @@ public:
|
||||
|
||||
EventGarbageCollectorTestCase::EventGarbageCollectorTestCase ()
|
||||
: TestCase ("EventGarbageCollector"), m_counter (0), m_events (0)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
EventGarbageCollectorTestCase::~EventGarbageCollectorTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
EventGarbageCollectorTestCase::EventGarbageCollectorCallback ()
|
||||
@@ -106,7 +104,7 @@ class EventGarbageCollectorTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
EventGarbageCollectorTestSuite ()
|
||||
: TestSuite ("event-garbage-collector")
|
||||
: TestSuite ("event-garbage-collector")
|
||||
{
|
||||
AddTestCase (new EventGarbageCollectorTestCase ());
|
||||
}
|
||||
@@ -119,7 +117,7 @@ public:
|
||||
static EventGarbageCollectorTestSuite g_eventGarbageCollectorTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup global-value-tests
|
||||
@@ -49,7 +49,8 @@ public:
|
||||
/** Constructor. */
|
||||
GlobalValueTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~GlobalValueTestCase () {}
|
||||
virtual ~GlobalValueTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -57,14 +58,13 @@ private:
|
||||
|
||||
GlobalValueTestCase::GlobalValueTestCase ()
|
||||
: TestCase ("Check GlobalValue mechanism")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
GlobalValueTestCase::DoRun (void)
|
||||
{
|
||||
//
|
||||
// Typically these are static globals but we can make one on the stack to
|
||||
// Typically these are static globals but we can make one on the stack to
|
||||
// keep it hidden from the documentation.
|
||||
//
|
||||
GlobalValue uint = GlobalValue ("TestUint", "help text",
|
||||
@@ -116,7 +116,7 @@ GlobalValueTestSuite::GlobalValueTestSuite ()
|
||||
static GlobalValueTestSuite g_globalValueTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup hash-tests
|
||||
@@ -54,10 +54,11 @@ public:
|
||||
* Constructor
|
||||
*
|
||||
* \param [in] name reference name
|
||||
*/
|
||||
*/
|
||||
HashTestCase (const std::string name);
|
||||
/** Destructor. */
|
||||
virtual ~HashTestCase ();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Check function
|
||||
@@ -71,7 +72,7 @@ protected:
|
||||
* \param [in] hash the hash value
|
||||
*/
|
||||
void Check ( const std::string hashName, const uint64_t hash);
|
||||
|
||||
|
||||
std::string key; //!< The reference value to hash.
|
||||
uint32_t hash32Reference; //!< The 32-bit hash of the reference.
|
||||
uint64_t hash64Reference; //!< The 64-bit hash of the reference.
|
||||
@@ -91,12 +92,10 @@ private:
|
||||
HashTestCase::HashTestCase (const std::string name)
|
||||
: TestCase (name),
|
||||
key ("The quick brown fox jumped over the lazy dogs.")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
HashTestCase::~HashTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
HashTestCase::Check ( const std::string hashName, const uint32_t hash)
|
||||
@@ -135,9 +134,9 @@ HashTestCase::Check ( std::string hashName, int bits, uint64_t hash)
|
||||
<< bits << "-bit result...";
|
||||
NS_TEST_EXPECT_MSG_EQ (hash, hashRef,
|
||||
hashName << " " << type
|
||||
<< " produced " << std::hex << std::setw (w) << hash
|
||||
<< ", expected " << std::hex << std::setw (w) << hashRef
|
||||
<< std::dec
|
||||
<< " produced " << std::hex << std::setw (w) << hash
|
||||
<< ", expected " << std::hex << std::setw (w) << hashRef
|
||||
<< std::dec
|
||||
);
|
||||
std::cout << std::hex << std::setw (w) << hash << ", ok"
|
||||
<< std::dec << std::endl;
|
||||
@@ -145,8 +144,7 @@ HashTestCase::Check ( std::string hashName, int bits, uint64_t hash)
|
||||
|
||||
void
|
||||
HashTestCase::DoRun (void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@@ -160,18 +158,17 @@ public:
|
||||
DefaultHashTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~DefaultHashTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
DefaultHashTestCase::DefaultHashTestCase ()
|
||||
: HashTestCase ("DefaultHash: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
DefaultHashTestCase::~DefaultHashTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
DefaultHashTestCase::DoRun (void)
|
||||
@@ -197,18 +194,17 @@ public:
|
||||
Fnv1aTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~Fnv1aTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
Fnv1aTestCase::Fnv1aTestCase ()
|
||||
: HashTestCase ("Fnv1a: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Fnv1aTestCase::~Fnv1aTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
Fnv1aTestCase::DoRun (void)
|
||||
@@ -233,18 +229,17 @@ public:
|
||||
Murmur3TestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~Murmur3TestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
Murmur3TestCase::Murmur3TestCase ()
|
||||
: HashTestCase ("Murmur3: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Murmur3TestCase::~Murmur3TestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
Murmur3TestCase::DoRun (void)
|
||||
@@ -270,7 +265,7 @@ Murmur3TestCase::DoRun (void)
|
||||
* \param [in,out] buffer The data to hash.
|
||||
* \param [in] size The buffer size.
|
||||
* \returns The checksum of the buffer contents.
|
||||
*/
|
||||
*/
|
||||
uint16_t
|
||||
gnu_sum (const char * buffer, const std::size_t size)
|
||||
{
|
||||
@@ -322,18 +317,17 @@ public:
|
||||
Hash32FunctionPtrTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~Hash32FunctionPtrTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
Hash32FunctionPtrTestCase::Hash32FunctionPtrTestCase ()
|
||||
: HashTestCase ("Hash32FunctionPtr: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Hash32FunctionPtrTestCase::~Hash32FunctionPtrTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
Hash32FunctionPtrTestCase::DoRun (void)
|
||||
@@ -354,18 +348,17 @@ public:
|
||||
Hash64FunctionPtrTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~Hash64FunctionPtrTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
Hash64FunctionPtrTestCase::Hash64FunctionPtrTestCase ()
|
||||
: HashTestCase ("Hash64FunctionPtr: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Hash64FunctionPtrTestCase::~Hash64FunctionPtrTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
Hash64FunctionPtrTestCase::DoRun (void)
|
||||
@@ -378,7 +371,7 @@ Hash64FunctionPtrTestCase::DoRun (void)
|
||||
/**
|
||||
* \ingroup hash-tests
|
||||
* Test incremental hashing
|
||||
*/
|
||||
*/
|
||||
class IncrementalTestCase : public HashTestCase
|
||||
{
|
||||
public:
|
||||
@@ -386,6 +379,7 @@ public:
|
||||
IncrementalTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~IncrementalTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
/**
|
||||
@@ -401,12 +395,10 @@ private:
|
||||
|
||||
IncrementalTestCase::IncrementalTestCase ()
|
||||
: HashTestCase ("Incremental: ")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
IncrementalTestCase::~IncrementalTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
IncrementalTestCase::DoHash (const std::string name, Hasher hasher)
|
||||
@@ -468,6 +460,6 @@ HashTestSuite::HashTestSuite ()
|
||||
static HashTestSuite g_hashTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,8 +35,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup randomvariable-tests
|
||||
@@ -56,12 +56,10 @@ private:
|
||||
|
||||
ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase ()
|
||||
: TestCase ("Many Uniform Random Variables with One GetValue() Call")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun (void)
|
||||
@@ -110,6 +108,6 @@ ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOn
|
||||
static ManyUniformRandomVariablesOneGetValueCallTestSuite g_manyUniformRandomVariablesOneGetValueCallTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
* Register this type.
|
||||
* \return The TypeId.
|
||||
*/
|
||||
static TypeId GetTypeId (void)
|
||||
static TypeId GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("TestObject")
|
||||
.SetParent<Object> ()
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
TestObject () {}
|
||||
TestObject ()
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
* Register this type.
|
||||
* \return The TypeId.
|
||||
*/
|
||||
static TypeId GetTypeId (void)
|
||||
static TypeId GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("AlternateTestObject")
|
||||
.SetParent<Object> ()
|
||||
@@ -81,14 +82,15 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
AlternateTestObject () {}
|
||||
AlternateTestObject ()
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can do its most basic job.
|
||||
*
|
||||
* Add associations between Objects using the lowest level add
|
||||
* Add associations between Objects using the lowest level add
|
||||
* function, which is:
|
||||
*
|
||||
* Add (Ptr<Object> context, std::string name, Ptr<Object> object);
|
||||
@@ -111,12 +113,10 @@ private:
|
||||
|
||||
BasicAddTestCase::BasicAddTestCase ()
|
||||
: TestCase ("Check low level Names::Add and Names::FindName functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
BasicAddTestCase::~BasicAddTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BasicAddTestCase::DoTeardown (void)
|
||||
@@ -160,7 +160,7 @@ BasicAddTestCase::DoRun (void)
|
||||
*
|
||||
* Add (std::string context, std::string name, Ptr<Object> object);
|
||||
*
|
||||
* High level path-based functions will translate into this form, so this is
|
||||
* High level path-based functions will translate into this form, so this is
|
||||
* the second most basic Add functionality.
|
||||
*/
|
||||
class StringContextAddTestCase : public TestCase
|
||||
@@ -179,12 +179,10 @@ private:
|
||||
StringContextAddTestCase::StringContextAddTestCase ()
|
||||
: TestCase ("Check string context Names::Add and Names::FindName functionality")
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
StringContextAddTestCase::~StringContextAddTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
StringContextAddTestCase::DoTeardown (void)
|
||||
@@ -224,11 +222,11 @@ StringContextAddTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can correctly use a
|
||||
* Test the Object Name Service can correctly use a
|
||||
* fully qualified path to add associations.
|
||||
*
|
||||
* Add (std::string name, Ptr<Object> object);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class FullyQualifiedAddTestCase : public TestCase
|
||||
{
|
||||
@@ -246,12 +244,10 @@ private:
|
||||
FullyQualifiedAddTestCase::FullyQualifiedAddTestCase ()
|
||||
: TestCase ("Check fully qualified path Names::Add and Names::FindName functionality")
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
FullyQualifiedAddTestCase::~FullyQualifiedAddTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
FullyQualifiedAddTestCase::DoTeardown (void)
|
||||
@@ -299,7 +295,7 @@ FullyQualifiedAddTestCase::DoRun (void)
|
||||
* in all of their strings.
|
||||
*
|
||||
* Add (std::string name, Ptr<Object> object);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class RelativeAddTestCase : public TestCase
|
||||
{
|
||||
@@ -317,12 +313,10 @@ private:
|
||||
RelativeAddTestCase::RelativeAddTestCase ()
|
||||
: TestCase ("Check relative path Names::Add and Names::FindName functionality")
|
||||
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RelativeAddTestCase::~RelativeAddTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RelativeAddTestCase::DoTeardown (void)
|
||||
@@ -384,12 +378,10 @@ private:
|
||||
|
||||
BasicRenameTestCase::BasicRenameTestCase ()
|
||||
: TestCase ("Check low level Names::Rename functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
BasicRenameTestCase::~BasicRenameTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BasicRenameTestCase::DoTeardown (void)
|
||||
@@ -427,11 +419,11 @@ BasicRenameTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can rename objects
|
||||
* Test the Object Name Service can rename objects
|
||||
* using a string context.
|
||||
*
|
||||
* Rename (std::string context, std::string oldname, std::string newname);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class StringContextRenameTestCase : public TestCase
|
||||
{
|
||||
@@ -448,12 +440,10 @@ private:
|
||||
|
||||
StringContextRenameTestCase::StringContextRenameTestCase ()
|
||||
: TestCase ("Check string context-based Names::Rename functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
StringContextRenameTestCase::~StringContextRenameTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
StringContextRenameTestCase::DoTeardown (void)
|
||||
@@ -491,11 +481,11 @@ StringContextRenameTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can rename objects
|
||||
* Test the Object Name Service can rename objects
|
||||
* using a fully qualified path name.
|
||||
*
|
||||
* Rename (std::string oldpath, std::string newname);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class FullyQualifiedRenameTestCase : public TestCase
|
||||
{
|
||||
@@ -512,12 +502,10 @@ private:
|
||||
|
||||
FullyQualifiedRenameTestCase::FullyQualifiedRenameTestCase ()
|
||||
: TestCase ("Check fully qualified path Names::Rename functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
FullyQualifiedRenameTestCase::~FullyQualifiedRenameTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
FullyQualifiedRenameTestCase::DoTeardown (void)
|
||||
@@ -555,11 +543,11 @@ FullyQualifiedRenameTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can rename objects
|
||||
* Test the Object Name Service can rename objects
|
||||
* using a relative path name.
|
||||
*
|
||||
* Rename (std::string oldpath, std::string newname);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class RelativeRenameTestCase : public TestCase
|
||||
{
|
||||
@@ -576,12 +564,10 @@ private:
|
||||
|
||||
RelativeRenameTestCase::RelativeRenameTestCase ()
|
||||
: TestCase ("Check relative path Names::Rename functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RelativeRenameTestCase::~RelativeRenameTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RelativeRenameTestCase::DoTeardown (void)
|
||||
@@ -623,7 +609,7 @@ RelativeRenameTestCase::DoRun (void)
|
||||
* and return its fully qualified path name.
|
||||
*
|
||||
* FindPath (Ptr<Object> object);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class FindPathTestCase : public TestCase
|
||||
{
|
||||
@@ -640,12 +626,10 @@ private:
|
||||
|
||||
FindPathTestCase::FindPathTestCase ()
|
||||
: TestCase ("Check Names::FindPath functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
FindPathTestCase::~FindPathTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
FindPathTestCase::DoTeardown (void)
|
||||
@@ -680,7 +664,7 @@ FindPathTestCase::DoRun (void)
|
||||
* Test the Object Name Service can find Objects.
|
||||
*
|
||||
* Find (Ptr<Object> context, std::string name);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class BasicFindTestCase : public TestCase
|
||||
{
|
||||
@@ -697,12 +681,10 @@ private:
|
||||
|
||||
BasicFindTestCase::BasicFindTestCase ()
|
||||
: TestCase ("Check low level Names::Find functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
BasicFindTestCase::~BasicFindTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BasicFindTestCase::DoTeardown (void)
|
||||
@@ -742,11 +724,11 @@ BasicFindTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can find Objects using
|
||||
* Test the Object Name Service can find Objects using
|
||||
* a string context.
|
||||
*
|
||||
* Find (std::string context, std::string name);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class StringContextFindTestCase : public TestCase
|
||||
{
|
||||
@@ -763,12 +745,10 @@ private:
|
||||
|
||||
StringContextFindTestCase::StringContextFindTestCase ()
|
||||
: TestCase ("Check string context-based Names::Find functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
StringContextFindTestCase::~StringContextFindTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
StringContextFindTestCase::DoTeardown (void)
|
||||
@@ -808,11 +788,11 @@ StringContextFindTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can find Objects using
|
||||
* Test the Object Name Service can find Objects using
|
||||
* a fully qualified path name.
|
||||
*
|
||||
* Find (std::string name);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class FullyQualifiedFindTestCase : public TestCase
|
||||
{
|
||||
@@ -829,12 +809,10 @@ private:
|
||||
|
||||
FullyQualifiedFindTestCase::FullyQualifiedFindTestCase ()
|
||||
: TestCase ("Check fully qualified path Names::Find functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
FullyQualifiedFindTestCase::~FullyQualifiedFindTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
FullyQualifiedFindTestCase::DoTeardown (void)
|
||||
@@ -874,11 +852,11 @@ FullyQualifiedFindTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can find Objects using
|
||||
* Test the Object Name Service can find Objects using
|
||||
* a relative path name.
|
||||
*
|
||||
* Find (std::string name);
|
||||
*
|
||||
*
|
||||
*/
|
||||
class RelativeFindTestCase : public TestCase
|
||||
{
|
||||
@@ -895,12 +873,10 @@ private:
|
||||
|
||||
RelativeFindTestCase::RelativeFindTestCase ()
|
||||
: TestCase ("Check relative path Names::Find functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RelativeFindTestCase::~RelativeFindTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RelativeFindTestCase::DoTeardown (void)
|
||||
@@ -940,7 +916,7 @@ RelativeFindTestCase::DoRun (void)
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Test the Object Name Service can find Objects using
|
||||
* Test the Object Name Service can find Objects using
|
||||
* a second type.
|
||||
*/
|
||||
class AlternateFindTestCase : public TestCase
|
||||
@@ -958,12 +934,10 @@ private:
|
||||
|
||||
AlternateFindTestCase::AlternateFindTestCase ()
|
||||
: TestCase ("Check GetObject operation in Names::Find")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
AlternateFindTestCase::~AlternateFindTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
AlternateFindTestCase::DoTeardown (void)
|
||||
@@ -984,26 +958,26 @@ AlternateFindTestCase::DoRun (void)
|
||||
Ptr<AlternateTestObject> foundAlternateTestObject;
|
||||
|
||||
foundTestObject = Names::Find<TestObject> ("Test Object");
|
||||
NS_TEST_ASSERT_MSG_EQ (foundTestObject, testObject,
|
||||
NS_TEST_ASSERT_MSG_EQ (foundTestObject, testObject,
|
||||
"Could not find a previously named TestObject via GetObject");
|
||||
|
||||
foundAlternateTestObject = Names::Find<AlternateTestObject> ("Alternate Test Object");
|
||||
NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, alternateTestObject,
|
||||
NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, alternateTestObject,
|
||||
"Could not find a previously named AlternateTestObject via GetObject");
|
||||
|
||||
|
||||
foundAlternateTestObject = Names::Find<AlternateTestObject> ("Test Object");
|
||||
NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0,
|
||||
NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0,
|
||||
"Unexpectedly able to GetObject<AlternateTestObject> on a TestObject");
|
||||
|
||||
foundTestObject = Names::Find<TestObject> ("Alternate Test Object");
|
||||
NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0,
|
||||
NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0,
|
||||
"Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup names-tests
|
||||
* Names Test Suite
|
||||
* Names Test Suite
|
||||
*/
|
||||
class NamesTestSuite : public TestSuite
|
||||
{
|
||||
@@ -1038,6 +1012,6 @@ NamesTestSuite::NamesTestSuite ()
|
||||
static NamesTestSuite g_namesTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -60,7 +60,8 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
BaseA () {}
|
||||
BaseA ()
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,9 +85,12 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
DerivedA () {}
|
||||
DerivedA ()
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void DoDispose (void) {
|
||||
virtual void DoDispose (void)
|
||||
{
|
||||
BaseA::DoDispose ();
|
||||
}
|
||||
};
|
||||
@@ -112,7 +116,8 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
BaseB () {}
|
||||
BaseB ()
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -136,9 +141,12 @@ public:
|
||||
return tid;
|
||||
}
|
||||
/** Constructor. */
|
||||
DerivedB () {}
|
||||
DerivedB ()
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void DoDispose (void) {
|
||||
virtual void DoDispose (void)
|
||||
{
|
||||
BaseB::DoDispose ();
|
||||
}
|
||||
};
|
||||
@@ -152,8 +160,8 @@ NS_OBJECT_ENSURE_REGISTERED (DerivedB);
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup object-tests
|
||||
@@ -173,12 +181,10 @@ private:
|
||||
|
||||
CreateObjectTestCase::CreateObjectTestCase ()
|
||||
: TestCase ("Check CreateObject<Type> template function")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
CreateObjectTestCase::~CreateObjectTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CreateObjectTestCase::DoRun (void)
|
||||
@@ -212,13 +218,13 @@ CreateObjectTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (baseA->GetObject<BaseA> (), baseA, "Unable to GetObject<BaseA> on BaseA");
|
||||
|
||||
//
|
||||
// Since we created a DerivedA and cast it to a BaseA, we should be able to
|
||||
// Since we created a DerivedA and cast it to a BaseA, we should be able to
|
||||
// get back a DerivedA and it should be the original Ptr.
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_EQ (baseA->GetObject<DerivedA> (), baseA, "GetObject() of the original type returns different Ptr");
|
||||
|
||||
// If we created a DerivedA and cast it to a BaseA, then we GetObject for the
|
||||
// same DerivedA and cast it back to the same BaseA, we should get the same
|
||||
// If we created a DerivedA and cast it to a BaseA, then we GetObject for the
|
||||
// same DerivedA and cast it back to the same BaseA, we should get the same
|
||||
// object.
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_EQ (baseA->GetObject<BaseA> (DerivedA::GetTypeId ()), baseA, "GetObject returns different Ptr");
|
||||
@@ -242,12 +248,10 @@ private:
|
||||
|
||||
AggregateObjectTestCase::AggregateObjectTestCase ()
|
||||
: TestCase ("Check Object aggregation functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
AggregateObjectTestCase::~AggregateObjectTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
AggregateObjectTestCase::DoRun (void)
|
||||
@@ -342,7 +346,7 @@ AggregateObjectTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (baseA->GetObject<DerivedB> (), 0, "Cannot GetObject (through baseA) for DerivedB Object");
|
||||
|
||||
//
|
||||
// Since the DerivedB is also a BaseB, we should be able to ask the aggregation
|
||||
// Since the DerivedB is also a BaseB, we should be able to ask the aggregation
|
||||
// (through baseA) for the BaseB part
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_NE (baseA->GetObject<BaseB> (), 0, "Cannot GetObject (through baseA) for BaseB Object");
|
||||
@@ -353,7 +357,7 @@ AggregateObjectTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_NE (baseB->GetObject<DerivedA> (), 0, "Cannot GetObject (through baseB) for DerivedA Object");
|
||||
|
||||
//
|
||||
// Since the DerivedA is also a BaseA, we should be able to ask the aggregation
|
||||
// Since the DerivedA is also a BaseA, we should be able to ask the aggregation
|
||||
// (through baseB) for the BaseA part
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_NE (baseB->GetObject<BaseA> (), 0, "Cannot GetObject (through baseB) for BaseA Object");
|
||||
@@ -362,20 +366,20 @@ AggregateObjectTestCase::DoRun (void)
|
||||
// baseBCopy is a copy of the original Ptr to the Object BaseB. Even though
|
||||
// we didn't use baseBCopy directly in the aggregations, the object to which
|
||||
// it points was used, therefore, we should be able to use baseBCopy as if
|
||||
// it were baseB (same underlying Object) and get a BaseA and a DerivedA out
|
||||
// it were baseB (same underlying Object) and get a BaseA and a DerivedA out
|
||||
// of the aggregation through baseBCopy.
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_NE (baseBCopy->GetObject<BaseA> (), 0, "Cannot GetObject (through baseBCopy) for a BaseA Object");
|
||||
NS_TEST_ASSERT_MSG_NE (baseBCopy->GetObject<DerivedA> (), 0, "Cannot GetObject (through baseBCopy) for a BaseA Object");
|
||||
|
||||
//
|
||||
// Since the Ptr<BaseB> is actually a DerivedB, we should be able to ask the
|
||||
// Since the Ptr<BaseB> is actually a DerivedB, we should be able to ask the
|
||||
// aggregation (through baseB) for the DerivedB part
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_NE (baseB->GetObject<DerivedB> (), 0, "Cannot GetObject (through baseB) for DerivedB Object");
|
||||
|
||||
//
|
||||
// Since the DerivedB was cast to a BaseB, we should be able to ask the
|
||||
// Since the DerivedB was cast to a BaseB, we should be able to ask the
|
||||
// aggregation (through baseB) for the BaseB part
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_NE (baseB->GetObject<BaseB> (), 0, "Cannot GetObject (through baseB) for BaseB Object");
|
||||
@@ -416,12 +420,10 @@ private:
|
||||
|
||||
ObjectFactoryTestCase::ObjectFactoryTestCase ()
|
||||
: TestCase ("Check ObjectFactory functionality")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
ObjectFactoryTestCase::~ObjectFactoryTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ObjectFactoryTestCase::DoRun (void)
|
||||
@@ -446,14 +448,14 @@ ObjectFactoryTestCase::DoRun (void)
|
||||
NS_TEST_ASSERT_MSG_EQ (a->GetObject<DerivedA> (), 0, "BaseA unexpectedly responds to GetObject for DerivedA");
|
||||
|
||||
//
|
||||
// Now tell the factory to make DerivedA Objects and create one with an
|
||||
// Now tell the factory to make DerivedA Objects and create one with an
|
||||
// implied cast back to a BaseA
|
||||
//
|
||||
factory.SetTypeId (DerivedA::GetTypeId ());
|
||||
a = factory.Create ();
|
||||
|
||||
//
|
||||
// Since the DerivedA has a BaseA part, we should be able to use GetObject to
|
||||
// Since the DerivedA has a BaseA part, we should be able to use GetObject to
|
||||
// dynamically cast back to a BaseA.
|
||||
//
|
||||
NS_TEST_ASSERT_MSG_EQ (a->GetObject<BaseA> (), a, "Unable to use GetObject as dynamic_cast<BaseA>()");
|
||||
@@ -499,6 +501,6 @@ ObjectTestSuite::ObjectTestSuite ()
|
||||
static ObjectTestSuite g_objectTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup randomvariable-tests
|
||||
@@ -55,12 +55,10 @@ private:
|
||||
|
||||
OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase ()
|
||||
: TestCase ("One Uniform Random Variable with Many GetValue() Calls")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun (void)
|
||||
@@ -109,6 +107,6 @@ OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableMany
|
||||
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
class PtrTestCase;
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
void Ref (void) const;
|
||||
/** Decrement the reference count, and delete if necessary. */
|
||||
void Unref (void) const;
|
||||
|
||||
private:
|
||||
mutable uint32_t m_count; //!< The reference count.
|
||||
};
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
~NoCount ();
|
||||
/** Noop function. */
|
||||
void Nothing (void) const;
|
||||
|
||||
private:
|
||||
PtrTestCase *m_test; //!< The object being tracked.
|
||||
};
|
||||
@@ -97,6 +99,7 @@ public:
|
||||
PtrTestCase ();
|
||||
/** Count the destruction of an object. */
|
||||
void DestroyNotify (void);
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
/**
|
||||
@@ -113,11 +116,9 @@ private:
|
||||
|
||||
PtrTestBase::PtrTestBase ()
|
||||
: m_count (1)
|
||||
{
|
||||
}
|
||||
{}
|
||||
PtrTestBase::~PtrTestBase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
void
|
||||
PtrTestBase::Ref (void) const
|
||||
{
|
||||
@@ -135,8 +136,7 @@ PtrTestBase::Unref (void) const
|
||||
|
||||
NoCount::NoCount (PtrTestCase *test)
|
||||
: m_test (test)
|
||||
{
|
||||
}
|
||||
{}
|
||||
NoCount::~NoCount ()
|
||||
{
|
||||
m_test->DestroyNotify ();
|
||||
@@ -149,8 +149,7 @@ NoCount::Nothing () const
|
||||
|
||||
PtrTestCase::PtrTestCase (void)
|
||||
: TestCase ("Sanity checking of Ptr<>")
|
||||
{
|
||||
}
|
||||
{}
|
||||
void
|
||||
PtrTestCase::DestroyNotify (void)
|
||||
{
|
||||
@@ -183,14 +182,14 @@ PtrTestCase::DoRun (void)
|
||||
Ptr<NoCount> p;
|
||||
p = Create<NoCount> (this);
|
||||
#if defined(__clang__)
|
||||
#if __has_warning("-Wself-assign-overloaded")
|
||||
#if __has_warning ("-Wself-assign-overloaded")
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wself-assign-overloaded"
|
||||
#endif
|
||||
#endif
|
||||
p = p;
|
||||
#if defined(__clang__)
|
||||
#if __has_warning("-Wself-assign-overloaded")
|
||||
#if __has_warning ("-Wself-assign-overloaded")
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
@@ -336,7 +335,7 @@ public:
|
||||
PtrTestSuite ()
|
||||
: TestSuite ("ptr")
|
||||
{
|
||||
AddTestCase (new PtrTestCase ());
|
||||
AddTestCase (new PtrTestCase ());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -344,9 +343,9 @@ public:
|
||||
* \ingroup ptr-tests
|
||||
* PtrTestSuite instance variable.
|
||||
*/
|
||||
static PtrTestSuite g_ptrTestSuite;
|
||||
static PtrTestSuite g_ptrTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -63,7 +63,7 @@ bool seedSet = false;
|
||||
// values so that the distributions can be evaluated with chi-squared
|
||||
// tests. To enable this, normal invocation of this test suite will
|
||||
// result in a seed value corresponding to the seconds since epoch
|
||||
// (time (0) from ctime). Note: this is not a recommended practice for
|
||||
// (time (0) from ctime). Note: this is not a recommended practice for
|
||||
// seeding normal simulations, as described in the ns-3 manual, but
|
||||
// suits our purposes here.
|
||||
//
|
||||
@@ -72,11 +72,11 @@ bool seedSet = false;
|
||||
// to a specific value. Therefore, we adopt the following policy. When
|
||||
// the test program is being run with the default global values for seed
|
||||
// and run number, this function will instead pick a random, time-based
|
||||
// seed for use within this test suite. If the global values for seed or
|
||||
// seed for use within this test suite. If the global values for seed or
|
||||
// run number have been configured differently from the default values,
|
||||
// the global seed value will be used instead of the time-based one.
|
||||
//
|
||||
// For example, this command will cause this test suite to use the
|
||||
//
|
||||
// For example, this command will cause this test suite to use the
|
||||
// deterministic value of seed=3 every time:
|
||||
// NS_GLOBAL_VALUE="RngSeed=3" ./test.py -s random-variable-stream-generators
|
||||
// or equivalently (to see log output):
|
||||
@@ -95,7 +95,7 @@ SetTestSuiteSeed (void)
|
||||
seed = static_cast<uint32_t> (time (0));
|
||||
seedSet = true;
|
||||
NS_LOG_DEBUG ("Global seed and run number are default; seeding with time of day: " << seed);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -135,12 +135,10 @@ private:
|
||||
|
||||
RandomVariableStreamUniformTestCase::RandomVariableStreamUniformTestCase ()
|
||||
: TestCase ("Uniform Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamUniformTestCase::~RandomVariableStreamUniformTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamUniformTestCase::ChiSquaredTest (Ptr<UniformRandomVariable> u)
|
||||
@@ -186,7 +184,7 @@ RandomVariableStreamUniformTestCase::DoRun (void)
|
||||
SetTestSuiteSeed ();
|
||||
|
||||
double confidence = 0.99;
|
||||
double maxStatistic = gsl_cdf_chisq_Pinv (confidence, (N_BINS-1));
|
||||
double maxStatistic = gsl_cdf_chisq_Pinv (confidence, (N_BINS - 1));
|
||||
NS_LOG_DEBUG ("Chi square required at " << confidence << " confidence for " << N_BINS << " bins is " << maxStatistic);
|
||||
|
||||
double result = maxStatistic;
|
||||
@@ -213,7 +211,7 @@ RandomVariableStreamUniformTestCase::DoRun (void)
|
||||
|
||||
x->SetAttribute ("Min", DoubleValue (min));
|
||||
x->SetAttribute ("Max", DoubleValue (max));
|
||||
|
||||
|
||||
// Test that values are always within the range:
|
||||
//
|
||||
// [min, max)
|
||||
@@ -283,12 +281,10 @@ private:
|
||||
|
||||
RandomVariableStreamUniformAntitheticTestCase::RandomVariableStreamUniformAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Uniform Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamUniformAntitheticTestCase::~RandomVariableStreamUniformAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamUniformAntitheticTestCase::ChiSquaredTest (Ptr<UniformRandomVariable> u)
|
||||
@@ -363,7 +359,7 @@ RandomVariableStreamUniformAntitheticTestCase::DoRun (void)
|
||||
|
||||
x->SetAttribute ("Min", DoubleValue (min));
|
||||
x->SetAttribute ("Max", DoubleValue (max));
|
||||
|
||||
|
||||
// Test that values are always within the range:
|
||||
//
|
||||
// [min, max)
|
||||
@@ -398,12 +394,10 @@ const double RandomVariableStreamConstantTestCase::TOLERANCE = 1e-8;
|
||||
|
||||
RandomVariableStreamConstantTestCase::RandomVariableStreamConstantTestCase ()
|
||||
: TestCase ("Constant Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamConstantTestCase::~RandomVariableStreamConstantTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamConstantTestCase::DoRun (void)
|
||||
@@ -448,12 +442,10 @@ const double RandomVariableStreamSequentialTestCase::TOLERANCE = 1e-8;
|
||||
|
||||
RandomVariableStreamSequentialTestCase::RandomVariableStreamSequentialTestCase ()
|
||||
: TestCase ("Sequential Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamSequentialTestCase::~RandomVariableStreamSequentialTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamSequentialTestCase::DoRun (void)
|
||||
@@ -468,24 +460,24 @@ RandomVariableStreamSequentialTestCase::DoRun (void)
|
||||
//
|
||||
s->SetAttribute ("Min", DoubleValue (4));
|
||||
s->SetAttribute ("Max", DoubleValue (11));
|
||||
s->SetAttribute ("Increment", StringValue("ns3::UniformRandomVariable[Min=3.0|Max=3.0]"));
|
||||
s->SetAttribute ("Increment", StringValue ("ns3::UniformRandomVariable[Min=3.0|Max=3.0]"));
|
||||
s->SetAttribute ("Consecutive", IntegerValue (2));
|
||||
|
||||
double value;
|
||||
|
||||
// Test that the sequencet is correct.
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence value 5 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence value 6 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence value 5 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence value 6 wrong.");
|
||||
|
||||
}
|
||||
|
||||
@@ -510,12 +502,10 @@ private:
|
||||
|
||||
RandomVariableStreamNormalTestCase::RandomVariableStreamNormalTestCase ()
|
||||
: TestCase ("Normal Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamNormalTestCase::~RandomVariableStreamNormalTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamNormalTestCase::ChiSquaredTest (Ptr<NormalRandomVariable> n)
|
||||
@@ -612,7 +602,7 @@ RandomVariableStreamNormalTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -636,12 +626,10 @@ private:
|
||||
|
||||
RandomVariableStreamNormalAntitheticTestCase::RandomVariableStreamNormalAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Normal Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamNormalAntitheticTestCase::~RandomVariableStreamNormalAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamNormalAntitheticTestCase::ChiSquaredTest (Ptr<NormalRandomVariable> n)
|
||||
@@ -745,7 +733,7 @@ RandomVariableStreamNormalAntitheticTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -769,12 +757,10 @@ private:
|
||||
|
||||
RandomVariableStreamExponentialTestCase::RandomVariableStreamExponentialTestCase ()
|
||||
: TestCase ("Exponential Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamExponentialTestCase::~RandomVariableStreamExponentialTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamExponentialTestCase::ChiSquaredTest (Ptr<ExponentialRandomVariable> e)
|
||||
@@ -865,7 +851,7 @@ RandomVariableStreamExponentialTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = mean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, mean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, mean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -889,12 +875,10 @@ private:
|
||||
|
||||
RandomVariableStreamExponentialAntitheticTestCase::RandomVariableStreamExponentialAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Exponential Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamExponentialAntitheticTestCase::~RandomVariableStreamExponentialAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamExponentialAntitheticTestCase::ChiSquaredTest (Ptr<ExponentialRandomVariable> e)
|
||||
@@ -992,7 +976,7 @@ RandomVariableStreamExponentialAntitheticTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = mean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, mean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, mean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1016,12 +1000,10 @@ private:
|
||||
|
||||
RandomVariableStreamParetoTestCase::RandomVariableStreamParetoTestCase ()
|
||||
: TestCase ("Pareto Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamParetoTestCase::~RandomVariableStreamParetoTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamParetoTestCase::ChiSquaredTest (Ptr<ParetoRandomVariable> p)
|
||||
@@ -1114,15 +1096,15 @@ RandomVariableStreamParetoTestCase::DoRun (void)
|
||||
// shape * scale
|
||||
// E[value] = --------------- ,
|
||||
// shape - 1
|
||||
//
|
||||
//
|
||||
// where
|
||||
//
|
||||
//
|
||||
// scale = mean * (shape - 1.0) / shape .
|
||||
double expectedMean = (shape * scale) / (shape - 1.0);
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1146,12 +1128,10 @@ private:
|
||||
|
||||
RandomVariableStreamParetoAntitheticTestCase::RandomVariableStreamParetoAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Pareto Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamParetoAntitheticTestCase::~RandomVariableStreamParetoAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamParetoAntitheticTestCase::ChiSquaredTest (Ptr<ParetoRandomVariable> p)
|
||||
@@ -1251,16 +1231,16 @@ RandomVariableStreamParetoAntitheticTestCase::DoRun (void)
|
||||
// shape * scale
|
||||
// E[value] = --------------- ,
|
||||
// shape - 1
|
||||
//
|
||||
//
|
||||
// where
|
||||
//
|
||||
//
|
||||
// scale = mean * (shape - 1.0) / shape .
|
||||
//
|
||||
double expectedMean = (shape * scale) / (shape - 1.0);
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1284,12 +1264,10 @@ private:
|
||||
|
||||
RandomVariableStreamWeibullTestCase::RandomVariableStreamWeibullTestCase ()
|
||||
: TestCase ("Weibull Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamWeibullTestCase::~RandomVariableStreamWeibullTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamWeibullTestCase::ChiSquaredTest (Ptr<WeibullRandomVariable> p)
|
||||
@@ -1384,11 +1362,11 @@ RandomVariableStreamWeibullTestCase::DoRun (void)
|
||||
// Weibull distributed random variable is
|
||||
//
|
||||
// E[value] = scale * Gamma(1 + 1 / shape) ,
|
||||
//
|
||||
// where Gamma() is the Gamma function. Note that
|
||||
//
|
||||
//
|
||||
// where Gamma() is the Gamma function. Note that
|
||||
//
|
||||
// Gamma(n) = (n - 1)!
|
||||
//
|
||||
//
|
||||
// if n is a positive integer.
|
||||
//
|
||||
// For this test,
|
||||
@@ -1401,12 +1379,12 @@ RandomVariableStreamWeibullTestCase::DoRun (void)
|
||||
// which means
|
||||
//
|
||||
// E[value] = scale .
|
||||
//
|
||||
//
|
||||
double expectedMean = scale;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1430,12 +1408,10 @@ private:
|
||||
|
||||
RandomVariableStreamWeibullAntitheticTestCase::RandomVariableStreamWeibullAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Weibull Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamWeibullAntitheticTestCase::~RandomVariableStreamWeibullAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamWeibullAntitheticTestCase::ChiSquaredTest (Ptr<WeibullRandomVariable> p)
|
||||
@@ -1537,11 +1513,11 @@ RandomVariableStreamWeibullAntitheticTestCase::DoRun (void)
|
||||
// Weibull distributed random variable is
|
||||
//
|
||||
// E[value] = scale * Gamma(1 + 1 / shape) ,
|
||||
//
|
||||
// where Gamma() is the Gamma function. Note that
|
||||
//
|
||||
//
|
||||
// where Gamma() is the Gamma function. Note that
|
||||
//
|
||||
// Gamma(n) = (n - 1)!
|
||||
//
|
||||
//
|
||||
// if n is a positive integer.
|
||||
//
|
||||
// For this test,
|
||||
@@ -1554,12 +1530,12 @@ RandomVariableStreamWeibullAntitheticTestCase::DoRun (void)
|
||||
// which means
|
||||
//
|
||||
// E[value] = scale .
|
||||
//
|
||||
//
|
||||
double expectedMean = scale;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1583,12 +1559,10 @@ private:
|
||||
|
||||
RandomVariableStreamLogNormalTestCase::RandomVariableStreamLogNormalTestCase ()
|
||||
: TestCase ("Log-Normal Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamLogNormalTestCase::~RandomVariableStreamLogNormalTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamLogNormalTestCase::ChiSquaredTest (Ptr<LogNormalRandomVariable> n)
|
||||
@@ -1680,13 +1654,13 @@ RandomVariableStreamLogNormalTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// log-normally distributed random variable is equal to
|
||||
// log-normally distributed random variable is equal to
|
||||
//
|
||||
// 2
|
||||
// mu + sigma / 2
|
||||
// E[value] = e .
|
||||
//
|
||||
double expectedMean = std::exp(mu + sigma * sigma / 2.0);
|
||||
double expectedMean = std::exp (mu + sigma * sigma / 2.0);
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
//
|
||||
@@ -1695,7 +1669,7 @@ RandomVariableStreamLogNormalTestCase::DoRun (void)
|
||||
/// implementation or that the mean of this distribution is more
|
||||
/// sensitive to its parameters than the others are.
|
||||
double TOLERANCE = expectedMean * 3e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1719,12 +1693,10 @@ private:
|
||||
|
||||
RandomVariableStreamLogNormalAntitheticTestCase::RandomVariableStreamLogNormalAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Log-Normal Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamLogNormalAntitheticTestCase::~RandomVariableStreamLogNormalAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamLogNormalAntitheticTestCase::ChiSquaredTest (Ptr<LogNormalRandomVariable> n)
|
||||
@@ -1823,13 +1795,13 @@ RandomVariableStreamLogNormalAntitheticTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// log-normally distributed random variable is equal to
|
||||
// log-normally distributed random variable is equal to
|
||||
//
|
||||
// 2
|
||||
// mu + sigma / 2
|
||||
// E[value] = e .
|
||||
//
|
||||
double expectedMean = std::exp(mu + sigma * sigma / 2.0);
|
||||
double expectedMean = std::exp (mu + sigma * sigma / 2.0);
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
//
|
||||
@@ -1838,7 +1810,7 @@ RandomVariableStreamLogNormalAntitheticTestCase::DoRun (void)
|
||||
/// implementation or that the mean of this distribution is more
|
||||
/// sensitive to its parameters than the others are.
|
||||
double TOLERANCE = expectedMean * 3e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1862,12 +1834,10 @@ private:
|
||||
|
||||
RandomVariableStreamGammaTestCase::RandomVariableStreamGammaTestCase ()
|
||||
: TestCase ("Gamma Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamGammaTestCase::~RandomVariableStreamGammaTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamGammaTestCase::ChiSquaredTest (Ptr<GammaRandomVariable> n)
|
||||
@@ -1959,7 +1929,7 @@ RandomVariableStreamGammaTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// gammaly distributed random variable is equal to
|
||||
// gammaly distributed random variable is equal to
|
||||
//
|
||||
// E[value] = alpha * beta .
|
||||
//
|
||||
@@ -1967,7 +1937,7 @@ RandomVariableStreamGammaTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1991,12 +1961,10 @@ private:
|
||||
|
||||
RandomVariableStreamGammaAntitheticTestCase::RandomVariableStreamGammaAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Gamma Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamGammaAntitheticTestCase::~RandomVariableStreamGammaAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamGammaAntitheticTestCase::ChiSquaredTest (Ptr<GammaRandomVariable> n)
|
||||
@@ -2096,7 +2064,7 @@ RandomVariableStreamGammaAntitheticTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// gammaly distributed random variable is equal to
|
||||
// gammaly distributed random variable is equal to
|
||||
//
|
||||
// E[value] = alpha * beta .
|
||||
//
|
||||
@@ -2104,7 +2072,7 @@ RandomVariableStreamGammaAntitheticTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2128,12 +2096,10 @@ private:
|
||||
|
||||
RandomVariableStreamErlangTestCase::RandomVariableStreamErlangTestCase ()
|
||||
: TestCase ("Erlang Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamErlangTestCase::~RandomVariableStreamErlangTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamErlangTestCase::ChiSquaredTest (Ptr<ErlangRandomVariable> n)
|
||||
@@ -2228,7 +2194,7 @@ RandomVariableStreamErlangTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// Erlangly distributed random variable is equal to
|
||||
// Erlangly distributed random variable is equal to
|
||||
//
|
||||
// E[value] = k * lambda .
|
||||
//
|
||||
@@ -2236,7 +2202,7 @@ RandomVariableStreamErlangTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2260,12 +2226,10 @@ private:
|
||||
|
||||
RandomVariableStreamErlangAntitheticTestCase::RandomVariableStreamErlangAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Erlang Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamErlangAntitheticTestCase::~RandomVariableStreamErlangAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RandomVariableStreamErlangAntitheticTestCase::ChiSquaredTest (Ptr<ErlangRandomVariable> n)
|
||||
@@ -2368,7 +2332,7 @@ RandomVariableStreamErlangAntitheticTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// Erlangly distributed random variable is equal to
|
||||
// Erlangly distributed random variable is equal to
|
||||
//
|
||||
// E[value] = k * lambda .
|
||||
//
|
||||
@@ -2376,7 +2340,7 @@ RandomVariableStreamErlangAntitheticTestCase::DoRun (void)
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2396,12 +2360,10 @@ private:
|
||||
|
||||
RandomVariableStreamZipfTestCase::RandomVariableStreamZipfTestCase ()
|
||||
: TestCase ("Zipf Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamZipfTestCase::~RandomVariableStreamZipfTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamZipfTestCase::DoRun (void)
|
||||
@@ -2427,23 +2389,23 @@ RandomVariableStreamZipfTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// Zipfly distributed random variable is equal to
|
||||
// Zipfly distributed random variable is equal to
|
||||
//
|
||||
// H
|
||||
// N, alpha - 1
|
||||
// E[value] = ---------------
|
||||
// H
|
||||
// N, alpha
|
||||
//
|
||||
//
|
||||
// where
|
||||
//
|
||||
// N
|
||||
// ---
|
||||
// N
|
||||
// ---
|
||||
// \ -alpha
|
||||
// H = / m .
|
||||
// N, alpha ---
|
||||
// m=1
|
||||
//
|
||||
// m=1
|
||||
//
|
||||
// For this test,
|
||||
//
|
||||
// -(alpha - 1)
|
||||
@@ -2453,12 +2415,12 @@ RandomVariableStreamZipfTestCase::DoRun (void)
|
||||
// 1
|
||||
//
|
||||
// = 1 .
|
||||
//
|
||||
//
|
||||
double expectedMean = 1.0;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2478,12 +2440,10 @@ private:
|
||||
|
||||
RandomVariableStreamZipfAntitheticTestCase::RandomVariableStreamZipfAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Zipf Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamZipfAntitheticTestCase::~RandomVariableStreamZipfAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamZipfAntitheticTestCase::DoRun (void)
|
||||
@@ -2512,23 +2472,23 @@ RandomVariableStreamZipfAntitheticTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// Zipfly distributed random variable is equal to
|
||||
// Zipfly distributed random variable is equal to
|
||||
//
|
||||
// H
|
||||
// N, alpha - 1
|
||||
// E[value] = ---------------
|
||||
// H
|
||||
// N, alpha
|
||||
//
|
||||
//
|
||||
// where
|
||||
//
|
||||
// N
|
||||
// ---
|
||||
// N
|
||||
// ---
|
||||
// \ -alpha
|
||||
// H = / m .
|
||||
// N, alpha ---
|
||||
// m=1
|
||||
//
|
||||
// m=1
|
||||
//
|
||||
// For this test,
|
||||
//
|
||||
// -(alpha - 1)
|
||||
@@ -2538,12 +2498,12 @@ RandomVariableStreamZipfAntitheticTestCase::DoRun (void)
|
||||
// 1
|
||||
//
|
||||
// = 1 .
|
||||
//
|
||||
//
|
||||
double expectedMean = 1.0;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2563,12 +2523,10 @@ private:
|
||||
|
||||
RandomVariableStreamZetaTestCase::RandomVariableStreamZetaTestCase ()
|
||||
: TestCase ("Zeta Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamZetaTestCase::~RandomVariableStreamZetaTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamZetaTestCase::DoRun (void)
|
||||
@@ -2592,24 +2550,24 @@ RandomVariableStreamZetaTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// zetaly distributed random variable is equal to
|
||||
// zetaly distributed random variable is equal to
|
||||
//
|
||||
// zeta(alpha - 1)
|
||||
// E[value] = --------------- for alpha > 2 ,
|
||||
// zeta(alpha)
|
||||
//
|
||||
//
|
||||
// where zeta(alpha) is the Riemann zeta function.
|
||||
//
|
||||
//
|
||||
// There are no simple analytic forms for the Riemann zeta function,
|
||||
// which is why the gsl library is used in this test to calculate
|
||||
// the known mean of the values.
|
||||
double expectedMean =
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha - 1)) /
|
||||
double expectedMean =
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha - 1)) /
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha) );
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2629,12 +2587,10 @@ private:
|
||||
|
||||
RandomVariableStreamZetaAntitheticTestCase::RandomVariableStreamZetaAntitheticTestCase ()
|
||||
: TestCase ("Antithetic Zeta Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamZetaAntitheticTestCase::~RandomVariableStreamZetaAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamZetaAntitheticTestCase::DoRun (void)
|
||||
@@ -2661,24 +2617,24 @@ RandomVariableStreamZetaAntitheticTestCase::DoRun (void)
|
||||
double valueMean = sum / N_MEASUREMENTS;
|
||||
|
||||
// The expected value for the mean of the values returned by a
|
||||
// zetaly distributed random variable is equal to
|
||||
// zetaly distributed random variable is equal to
|
||||
//
|
||||
// zeta(alpha - 1)
|
||||
// E[value] = --------------- for alpha > 2 ,
|
||||
// zeta(alpha)
|
||||
//
|
||||
//
|
||||
// where zeta(alpha) is the Riemann zeta function.
|
||||
//
|
||||
//
|
||||
// There are no simple analytic forms for the Riemann zeta function,
|
||||
// which is why the gsl library is used in this test to calculate
|
||||
// the known mean of the values.
|
||||
double expectedMean =
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha) - 1) /
|
||||
double expectedMean =
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha) - 1) /
|
||||
gsl_sf_zeta_int (static_cast<int> (alpha) );
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2700,12 +2656,10 @@ const double RandomVariableStreamDeterministicTestCase::TOLERANCE = 1e-8;
|
||||
|
||||
RandomVariableStreamDeterministicTestCase::RandomVariableStreamDeterministicTestCase ()
|
||||
: TestCase ("Deterministic Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamDeterministicTestCase::~RandomVariableStreamDeterministicTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamDeterministicTestCase::DoRun (void)
|
||||
@@ -2725,18 +2679,18 @@ RandomVariableStreamDeterministicTestCase::DoRun (void)
|
||||
double value;
|
||||
|
||||
// Test that the first sequence is correct.
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence 1 value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence 1 value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence 1 value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence 1 value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence 1 value 5 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence 1 value 6 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence 1 value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4, TOLERANCE, "Sequence 1 value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence 1 value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 7, TOLERANCE, "Sequence 1 value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence 1 value 5 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 10, TOLERANCE, "Sequence 1 value 6 wrong.");
|
||||
|
||||
// The following array should give the sequence
|
||||
//
|
||||
@@ -2747,15 +2701,15 @@ RandomVariableStreamDeterministicTestCase::DoRun (void)
|
||||
s->SetValueArray (array2, count2);
|
||||
|
||||
// Test that the second sequence is correct.
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 1000, TOLERANCE, "Sequence 2 value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 2000, TOLERANCE, "Sequence 2 value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 3000, TOLERANCE, "Sequence 2 value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4000, TOLERANCE, "Sequence 2 value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 1000, TOLERANCE, "Sequence 2 value 1 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 2000, TOLERANCE, "Sequence 2 value 2 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 3000, TOLERANCE, "Sequence 2 value 3 wrong.");
|
||||
value = s->GetValue ();
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (value, 4000, TOLERANCE, "Sequence 2 value 4 wrong.");
|
||||
value = s->GetValue ();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -2775,12 +2729,10 @@ private:
|
||||
|
||||
RandomVariableStreamEmpiricalTestCase::RandomVariableStreamEmpiricalTestCase ()
|
||||
: TestCase ("Empirical Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamEmpiricalTestCase::~RandomVariableStreamEmpiricalTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamEmpiricalTestCase::DoRun (void)
|
||||
@@ -2807,12 +2759,12 @@ RandomVariableStreamEmpiricalTestCase::DoRun (void)
|
||||
// empirical distribution is the midpoint of the distribution
|
||||
//
|
||||
// E[value] = 5 .
|
||||
//
|
||||
//
|
||||
double expectedMean = 5.0;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
|
||||
// Bug 2082: Create the RNG with a uniform distribution between -1 and 1.
|
||||
Ptr<EmpiricalRandomVariable> y = CreateObject<EmpiricalRandomVariable> ();
|
||||
@@ -2839,12 +2791,10 @@ private:
|
||||
|
||||
RandomVariableStreamEmpiricalAntitheticTestCase::RandomVariableStreamEmpiricalAntitheticTestCase ()
|
||||
: TestCase ("EmpiricalAntithetic Random Variable Stream Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RandomVariableStreamEmpiricalAntitheticTestCase::~RandomVariableStreamEmpiricalAntitheticTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
RandomVariableStreamEmpiricalAntitheticTestCase::DoRun (void)
|
||||
@@ -2874,12 +2824,12 @@ RandomVariableStreamEmpiricalAntitheticTestCase::DoRun (void)
|
||||
// empirical distribution is the midpoint of the distribution
|
||||
//
|
||||
// E[value] = 5 .
|
||||
//
|
||||
//
|
||||
double expectedMean = 5.0;
|
||||
|
||||
// Test that values have approximately the right mean value.
|
||||
double TOLERANCE = expectedMean * 1e-2;
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (valueMean, expectedMean, TOLERANCE, "Wrong mean value.");
|
||||
}
|
||||
|
||||
class RandomVariableStreamTestSuite : public TestSuite
|
||||
|
||||
@@ -62,17 +62,15 @@ private:
|
||||
|
||||
RngUniformTestCase::RngUniformTestCase ()
|
||||
: TestCase ("Uniform Random Number Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RngUniformTestCase::~RngUniformTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RngUniformTestCase::ChiSquaredTest (Ptr<UniformRandomVariable> u)
|
||||
{
|
||||
gsl_histogram * h = gsl_histogram_alloc (N_BINS);
|
||||
gsl_histogram * h = gsl_histogram_alloc (N_BINS);
|
||||
gsl_histogram_set_ranges_uniform (h, 0., 1.);
|
||||
|
||||
for (uint32_t i = 0; i < N_MEASUREMENTS; ++i)
|
||||
@@ -145,12 +143,10 @@ private:
|
||||
|
||||
RngNormalTestCase::RngNormalTestCase ()
|
||||
: TestCase ("Normal Random Number Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RngNormalTestCase::~RngNormalTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RngNormalTestCase::ChiSquaredTest (Ptr<NormalRandomVariable> n)
|
||||
@@ -242,12 +238,10 @@ private:
|
||||
|
||||
RngExponentialTestCase::RngExponentialTestCase ()
|
||||
: TestCase ("Exponential Random Number Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RngExponentialTestCase::~RngExponentialTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RngExponentialTestCase::ChiSquaredTest (Ptr<ExponentialRandomVariable> e)
|
||||
@@ -338,12 +332,10 @@ private:
|
||||
|
||||
RngParetoTestCase::RngParetoTestCase ()
|
||||
: TestCase ("Pareto Random Number Generator")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
RngParetoTestCase::~RngParetoTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
double
|
||||
RngParetoTestCase::ChiSquaredTest (Ptr<ParetoRandomVariable> p)
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
/// Class test suite. \endverbatim
|
||||
*
|
||||
* Define the class-tests group:
|
||||
* \verbatim /// \ingroup module-tests
|
||||
* \verbatim /// \ingroup module-tests
|
||||
/// \defgroup class-tests Class test suite \endverbatim
|
||||
*
|
||||
* Make sure test.h is included:
|
||||
@@ -64,7 +64,7 @@ class ClassTestSuite : public TestSuite {...}; \endverbatim
|
||||
static ClassTestSuite g_classTestSuite; \endverbatim
|
||||
*
|
||||
* Finally, close the ingroup and namespace blocks:
|
||||
* \verbatim } // namespace tests
|
||||
* \verbatim } // namespace tests
|
||||
} // namespace ns3 \endverbatim
|
||||
*/
|
||||
|
||||
@@ -76,8 +76,8 @@ static ClassTestSuite g_classTestSuite; \endverbatim
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup testing-example
|
||||
@@ -98,16 +98,14 @@ private:
|
||||
/** Add some help text to this case to describe what it is intended to test. */
|
||||
SampleTestCase1::SampleTestCase1 ()
|
||||
: TestCase ("Sample test case (does nothing)")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* This destructor does nothing but we include it as a reminder that
|
||||
* the test case should clean up after itself
|
||||
*/
|
||||
SampleTestCase1::~SampleTestCase1 ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* This method is the pure virtual method from class TestCase that every
|
||||
@@ -149,6 +147,6 @@ SampleTestSuite::SampleTestSuite ()
|
||||
static SampleTestSuite g_sampleTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -49,11 +49,10 @@ public:
|
||||
};
|
||||
|
||||
SimulatorEventsTestCase::SimulatorEventsTestCase (ObjectFactory schedulerFactory)
|
||||
: TestCase ("Check that basic event handling is working with " +
|
||||
: TestCase ("Check that basic event handling is working with " +
|
||||
schedulerFactory.GetTypeId ().GetName ()),
|
||||
m_schedulerFactory (schedulerFactory)
|
||||
{
|
||||
}
|
||||
{}
|
||||
uint64_t
|
||||
SimulatorEventsTestCase::NowUs (void)
|
||||
{
|
||||
@@ -71,11 +70,11 @@ SimulatorEventsTestCase::EventA (int a)
|
||||
void
|
||||
SimulatorEventsTestCase::EventB (int b)
|
||||
{
|
||||
if (b != 2 || NowUs () != 11)
|
||||
if (b != 2 || NowUs () != 11)
|
||||
{
|
||||
m_b = false;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_b = true;
|
||||
}
|
||||
@@ -93,11 +92,11 @@ SimulatorEventsTestCase::EventC (int c)
|
||||
void
|
||||
SimulatorEventsTestCase::EventD (int d)
|
||||
{
|
||||
if (d != 4 || NowUs () != (11+10))
|
||||
if (d != 4 || NowUs () != (11 + 10))
|
||||
{
|
||||
m_d = false;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_d = true;
|
||||
}
|
||||
@@ -112,10 +111,10 @@ SimulatorEventsTestCase::destroy (void)
|
||||
{
|
||||
if (m_destroyId.IsExpired ())
|
||||
{
|
||||
m_destroy = true;
|
||||
m_destroy = true;
|
||||
}
|
||||
}
|
||||
void
|
||||
void
|
||||
SimulatorEventsTestCase::DoRun (void)
|
||||
{
|
||||
m_a = true;
|
||||
@@ -175,11 +174,15 @@ class SimulatorTemplateTestCase : public TestCase
|
||||
public:
|
||||
SimulatorTemplateTestCase ();
|
||||
// only here for testing of Ptr<>
|
||||
void Ref (void) const {}
|
||||
void Unref (void) const {}
|
||||
void Ref (void) const
|
||||
{}
|
||||
void Unref (void) const
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
void bar0 (void) {}
|
||||
void bar1 (int) {}
|
||||
void bar2 (int, int) {}
|
||||
@@ -213,6 +216,7 @@ private:
|
||||
void cbaz3c (const int &, const int &, const int &) const {}
|
||||
void cbaz4c (const int &, const int &, const int &, const int &) const {}
|
||||
void cbaz5c (const int &, const int &, const int &, const int &, const int &) const {}
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
|
||||
};
|
||||
|
||||
@@ -251,8 +255,7 @@ static void cber5 (const int &, const int &, const int &, const int &, const int
|
||||
|
||||
SimulatorTemplateTestCase::SimulatorTemplateTestCase ()
|
||||
: TestCase ("Check that all templates are instantiated correctly. This is a compilation test, it cannot fail at runtime.")
|
||||
{
|
||||
}
|
||||
{}
|
||||
void
|
||||
SimulatorTemplateTestCase::DoRun (void)
|
||||
{
|
||||
|
||||
@@ -74,16 +74,15 @@ ThreadedSimulatorEventsTestCase::ThreadedSimulatorEventsTestCase (ObjectFactory
|
||||
m_threads (threads),
|
||||
m_schedulerFactory (schedulerFactory),
|
||||
m_simulatorType (simulatorType)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::End (void)
|
||||
{
|
||||
m_stop = true;
|
||||
for (std::list<Ptr<SystemThread> >::iterator it2 = m_threadlist.begin(); it2 != m_threadlist.end(); ++it2)
|
||||
for (std::list<Ptr<SystemThread> >::iterator it2 = m_threadlist.begin (); it2 != m_threadlist.end (); ++it2)
|
||||
{
|
||||
(*it2)->Join();
|
||||
(*it2)->Join ();
|
||||
}
|
||||
}
|
||||
void
|
||||
@@ -91,7 +90,7 @@ ThreadedSimulatorEventsTestCase::SchedulingThread (std::pair<ThreadedSimulatorEv
|
||||
{
|
||||
ThreadedSimulatorEventsTestCase *me = context.first;
|
||||
unsigned int threadno = context.second;
|
||||
|
||||
|
||||
while (!me->m_stop)
|
||||
{
|
||||
me->m_threadWaiting[threadno] = true;
|
||||
@@ -100,14 +99,14 @@ ThreadedSimulatorEventsTestCase::SchedulingThread (std::pair<ThreadedSimulatorEv
|
||||
&ThreadedSimulatorEventsTestCase::DoNothing, me, threadno);
|
||||
while (!me->m_stop && me->m_threadWaiting[threadno])
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::nanoseconds(500));
|
||||
std::this_thread::sleep_for (std::chrono::nanoseconds (500));
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::DoNothing (unsigned int threadno)
|
||||
{
|
||||
if (!m_error.empty())
|
||||
if (!m_error.empty ())
|
||||
{
|
||||
m_error = "Bad threaded scheduling";
|
||||
}
|
||||
@@ -119,90 +118,90 @@ ThreadedSimulatorEventsTestCase::EventA (int a)
|
||||
if (m_a != m_b || m_a != m_c || m_a != m_d)
|
||||
{
|
||||
m_error = "Bad scheduling";
|
||||
Simulator::Stop();
|
||||
};
|
||||
Simulator::Stop ();
|
||||
}
|
||||
++m_a;
|
||||
Simulator::Schedule (MicroSeconds (10),
|
||||
&ThreadedSimulatorEventsTestCase::EventB, this, a+1);
|
||||
&ThreadedSimulatorEventsTestCase::EventB, this, a + 1);
|
||||
}
|
||||
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::EventB (int b)
|
||||
{
|
||||
if (m_a != (m_b+1) || m_a != (m_c+1) || m_a != (m_d+1))
|
||||
if (m_a != (m_b + 1) || m_a != (m_c + 1) || m_a != (m_d + 1))
|
||||
{
|
||||
m_error = "Bad scheduling";
|
||||
Simulator::Stop();
|
||||
};
|
||||
Simulator::Stop ();
|
||||
}
|
||||
++m_b;
|
||||
Simulator::Schedule (MicroSeconds (10),
|
||||
&ThreadedSimulatorEventsTestCase::EventC, this, b+1);
|
||||
&ThreadedSimulatorEventsTestCase::EventC, this, b + 1);
|
||||
}
|
||||
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::EventC (int c)
|
||||
{
|
||||
if (m_a != m_b || m_a != (m_c+1) || m_a != (m_d+1))
|
||||
if (m_a != m_b || m_a != (m_c + 1) || m_a != (m_d + 1))
|
||||
{
|
||||
m_error = "Bad scheduling";
|
||||
Simulator::Stop();
|
||||
};
|
||||
Simulator::Stop ();
|
||||
}
|
||||
++m_c;
|
||||
Simulator::Schedule (MicroSeconds (10),
|
||||
&ThreadedSimulatorEventsTestCase::EventD, this, c+1);
|
||||
&ThreadedSimulatorEventsTestCase::EventD, this, c + 1);
|
||||
}
|
||||
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::EventD (int d)
|
||||
{
|
||||
if (m_a != m_b || m_a != m_c || m_a != (m_d+1))
|
||||
if (m_a != m_b || m_a != m_c || m_a != (m_d + 1))
|
||||
{
|
||||
m_error = "Bad scheduling";
|
||||
Simulator::Stop();
|
||||
};
|
||||
Simulator::Stop ();
|
||||
}
|
||||
++m_d;
|
||||
if (m_stop)
|
||||
{
|
||||
Simulator::Stop();
|
||||
Simulator::Stop ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulator::Schedule (MicroSeconds (10),
|
||||
&ThreadedSimulatorEventsTestCase::EventA, this, d+1);
|
||||
&ThreadedSimulatorEventsTestCase::EventA, this, d + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::DoSetup (void)
|
||||
{
|
||||
if (!m_simulatorType.empty())
|
||||
if (!m_simulatorType.empty ())
|
||||
{
|
||||
Config::SetGlobal ("SimulatorImplementationType", StringValue (m_simulatorType));
|
||||
}
|
||||
|
||||
m_error = "";
|
||||
|
||||
m_a =
|
||||
m_b =
|
||||
m_c =
|
||||
m_d = 0;
|
||||
|
||||
for (unsigned int i=0; i < m_threads; ++i)
|
||||
m_error = "";
|
||||
|
||||
m_a =
|
||||
m_b =
|
||||
m_c =
|
||||
m_d = 0;
|
||||
|
||||
for (unsigned int i = 0; i < m_threads; ++i)
|
||||
{
|
||||
m_threadlist.push_back(
|
||||
m_threadlist.push_back (
|
||||
Create<SystemThread> (MakeBoundCallback (
|
||||
&ThreadedSimulatorEventsTestCase::SchedulingThread,
|
||||
std::pair<ThreadedSimulatorEventsTestCase *, unsigned int>(this,i) )) );
|
||||
&ThreadedSimulatorEventsTestCase::SchedulingThread,
|
||||
std::pair<ThreadedSimulatorEventsTestCase *, unsigned int> (this,i) )) );
|
||||
}
|
||||
}
|
||||
void
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::DoTeardown (void)
|
||||
{
|
||||
m_threadlist.clear();
|
||||
|
||||
m_threadlist.clear ();
|
||||
|
||||
Config::SetGlobal ("SimulatorImplementationType", StringValue ("ns3::DefaultSimulatorImpl"));
|
||||
}
|
||||
void
|
||||
void
|
||||
ThreadedSimulatorEventsTestCase::DoRun (void)
|
||||
{
|
||||
m_stop = false;
|
||||
@@ -211,16 +210,16 @@ ThreadedSimulatorEventsTestCase::DoRun (void)
|
||||
Simulator::Schedule (MicroSeconds (10), &ThreadedSimulatorEventsTestCase::EventA, this, 1);
|
||||
Simulator::Schedule (Seconds (1), &ThreadedSimulatorEventsTestCase::End, this);
|
||||
|
||||
|
||||
for (std::list<Ptr<SystemThread> >::iterator it = m_threadlist.begin(); it != m_threadlist.end(); ++it)
|
||||
|
||||
for (std::list<Ptr<SystemThread> >::iterator it = m_threadlist.begin (); it != m_threadlist.end (); ++it)
|
||||
{
|
||||
(*it)->Start();
|
||||
(*it)->Start ();
|
||||
}
|
||||
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_TEST_EXPECT_MSG_EQ (m_error.empty(), true, m_error.c_str());
|
||||
NS_TEST_EXPECT_MSG_EQ (m_error.empty (), true, m_error.c_str ());
|
||||
NS_TEST_EXPECT_MSG_EQ (m_a, m_b, "Bad scheduling");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_a, m_c, "Bad scheduling");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_a, m_d, "Bad scheduling");
|
||||
@@ -247,18 +246,18 @@ public:
|
||||
unsigned int threadcounts[] = {
|
||||
0,
|
||||
2,
|
||||
10,
|
||||
10,
|
||||
20
|
||||
};
|
||||
ObjectFactory factory;
|
||||
|
||||
for (unsigned int i=0; i < (sizeof(simulatorTypes) / sizeof(simulatorTypes[0])); ++i)
|
||||
|
||||
for (unsigned int i = 0; i < (sizeof(simulatorTypes) / sizeof(simulatorTypes[0])); ++i)
|
||||
{
|
||||
for (unsigned int j=0; j < (sizeof(threadcounts) / sizeof(threadcounts[0])); ++j)
|
||||
for (unsigned int j = 0; j < (sizeof(threadcounts) / sizeof(threadcounts[0])); ++j)
|
||||
{
|
||||
for (unsigned int k=0; k < (sizeof(schedulerTypes) / sizeof(schedulerTypes[0])); ++k)
|
||||
for (unsigned int k = 0; k < (sizeof(schedulerTypes) / sizeof(schedulerTypes[0])); ++k)
|
||||
{
|
||||
factory.SetTypeId(schedulerTypes[k]);
|
||||
factory.SetTypeId (schedulerTypes[k]);
|
||||
AddTestCase (new ThreadedSimulatorEventsTestCase (factory, simulatorTypes[i], threadcounts[j]), TestCase::QUICK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class TimeSimpleTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
TimeSimpleTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoSetup (void);
|
||||
virtual void DoRun (void);
|
||||
@@ -43,13 +44,11 @@ private:
|
||||
|
||||
TimeSimpleTestCase::TimeSimpleTestCase ()
|
||||
: TestCase ("Sanity check of common time operations")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimeSimpleTestCase::DoSetup (void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimeSimpleTestCase::DoRun (void)
|
||||
@@ -70,22 +69,22 @@ TimeSimpleTestCase::DoRun (void)
|
||||
"is 1 really 1 ?");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (Minutes (10.0).GetMinutes (), 10.0, Minutes (1).GetMinutes (),
|
||||
"is 10 really 10 ?");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (Seconds (1.0).GetSeconds (), 1.0, TimeStep (1).GetSeconds (),
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (Seconds (1.0).GetSeconds (), 1.0, TimeStep (1).GetSeconds (),
|
||||
"is 1 really 1 ?");
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (Seconds (10.0).GetSeconds (), 10.0, TimeStep (1).GetSeconds (),
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL (Seconds (10.0).GetSeconds (), 10.0, TimeStep (1).GetSeconds (),
|
||||
"is 10 really 10 ?");
|
||||
NS_TEST_ASSERT_MSG_EQ (MilliSeconds (1).GetMilliSeconds (), 1,
|
||||
NS_TEST_ASSERT_MSG_EQ (MilliSeconds (1).GetMilliSeconds (), 1,
|
||||
"is 1ms really 1ms ?");
|
||||
NS_TEST_ASSERT_MSG_EQ (MicroSeconds (1).GetMicroSeconds (), 1,
|
||||
NS_TEST_ASSERT_MSG_EQ (MicroSeconds (1).GetMicroSeconds (), 1,
|
||||
"is 1us really 1us ?");
|
||||
#if 0
|
||||
Time ns = NanoSeconds (1);
|
||||
ns.GetNanoSeconds ();
|
||||
NS_TEST_ASSERT_MSG_EQ (NanoSeconds (1).GetNanoSeconds (), 1,
|
||||
NS_TEST_ASSERT_MSG_EQ (NanoSeconds (1).GetNanoSeconds (), 1,
|
||||
"is 1ns really 1ns ?");
|
||||
NS_TEST_ASSERT_MSG_EQ (PicoSeconds (1).GetPicoSeconds (), 1,
|
||||
NS_TEST_ASSERT_MSG_EQ (PicoSeconds (1).GetPicoSeconds (), 1,
|
||||
"is 1ps really 1ps ?");
|
||||
NS_TEST_ASSERT_MSG_EQ (FemtoSeconds (1).GetFemtoSeconds (), 1,
|
||||
NS_TEST_ASSERT_MSG_EQ (FemtoSeconds (1).GetFemtoSeconds (), 1,
|
||||
"is 1fs really 1fs ?");
|
||||
#endif
|
||||
|
||||
@@ -97,15 +96,15 @@ TimeSimpleTestCase::DoRun (void)
|
||||
"change resolution to PS");
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
TimeSimpleTestCase::DoTeardown (void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
class TimeWithSignTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
TimeWithSignTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoSetup (void);
|
||||
virtual void DoRun (void);
|
||||
@@ -114,13 +113,11 @@ private:
|
||||
|
||||
TimeWithSignTestCase::TimeWithSignTestCase ()
|
||||
: TestCase ("Checks times that have plus or minus signs")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimeWithSignTestCase::DoSetup (void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimeWithSignTestCase::DoRun (void)
|
||||
@@ -152,16 +149,16 @@ TimeWithSignTestCase::DoRun (void)
|
||||
"Negative time with units not parsed correctly.");
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
TimeWithSignTestCase::DoTeardown (void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
class TimeInputOutputTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
TimeInputOutputTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
void Check (const std::string & str);
|
||||
@@ -169,8 +166,7 @@ private:
|
||||
|
||||
TimeInputOutputTestCase::TimeInputOutputTestCase ()
|
||||
: TestCase ("Input,output from,to strings")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimeInputOutputTestCase::Check (const std::string & str)
|
||||
@@ -179,7 +175,7 @@ TimeInputOutputTestCase::Check (const std::string & str)
|
||||
Time time;
|
||||
ss >> time;
|
||||
ss << time;
|
||||
bool pass = (str == ss.str ());
|
||||
bool pass = (str == ss.str ());
|
||||
|
||||
std::cout << GetParent ()->GetName () << " InputOutput: "
|
||||
<< (pass ? "pass " : "FAIL ")
|
||||
@@ -196,8 +192,8 @@ TimeInputOutputTestCase::DoRun (void)
|
||||
{
|
||||
std::cout << std::endl;
|
||||
std::cout << GetParent ()->GetName () << " InputOutput: " << GetName ()
|
||||
<< std::endl;
|
||||
|
||||
<< std::endl;
|
||||
|
||||
Check ("2ns");
|
||||
Check ("+3.1us");
|
||||
Check ("-4.2ms");
|
||||
@@ -208,16 +204,16 @@ TimeInputOutputTestCase::DoRun (void)
|
||||
Check ("10.8y");
|
||||
|
||||
Time t (3.141592654e9); // Pi seconds
|
||||
|
||||
|
||||
std::cout << GetParent ()->GetName () << " InputOutput: "
|
||||
<< "example: raw: " << t
|
||||
<< std::endl;
|
||||
|
||||
|
||||
std::cout << GetParent ()->GetName () << " InputOutput: "
|
||||
<< std::fixed << std::setprecision (9)
|
||||
<< "example: in s: " << t.As (Time::S)
|
||||
<< std::endl;
|
||||
|
||||
|
||||
std::cout << GetParent ()->GetName () << " InputOutput: "
|
||||
<< std::setprecision (6)
|
||||
<< "example: in ms: " << t.As (Time::MS)
|
||||
@@ -229,7 +225,7 @@ TimeInputOutputTestCase::DoRun (void)
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
static class TimeTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -23,27 +23,17 @@
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
namespace {
|
||||
void bari (int)
|
||||
{
|
||||
}
|
||||
void bar2i (int, int)
|
||||
{
|
||||
}
|
||||
void bar3i (int, int, int)
|
||||
{
|
||||
}
|
||||
void bar4i (int, int, int, int)
|
||||
{
|
||||
}
|
||||
void bar5i (int, int, int, int, int)
|
||||
{
|
||||
}
|
||||
void barcir (const int &)
|
||||
{
|
||||
}
|
||||
void barir (int &)
|
||||
{
|
||||
}
|
||||
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
void bari (int) {}
|
||||
void bar2i (int, int) {}
|
||||
void bar3i (int, int, int) {}
|
||||
void bar4i (int, int, int, int) {}
|
||||
void bar5i (int, int, int, int, int) {}
|
||||
void barcir (const int &) {}
|
||||
void barir (int &) {}
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
using namespace ns3;
|
||||
@@ -57,8 +47,7 @@ public:
|
||||
|
||||
TimerStateTestCase::TimerStateTestCase ()
|
||||
: TestCase ("Check correct state transitions")
|
||||
{
|
||||
}
|
||||
{}
|
||||
void
|
||||
TimerStateTestCase::DoRun (void)
|
||||
{
|
||||
@@ -99,42 +88,24 @@ public:
|
||||
TimerTemplateTestCase ();
|
||||
virtual void DoRun (void);
|
||||
virtual void DoTeardown (void);
|
||||
void bazi (int)
|
||||
{
|
||||
}
|
||||
void baz2i (int, int)
|
||||
{
|
||||
}
|
||||
void baz3i (int, int, int)
|
||||
{
|
||||
}
|
||||
void baz4i (int, int, int, int)
|
||||
{
|
||||
}
|
||||
void baz5i (int, int, int, int, int)
|
||||
{
|
||||
}
|
||||
void baz6i (int, int, int, int, int, int)
|
||||
{
|
||||
}
|
||||
void bazcir (const int&)
|
||||
{
|
||||
}
|
||||
void bazir (int&)
|
||||
{
|
||||
}
|
||||
void bazip (int *)
|
||||
{
|
||||
}
|
||||
void bazcip (const int *)
|
||||
{
|
||||
}
|
||||
|
||||
/* *NS_CHECK_STYLE_OFF* */
|
||||
void bazi (int) {}
|
||||
void baz2i (int, int) {}
|
||||
void baz3i (int, int, int) {}
|
||||
void baz4i (int, int, int, int) {}
|
||||
void baz5i (int, int, int, int, int) {}
|
||||
void baz6i (int, int, int, int, int, int) {}
|
||||
void bazcir (const int&) {}
|
||||
void bazir (int&) {}
|
||||
void bazip (int *) {}
|
||||
void bazcip (const int *) {}
|
||||
/* *NS_CHECK_STYLE_ON* */
|
||||
};
|
||||
|
||||
TimerTemplateTestCase::TimerTemplateTestCase ()
|
||||
: TestCase ("Check that template magic is working")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TimerTemplateTestCase::DoRun (void)
|
||||
|
||||
@@ -26,7 +26,8 @@ class BasicTracedCallbackTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
BasicTracedCallbackTestCase ();
|
||||
virtual ~BasicTracedCallbackTestCase () {}
|
||||
virtual ~BasicTracedCallbackTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -40,8 +41,7 @@ private:
|
||||
|
||||
BasicTracedCallbackTestCase::BasicTracedCallbackTestCase ()
|
||||
: TestCase ("Check basic TracedCallback operation")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
BasicTracedCallbackTestCase::CbOne (uint8_t a, double b)
|
||||
@@ -69,7 +69,7 @@ BasicTracedCallbackTestCase::DoRun (void)
|
||||
TracedCallback<uint8_t, double> trace;
|
||||
|
||||
//
|
||||
// Connect both callbacks to their respective test methods. If we hit the
|
||||
// Connect both callbacks to their respective test methods. If we hit the
|
||||
// trace, both callbacks should be called and the two variables should be set
|
||||
// to true.
|
||||
//
|
||||
|
||||
@@ -36,8 +36,8 @@ using namespace std;
|
||||
using namespace ns3;
|
||||
|
||||
|
||||
const std::string suite("type-id: ");
|
||||
|
||||
const std::string suite ("type-id: ");
|
||||
|
||||
//----------------------------
|
||||
//
|
||||
// Test for uniqueness of all TypeIds
|
||||
@@ -47,39 +47,41 @@ class UniqueTypeIdTestCase : public TestCase
|
||||
public:
|
||||
UniqueTypeIdTestCase ();
|
||||
virtual ~UniqueTypeIdTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
enum { HashChainFlag = 0x80000000};
|
||||
enum
|
||||
{
|
||||
HashChainFlag = 0x80000000
|
||||
};
|
||||
};
|
||||
|
||||
UniqueTypeIdTestCase::UniqueTypeIdTestCase ()
|
||||
: TestCase ("Check uniqueness of all TypeIds")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
UniqueTypeIdTestCase::~UniqueTypeIdTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
UniqueTypeIdTestCase::DoRun (void)
|
||||
{
|
||||
cout << suite << endl;
|
||||
cout << suite << GetName () << endl;
|
||||
|
||||
|
||||
// Use same custom hasher as TypeId
|
||||
ns3::Hasher hasher = ns3::Hasher ( Create<Hash::Function::Murmur3> () );
|
||||
|
||||
|
||||
uint32_t nids = TypeId::GetRegisteredN ();
|
||||
|
||||
cout << suite << "UniqueTypeIdTestCase: nids: " << nids << endl;
|
||||
cout << suite << "TypeId list:" << endl;
|
||||
cout << suite << "TypeId Chain hash Name" << endl;
|
||||
|
||||
|
||||
for (uint16_t i = 0; i < nids; ++i)
|
||||
{
|
||||
const TypeId tid = TypeId::GetRegistered (i);
|
||||
cout << suite << "" << std::setw(6) << tid.GetUid ();
|
||||
cout << suite << "" << std::setw (6) << tid.GetUid ();
|
||||
if (tid.GetHash () & HashChainFlag)
|
||||
{
|
||||
cout << " chain";
|
||||
@@ -108,7 +110,7 @@ UniqueTypeIdTestCase::DoRun (void)
|
||||
TypeId::LookupByHash (tid.GetHash ()).GetUid (),
|
||||
"LookupByHash returned different TypeId for "
|
||||
<< tid.GetName ());
|
||||
|
||||
|
||||
}
|
||||
|
||||
cout << suite << "<-- end TypeId list -->" << endl;
|
||||
@@ -124,26 +126,28 @@ class CollisionTestCase : public TestCase
|
||||
public:
|
||||
CollisionTestCase ();
|
||||
virtual ~CollisionTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
enum { HashChainFlag = 0x80000000};
|
||||
enum
|
||||
{
|
||||
HashChainFlag = 0x80000000
|
||||
};
|
||||
};
|
||||
|
||||
CollisionTestCase::CollisionTestCase ()
|
||||
: TestCase ("Check behavior when type names collide")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
CollisionTestCase::~CollisionTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
CollisionTestCase::DoRun (void)
|
||||
{
|
||||
cout << suite << endl;
|
||||
cout << suite << GetName () << endl;
|
||||
|
||||
|
||||
// Register two types whose hashes collide, in alphabetical order
|
||||
// Murmur3 collision from /usr/share/dict/web2
|
||||
string t1Name = "daemon";
|
||||
@@ -157,11 +161,11 @@ CollisionTestCase::DoRun (void)
|
||||
|
||||
// Check that they are alphabetical: t1 name < t2 name
|
||||
NS_TEST_ASSERT_MSG_EQ ( (t1.GetHash () & HashChainFlag), 0,
|
||||
"First and lesser TypeId has HashChainFlag set");
|
||||
"First and lesser TypeId has HashChainFlag set");
|
||||
cout << suite << "collision: first,lesser not chained: OK" << endl;
|
||||
|
||||
NS_TEST_ASSERT_MSG_NE ( (t2.GetHash () & HashChainFlag), 0,
|
||||
"Second and greater TypeId does not have HashChainFlag set");
|
||||
"Second and greater TypeId does not have HashChainFlag set");
|
||||
cout << suite << "collision: second,greater chained: OK" << endl;
|
||||
|
||||
|
||||
@@ -189,7 +193,7 @@ CollisionTestCase::DoRun (void)
|
||||
*
|
||||
* None found in /usr/share/dict/web2
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -209,15 +213,20 @@ private:
|
||||
TracedValue<double> m_trace;
|
||||
|
||||
public:
|
||||
DeprecatedAttribute () : m_attr (0) { NS_UNUSED (m_attr); };
|
||||
virtual ~DeprecatedAttribute () { };
|
||||
DeprecatedAttribute ()
|
||||
: m_attr (0)
|
||||
{
|
||||
NS_UNUSED (m_attr);
|
||||
}
|
||||
virtual ~DeprecatedAttribute ()
|
||||
{}
|
||||
|
||||
// Register a type with a deprecated Attribute and TraceSource
|
||||
static TypeId GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("DeprecatedAttribute")
|
||||
.SetParent<Object> ()
|
||||
|
||||
|
||||
// The new attribute
|
||||
.AddAttribute ("attribute",
|
||||
"the Attribute",
|
||||
@@ -260,7 +269,7 @@ public:
|
||||
"ns3::TracedValueCallback::Void",
|
||||
TypeId::OBSOLETE,
|
||||
"refactor to use 'trace'");
|
||||
|
||||
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -272,6 +281,7 @@ class DeprecatedAttributeTestCase : public TestCase
|
||||
public:
|
||||
DeprecatedAttributeTestCase ();
|
||||
virtual ~DeprecatedAttributeTestCase ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
|
||||
@@ -279,12 +289,10 @@ private:
|
||||
|
||||
DeprecatedAttributeTestCase::DeprecatedAttributeTestCase ()
|
||||
: TestCase ("Check deprecated Attributes and TraceSources")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
DeprecatedAttributeTestCase::~DeprecatedAttributeTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
DeprecatedAttributeTestCase::DoRun (void)
|
||||
@@ -294,17 +302,17 @@ DeprecatedAttributeTestCase::DoRun (void)
|
||||
|
||||
TypeId tid = DeprecatedAttribute::GetTypeId ();
|
||||
cerr << suite << "DeprecatedAttribute TypeId: " << tid.GetUid () << endl;
|
||||
|
||||
|
||||
// Try the lookups
|
||||
struct TypeId::AttributeInformation ainfo;
|
||||
NS_TEST_ASSERT_MSG_EQ (tid.LookupAttributeByName ("attribute", &ainfo), true,
|
||||
"lookup new attribute");
|
||||
"lookup new attribute");
|
||||
cerr << suite << "lookup new attribute:"
|
||||
<< (ainfo.supportLevel == TypeId::SUPPORTED ? "supported" : "error")
|
||||
<< endl;
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (tid.LookupAttributeByName ("oldAttribute", &ainfo), true,
|
||||
"lookup old attribute");
|
||||
"lookup old attribute");
|
||||
cerr << suite << "lookup old attribute:"
|
||||
<< (ainfo.supportLevel == TypeId::DEPRECATED ? "deprecated" : "error")
|
||||
<< endl;
|
||||
@@ -325,7 +333,7 @@ DeprecatedAttributeTestCase::DoRun (void)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------
|
||||
//
|
||||
// Performance test
|
||||
@@ -335,29 +343,31 @@ class LookupTimeTestCase : public TestCase
|
||||
public:
|
||||
LookupTimeTestCase ();
|
||||
virtual ~LookupTimeTestCase ();
|
||||
|
||||
private:
|
||||
void DoRun (void);
|
||||
void DoSetup (void);
|
||||
void Report (const std::string how, const uint32_t delta) const ;
|
||||
void Report (const std::string how, const uint32_t delta) const;
|
||||
|
||||
enum { REPETITIONS = 100000 };
|
||||
enum
|
||||
{
|
||||
REPETITIONS = 100000
|
||||
};
|
||||
};
|
||||
|
||||
LookupTimeTestCase::LookupTimeTestCase ()
|
||||
: TestCase ("Measure average lookup time")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
LookupTimeTestCase::~LookupTimeTestCase ()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
LookupTimeTestCase::DoRun (void)
|
||||
{
|
||||
cout << suite << endl;
|
||||
cout << suite << GetName () << endl;
|
||||
|
||||
|
||||
uint32_t nids = TypeId::GetRegisteredN ();
|
||||
|
||||
int start = clock ();
|
||||
@@ -368,7 +378,7 @@ LookupTimeTestCase::DoRun (void)
|
||||
const TypeId tid = TypeId::GetRegistered (i);
|
||||
const TypeId sid = TypeId::LookupByName (tid.GetName ());
|
||||
}
|
||||
}
|
||||
}
|
||||
int stop = clock ();
|
||||
Report ("name", stop - start);
|
||||
|
||||
@@ -380,17 +390,17 @@ LookupTimeTestCase::DoRun (void)
|
||||
const TypeId tid = TypeId::GetRegistered (i);
|
||||
const TypeId sid = TypeId::LookupByHash (tid.GetHash ());
|
||||
}
|
||||
}
|
||||
}
|
||||
stop = clock ();
|
||||
Report ("hash", stop - start);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LookupTimeTestCase::DoSetup (void)
|
||||
{
|
||||
uint32_t nids = TypeId::GetRegisteredN ();
|
||||
|
||||
|
||||
cout << suite << "Lookup time: reps: " << REPETITIONS
|
||||
<< ", num TypeId's: " << nids
|
||||
<< endl;
|
||||
@@ -403,14 +413,14 @@ LookupTimeTestCase::Report (const std::string how,
|
||||
{
|
||||
double nids = TypeId::GetRegisteredN ();
|
||||
double reps = nids * REPETITIONS;
|
||||
|
||||
|
||||
double per = 1E6 * double(delta) / (reps * double(CLOCKS_PER_SEC));
|
||||
|
||||
|
||||
cout << suite << "Lookup time: by " << how << ": "
|
||||
<< "ticks: " << delta
|
||||
<< "\tper: " << per
|
||||
<< " microsec/lookup"
|
||||
<< endl;
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -423,13 +433,13 @@ class TypeIdTestSuite : public TestSuite
|
||||
public:
|
||||
TypeIdTestSuite ();
|
||||
};
|
||||
|
||||
|
||||
TypeIdTestSuite::TypeIdTestSuite ()
|
||||
: TestSuite ("type-id", UNIT)
|
||||
{
|
||||
// Turn on logging, so we see the result of collisions
|
||||
LogComponentEnable ("TypeId", ns3::LogLevel(LOG_ERROR|LOG_PREFIX_FUNC));
|
||||
|
||||
LogComponentEnable ("TypeId", ns3::LogLevel (LOG_ERROR | LOG_PREFIX_FUNC));
|
||||
|
||||
// If the CollisionTestCase is performed before the
|
||||
// UniqueIdTestCase, the artificial collisions added by
|
||||
// CollisionTestCase will show up in the list of TypeIds
|
||||
@@ -439,15 +449,15 @@ TypeIdTestSuite::TypeIdTestSuite ()
|
||||
AddTestCase (new DeprecatedAttributeTestCase, QUICK);
|
||||
}
|
||||
|
||||
static TypeIdTestSuite g_TypeIdTestSuite;
|
||||
|
||||
static TypeIdTestSuite g_TypeIdTestSuite;
|
||||
|
||||
|
||||
class TypeIdPerformanceSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
TypeIdPerformanceSuite ();
|
||||
};
|
||||
|
||||
|
||||
TypeIdPerformanceSuite::TypeIdPerformanceSuite ()
|
||||
: TestSuite ("type-id-perf", PERFORMANCE)
|
||||
{
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup object-tests
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
/** Constructor. */
|
||||
TypeTraitsTestCase ();
|
||||
/** Destructor. */
|
||||
virtual ~TypeTraitsTestCase () {}
|
||||
virtual ~TypeTraitsTestCase ()
|
||||
{}
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -50,30 +51,29 @@ private:
|
||||
|
||||
TypeTraitsTestCase::TypeTraitsTestCase (void)
|
||||
: TestCase ("Check type traits")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
TypeTraitsTestCase::DoRun (void)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (void)>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (void)");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(void)>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (void)");
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (void) const>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (void) const");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(void) const>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (void) const");
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (int)>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (int)");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(int)>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (int)");
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (int) const>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (int) const");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(int) const>::IsPointerToMember, 1,
|
||||
"Check pointer to member function (int) const");
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (void) const>::PointerToMemberTraits::nArgs, 0,
|
||||
"Check number of arguments for pointer to member function (void) const");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(void) const>::PointerToMemberTraits::nArgs, 0,
|
||||
"Check number of arguments for pointer to member function (void) const");
|
||||
NS_TEST_ASSERT_MSG_EQ
|
||||
(TypeTraits<void (TypeTraitsTestCase::*) (int) const>::PointerToMemberTraits::nArgs, 1,
|
||||
"Check number of arguments for pointer to member function (int) const");
|
||||
(TypeTraits<void (TypeTraitsTestCase::*)(int) const>::PointerToMemberTraits::nArgs, 1,
|
||||
"Check number of arguments for pointer to member function (int) const");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ TypeTraitsTestSuite::TypeTraitsTestSuite ()
|
||||
*/
|
||||
static TypeTraitsTestSuite g_typeTraitsTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
namespace tests {
|
||||
|
||||
namespace tests {
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup timer-tests
|
||||
@@ -53,10 +53,9 @@ public:
|
||||
int m_expiredArgument; //!< Argument supplied to expired Watchdog
|
||||
};
|
||||
|
||||
WatchdogTestCase::WatchdogTestCase()
|
||||
WatchdogTestCase::WatchdogTestCase ()
|
||||
: TestCase ("Check that we can keepalive a watchdog")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
WatchdogTestCase::Expire (int arg)
|
||||
@@ -72,7 +71,7 @@ WatchdogTestCase::DoRun (void)
|
||||
m_expired = false;
|
||||
m_expiredArgument = 0;
|
||||
m_expiredTime = Seconds (0);
|
||||
|
||||
|
||||
Watchdog watchdog;
|
||||
watchdog.SetFunction (&WatchdogTestCase::Expire, this);
|
||||
watchdog.SetArguments (1);
|
||||
@@ -96,7 +95,7 @@ class WatchdogTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
/** Constructor. */
|
||||
WatchdogTestSuite()
|
||||
WatchdogTestSuite ()
|
||||
: TestSuite ("watchdog")
|
||||
{
|
||||
AddTestCase (new WatchdogTestCase ());
|
||||
@@ -110,6 +109,6 @@ public:
|
||||
static WatchdogTestSuite g_watchdogTestSuite;
|
||||
|
||||
|
||||
} // namespace tests
|
||||
} // namespace tests
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
Reference in New Issue
Block a user