From b98955f20a5ff44b855c9a925c28b2b486bcae6a Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr" Date: Fri, 27 Mar 2020 16:40:58 -0700 Subject: [PATCH] core: check-style for core/{examples,helper,test} --- src/core/examples/command-line-example.cc | 14 +- src/core/examples/hash-example.cc | 145 ++-- src/core/examples/main-callback.cc | 16 +- src/core/examples/main-ptr.cc | 10 +- .../examples/main-random-variable-stream.cc | 98 +-- src/core/examples/main-test-sync.cc | 34 +- src/core/examples/sample-log-time-format.cc | 12 +- .../examples/sample-random-variable-stream.cc | 18 +- src/core/examples/sample-random-variable.cc | 16 +- src/core/examples/sample-show-progress.cc | 35 +- src/core/examples/sample-simulator.cc | 3 +- .../examples/test-string-value-formatting.cc | 11 +- src/core/helper/event-garbage-collector.cc | 23 +- .../helper/random-variable-stream-helper.cc | 2 +- src/core/test/attribute-test-suite.cc | 239 ++++--- src/core/test/build-profile-test-suite.cc | 24 +- src/core/test/callback-test-suite.cc | 178 +++-- src/core/test/command-line-test-suite.cc | 88 +-- src/core/test/config-test-suite.cc | 138 ++-- .../event-garbage-collector-test-suite.cc | 16 +- src/core/test/global-value-test-suite.cc | 16 +- src/core/test/hash-test-suite.cc | 72 +- src/core/test/int64x64-test-suite.cc | 644 +++++++++--------- ...variables-one-get-value-call-test-suite.cc | 12 +- src/core/test/names-test-suite.cc | 150 ++-- src/core/test/object-test-suite.cc | 64 +- ...ariable-many-get-value-calls-test-suite.cc | 12 +- src/core/test/ptr-test-suite.cc | 29 +- .../test/random-variable-stream-test-suite.cc | 370 +++++----- src/core/test/rng-test-suite.cc | 26 +- src/core/test/sample-test-suite.cc | 16 +- src/core/test/simulator-test-suite.cc | 33 +- src/core/test/threaded-test-suite.cc | 101 ++- src/core/test/time-test-suite.cc | 56 +- src/core/test/timer-test-suite.cc | 81 +-- src/core/test/traced-callback-test-suite.cc | 8 +- src/core/test/type-id-test-suite.cc | 116 ++-- src/core/test/type-traits-test-suite.cc | 38 +- src/core/test/watchdog-test-suite.cc | 15 +- 39 files changed, 1489 insertions(+), 1490 deletions(-) diff --git a/src/core/examples/command-line-example.cc b/src/core/examples/command-line-example.cc index 9622f91b9..98dec903a 100644 --- a/src/core/examples/command-line-example.cc +++ b/src/core/examples/command-line-example.cc @@ -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) diff --git a/src/core/examples/hash-example.cc b/src/core/examples/hash-example.cc index 9d6aa2141..c351ceca1 100644 --- a/src/core/examples/hash-example.cc +++ b/src/core/examples/hash-example.cc @@ -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 hashdict_t; @@ -262,15 +262,16 @@ private: typedef std::vector < std::pair > 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 ::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 n is the number of entries in the table, and * k 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 (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 ::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::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 () ), Collider::Bits64)); - + files.ReadInto (dict); - + dict.Report (); - + if (timing) { dict.Time (); diff --git a/src/core/examples/main-callback.cc b/src/core/examples/main-callback.cc index fa8faa35b..77d7b12d7 100644 --- a/src/core/examples/main-callback.cc +++ b/src/core/examples/main-callback.cc @@ -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 three; three.Assign (MakeCallback (&CbOne)); diff --git a/src/core/examples/main-ptr.cc b/src/core/examples/main-ptr.cc index 5e02be4c9..878163654 100644 --- a/src/core/examples/main-ptr.cc +++ b/src/core/examples/main-ptr.cc @@ -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 p = CreateObject (); 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 p = CreateObject (); Ptr prev = StorePtr (p); diff --git a/src/core/examples/main-random-variable-stream.cc b/src/core/examples/main-random-variable-stream.cc index 47c947f1a..241e1cda5 100644 --- a/src/core/examples/main-random-variable-stream.cc +++ b/src/core/examples/main-random-variable-stream.cc @@ -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 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 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 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 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 x2 = CreateObject (); 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 x3 = CreateObject (); 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 x2 = CreateObject (); 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 x3 = CreateObject (); 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 x3 = CreateObject (); 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 x5 = CreateObject (); 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 x2 = CreateObject (); 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 x3 = CreateObject (); 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)") ); diff --git a/src/core/examples/main-test-sync.cc b/src/core/examples/main-test-sync.cc index 9adb5e689..dc96c37b1 100644 --- a/src/core/examples/main-test-sync.cc +++ b/src/core/examples/main-test-sync.cc @@ -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 st3 = Create ( - 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 (); diff --git a/src/core/examples/sample-log-time-format.cc b/src/core/examples/sample-log-time-format.cc index 8553253e5..65651ab93 100644 --- a/src/core/examples/sample-log-time-format.cc +++ b/src/core/examples/sample-log-time-format.cc @@ -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 * diff --git a/src/core/examples/sample-random-variable-stream.cc b/src/core/examples/sample-random-variable-stream.cc index f2559bba4..315111096 100644 --- a/src/core/examples/sample-random-variable-stream.cc +++ b/src/core/examples/sample-random-variable-stream.cc @@ -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=" --run program-name` * 3. Through the use of the NS_GLOBAL_VALUE environment variable, such as: * `$ NS_GLOBAL_VALUE="RngRun=" ./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 */ diff --git a/src/core/examples/sample-random-variable.cc b/src/core/examples/sample-random-variable.cc index 9d4462762..a3e16ece1 100644 --- a/src/core/examples/sample-random-variable.cc +++ b/src/core/examples/sample-random-variable.cc @@ -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=" --run program-name` * 3. Through the use of the NS_GLOBAL_VALUE environment variable, such as: * `$ NS_GLOBAL_VALUE="RngRun=" ./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 */ diff --git a/src/core/examples/sample-show-progress.cc b/src/core/examples/sample-show-progress.cc index 7e3060a4e..1e050bd12 100644 --- a/src/core/examples/sample-show-progress.cc +++ b/src/core/examples/sample-show-progress.cc @@ -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 { public: - + Hold (Time wait, Time interval) { m_wait = wait; @@ -90,15 +92,14 @@ public: Hold (Ptr 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 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 h = Create (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 (); } diff --git a/src/core/examples/sample-simulator.cc b/src/core/examples/sample-simulator.cc index d3f8f6ad2..72001ed7f 100644 --- a/src/core/examples/sample-simulator.cc +++ b/src/core/examples/sample-simulator.cc @@ -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. diff --git a/src/core/examples/test-string-value-formatting.cc b/src/core/examples/test-string-value-formatting.cc index 2e294a396..de2016209 100644 --- a/src/core/examples/test-string-value-formatting.cc +++ b/src/core/examples/test-string-value-formatting.cc @@ -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 GetTestVariable (void) const; + private: Ptr m_testVariable; //!< The test variable }; @@ -81,8 +82,7 @@ FormattingTestObject::GetTypeId (void) } FormattingTestObject::FormattingTestObject () -{ -} +{} Ptr 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 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 diff --git a/src/core/helper/event-garbage-collector.cc b/src/core/helper/event-garbage-collector.cc index c7a14602b..97143e9f8 100644 --- a/src/core/helper/event-garbage-collector.cc +++ b/src/core/helper/event-garbage-collector.cc @@ -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 (); + } } diff --git a/src/core/helper/random-variable-stream-helper.cc b/src/core/helper/random-variable-stream-helper.cc index 95238c9c1..5fa5763c6 100644 --- a/src/core/helper/random-variable-stream-helper.cc +++ b/src/core/helper/random-variable-stream-helper.cc @@ -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) { diff --git a/src/core/test/attribute-test-suite.cc b/src/core/test/attribute-test-suite.cc index 2941b5124..b9a91a50e 100644 --- a/src/core/test/attribute-test-suite.cc +++ b/src/core/test/attribute-test-suite.cc @@ -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 () .SetParent () ; 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 () .SetParent () @@ -208,11 +213,11 @@ public: MakePointerAccessor (&AttributeObjectTest::m_ptr), MakePointerChecker ()) .AddAttribute ("PointerInitialized", "help text", - StringValue("ns3::Derived"), + StringValue ("ns3::Derived"), MakePointerAccessor (&AttributeObjectTest::m_ptrInitialized), MakePointerChecker ()) .AddAttribute ("PointerInitialized2", "help text", - StringValue("ns3::Derived[]"), + StringValue ("ns3::Derived[]"), MakePointerAccessor (&AttributeObjectTest::m_ptrInitialized2), MakePointerChecker ()) .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 ()); } - void AddToVector2 (void) { m_vector2.push_back (CreateObject ()); } + void AddToVector1 (void) + { + m_vector1.push_back (CreateObject ()); + } + void AddToVector2 (void) + { + m_vector2.push_back (CreateObject ()); + } - void AddToMap1 (uint32_t i) { m_map1.insert (std::pair > (i, CreateObject ())); } + void AddToMap1 (uint32_t i) + { + m_map1.insert (std::pair > (i, CreateObject ())); + } - 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 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 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 @@ -319,17 +370,15 @@ private: template AttributeTestCase::AttributeTestCase (std::string description) : TestCase (description) -{ -} +{} template AttributeTestCase::~AttributeTestCase () -{ -} +{} template bool AttributeTestCase::CheckGetCodePaths ( - Ptr p, + Ptr p, std::string attributeName, std::string expectedString, T expectedValue) @@ -443,7 +492,7 @@ AttributeTestCase::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::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::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::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::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::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::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::DoRun (void) // The test vectors assume ns resolution Time::SetResolution (Time::NS); - + // // Set value // @@ -738,7 +787,7 @@ AttributeTestCase::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 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. 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, // So see if we can get a Ptr out of the Ptr 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 storedPtr3 = ptr3.Get (); 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 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; diff --git a/src/core/test/build-profile-test-suite.cc b/src/core/test/build-profile-test-suite.cc index 7a82658a5..49e349119 100644 --- a/src/core/test/build-profile-test-suite.cc +++ b/src/core/test/build-profile-test-suite.cc @@ -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 diff --git a/src/core/test/callback-test-suite.cc b/src/core/test/callback-test-suite.cc index c78ec338d..de9789b5c 100644 --- a/src/core/test/callback-test-suite.cc +++ b/src/core/test/callback-test-suite.cc @@ -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 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 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 target3 = Callback (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 target4 = Callback (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 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 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 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 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 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 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 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 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) diff --git a/src/core/test/command-line-test-suite.cc b/src/core/test/command-line-test-suite.cc index eca0338ac..5d8682a28 100644 --- a/src/core/test/command-line-test-suite.cc +++ b/src/core/test/command-line-test-suite.cc @@ -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 - + diff --git a/src/core/test/config-test-suite.cc b/src/core/test/config-test-suite.cc index c1c00e831..abd3f1297 100644 --- a/src/core/test/config-test-suite.cc +++ b/src/core/test/config-test-suite.cc @@ -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 a); - /** + /** * Add node B function * \param b test object b */ @@ -161,25 +161,25 @@ ConfigTestObject::SetNodeB (Ptr b) m_nodeB = b; } -void +void ConfigTestObject::AddNodeA (Ptr a) { m_nodesA.push_back (a); } -void +void ConfigTestObject::AddNodeB (Ptr 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 () - ; + ; 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 ()) - ; + ; 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 () - ; + ; 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 root = CreateObject (); @@ -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 root = CreateObject (); @@ -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 derived = CreateObject (); @@ -857,7 +867,7 @@ ConfigTestSuite::ConfigTestSuite () static ConfigTestSuite g_configTestSuite; - } // namespace tests +} // namespace tests } // namespace ns3 - + diff --git a/src/core/test/event-garbage-collector-test-suite.cc b/src/core/test/event-garbage-collector-test-suite.cc index e4df7fecd..ed37815fe 100644 --- a/src/core/test/event-garbage-collector-test-suite.cc +++ b/src/core/test/event-garbage-collector-test-suite.cc @@ -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 - + diff --git a/src/core/test/global-value-test-suite.cc b/src/core/test/global-value-test-suite.cc index 8bd82c1de..755a37b83 100644 --- a/src/core/test/global-value-test-suite.cc +++ b/src/core/test/global-value-test-suite.cc @@ -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 - + diff --git a/src/core/test/hash-test-suite.cc b/src/core/test/hash-test-suite.cc index e4360e2c5..8e9a24cf5 100644 --- a/src/core/test/hash-test-suite.cc +++ b/src/core/test/hash-test-suite.cc @@ -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 diff --git a/src/core/test/int64x64-test-suite.cc b/src/core/test/int64x64-test-suite.cc index f9e6ce255..bfa17d03f 100644 --- a/src/core/test/int64x64-test-suite.cc +++ b/src/core/test/int64x64-test-suite.cc @@ -29,10 +29,10 @@ using namespace ns3; namespace ns3 { - namespace int64x64 { +namespace int64x64 { + +namespace test { - namespace test { - /** * \class ns3::int64x64::Int64x64TestSuite * \internal @@ -40,7 +40,7 @@ namespace ns3 { * Some of these tests are a little unusual for ns-3 in that they * are sensitive to implementation, specifically the resolution * of the double and long double implementations. - * + * * To handle this, where needed we define a tolerance to use in the * test comparisons. If you need to increase the tolerance, * please append the system and compiler version. For example: @@ -106,10 +106,10 @@ std::ostream & operator << (std::ostream & os, const Printer & p) if (p.m_haveInt) { os << std::fixed << std::setprecision (22) - << p.m_value; + << p.m_value; } - + os << std::hex << std::setfill ('0') << " (0x" << std::setw (16) << p.m_high << " 0x" << std::setw (16) << p.m_low << ")" @@ -128,10 +128,9 @@ public: Int64x64HiLoTestCase::Int64x64HiLoTestCase () : TestCase ("Manipulate the high and low part of every number") -{ -} +{} -void +void Int64x64HiLoTestCase::Check (const int64_t hi, const uint64_t lo) { uint64_t tolerance = 0; @@ -144,20 +143,20 @@ Int64x64HiLoTestCase::Check (const int64_t hi, const uint64_t lo) int64x64_t value = int64x64_t (hi,lo); uint64_t vLow = value.GetLow (); bool pass = ( (value.GetHigh () == hi) - && ( (Max (vLow, lo) - Min (vLow, lo)) <= tolerance) - ); + && ( (Max (vLow, lo) - Min (vLow, lo)) <= tolerance) + ); std::cout << GetParent ()->GetName () << " Check: " - << (pass ? "pass " : "FAIL ") - << Printer (value) << " from" << Printer (hi, lo) - << std::endl; + << (pass ? "pass " : "FAIL ") + << Printer (value) << " from" << Printer (hi, lo) + << std::endl; NS_TEST_EXPECT_MSG_EQ (value.GetHigh (), hi, - "High part does not match for hi:" << hi - << " lo: " << lo); + "High part does not match for hi:" << hi + << " lo: " << lo); NS_TEST_EXPECT_MSG_EQ_TOL ((int64_t)vLow, (int64_t)lo, (int64_t)tolerance, - "Low part does not match for hi: " << hi - << " lo: " << lo); + "Low part does not match for hi: " << hi + << " lo: " << lo); } void @@ -165,7 +164,7 @@ Int64x64HiLoTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Check: " << GetName () - << std::endl; + << std::endl; uint64_t low = 1; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -177,11 +176,11 @@ Int64x64HiLoTestCase::DoRun (void) Check ( 0, 0); Check ( 0, low); Check ( 0, 0xffffffffffffffffULL - low); - + Check ( 1, 0); Check ( 1, low); Check ( 1, 0xffffffffffffffffULL - low); - + Check (-1, 0); Check (-1, low); Check (-1, 0xffffffffffffffffULL - low); @@ -194,18 +193,17 @@ public: Int64x64InputTestCase (); virtual void DoRun (void); void Check (const std::string & str, - const int64_t hi, const uint64_t lo, - const int64_t tolerance = 0); + const int64_t hi, const uint64_t lo, + const int64_t tolerance = 0); }; Int64x64InputTestCase::Int64x64InputTestCase () : TestCase ("Parse int64x64_t numbers as strings") -{ -} -void +{} +void Int64x64InputTestCase::Check (const std::string & str, - const int64_t hi, const uint64_t lo, - const int64_t tolerance /* = 0 */) - + const int64_t hi, const uint64_t lo, + const int64_t tolerance /* = 0 */) + { std::istringstream iss; iss.str (str); @@ -214,30 +212,30 @@ Int64x64InputTestCase::Check (const std::string & str, std::string input = "\"" + str + "\""; uint64_t vLow = value.GetLow (); - bool pass = ( (value.GetHigh () == hi) && - ( Max (vLow, lo) - Min (vLow, lo) <= tolerance) - ); + bool pass = ( (value.GetHigh () == hi) + && ( Max (vLow, lo) - Min (vLow, lo) <= tolerance) + ); std::cout << GetParent ()->GetName () << " Input: " - << (pass ? "pass " : "FAIL ") - << std::left << std::setw (28) << input << std::right - << Printer (value) - << " expected: " << Printer (hi, lo) << " +/- " << tolerance - << std::endl; + << (pass ? "pass " : "FAIL ") + << std::left << std::setw (28) << input << std::right + << Printer (value) + << " expected: " << Printer (hi, lo) << " +/- " << tolerance + << std::endl; NS_TEST_EXPECT_MSG_EQ (value.GetHigh (), hi, - "High parts do not match for input string \"" - << str << "\""); + "High parts do not match for input string \"" + << str << "\""); NS_TEST_EXPECT_MSG_EQ_TOL ((int64_t)value.GetLow (), (int64_t)lo, tolerance, - "Low parts do not match for input string \"" - << str << "\""); + "Low parts do not match for input string \"" + << str << "\""); } void Int64x64InputTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Input: " << GetName () - << std::endl; + << std::endl; int64_t tolerance = 0; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -245,7 +243,7 @@ Int64x64InputTestCase::DoRun (void) // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 tolerance = 2; } - + Check ("1", 1, 0); Check ("+1", 1, 0); Check ("-1", -1, 0); @@ -269,15 +267,14 @@ public: Int64x64InputOutputTestCase (); virtual void DoRun (void); void Check (const std::string & str, - const int64_t tolerance = 0); + const int64_t tolerance = 0); }; Int64x64InputOutputTestCase::Int64x64InputOutputTestCase () : TestCase ("Roundtrip int64x64_t numbers as strings") -{ -} -void +{} +void Int64x64InputOutputTestCase::Check (const std::string & str, - const int64_t tolerance /* = 0 */) + const int64_t tolerance /* = 0 */) { std::stringstream iss (str); int64x64_t expect; @@ -296,28 +293,28 @@ Int64x64InputOutputTestCase::Check (const std::string & str, if (pass) { std::cout << GetParent ()->GetName () << " InputOutput: " - << (pass ? "pass " : "FAIL ") - << " in: " << std::left << std::setw (28) << input - << " out: " << std::left << std::setw (28) << output - << std::right - << std::endl; + << (pass ? "pass " : "FAIL ") + << " in: " << std::left << std::setw (28) << input + << " out: " << std::left << std::setw (28) << output + << std::right + << std::endl; } else { std::cout << GetParent ()->GetName () << " InputOutput: " - << (pass ? "pass " : "FAIL ") - << " in: " << std::left << std::setw (28) << input - << std::right << Printer (expect) - << std::endl; + << (pass ? "pass " : "FAIL ") + << " in: " << std::left << std::setw (28) << input + << std::right << Printer (expect) + << std::endl; std::cout << GetParent ()->GetName () - << std::setw (19) << " " - << " out: " << std::left << std::setw (28) << output - << std::right << Printer (value) - << std::endl; - } + << std::setw (19) << " " + << " out: " << std::left << std::setw (28) << output + << std::right << Printer (value) + << std::endl; + } NS_TEST_EXPECT_MSG_EQ_TOL (value, expect, int64x64_t (0, tolerance), - "Converted string does not match expected string"); + "Converted string does not match expected string"); } void @@ -325,7 +322,7 @@ Int64x64InputOutputTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " InputOutput: " << GetName () - << std::endl; + << std::endl; int64_t tolerance = 0; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -333,7 +330,7 @@ Int64x64InputOutputTestCase::DoRun (void) // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 tolerance = 1; } - + Check ("+1.000000000000000000000"); Check ("+20.000000000000000000000"); Check ("+0.000000000000000000000", tolerance); @@ -351,40 +348,39 @@ public: Int64x64ArithmeticTestCase (); virtual void DoRun (void); void Check (const int test, - const int64x64_t value, const int64x64_t expect); + const int64x64_t value, const int64x64_t expect); void Check (const int test, - const int64x64_t value, const int64x64_t expect, - const int64x64_t tolerance); + const int64x64_t value, const int64x64_t expect, + const int64x64_t tolerance); }; Int64x64ArithmeticTestCase::Int64x64ArithmeticTestCase () : TestCase ("Basic arithmetic operations") -{ -} +{} void Int64x64ArithmeticTestCase::Check (const int test, - const int64x64_t value, - const int64x64_t expect) + const int64x64_t value, + const int64x64_t expect) { int64x64_t zero (0,0); Check (test, value, expect, zero); } void Int64x64ArithmeticTestCase::Check (const int test, - const int64x64_t value, - const int64x64_t expect, - const int64x64_t tolerance) + const int64x64_t value, + const int64x64_t expect, + const int64x64_t tolerance) { bool pass = Abs (value - expect) <= tolerance; - + std::cout << GetParent ()->GetName () << " Arithmetic: " - << (pass ? "pass " : "FAIL ") - << test << ": " << value << " == " << expect - << " (+/- " << tolerance << ")" - << std::endl; - + << (pass ? "pass " : "FAIL ") + << test << ": " << value << " == " << expect + << " (+/- " << tolerance << ")" + << std::endl; + NS_TEST_ASSERT_MSG_EQ_TOL ( value, expect, tolerance, - "Arithmetic failure in test case " << test); + "Arithmetic failure in test case " << test); } void @@ -398,92 +394,92 @@ Int64x64ArithmeticTestCase::DoRun (void) std::cout << std::endl; std::cout << GetParent ()->GetName () << " Arithmetic: " << GetName () - << std::endl; - - Check ( 0, zero - zero , zero ); - Check ( 1, zero - one , -one ); - Check ( 2, one - one , zero ); - Check ( 3, one - two , -one ); + << std::endl; + + Check ( 0, zero - zero, zero ); + Check ( 1, zero - one, -one ); + Check ( 2, one - one, zero ); + Check ( 3, one - two, -one ); Check ( 4, one - (-one ), two ); Check ( 5, (-one ) - (-two ), one ); - Check ( 6, (-one ) - two , -thre ); - - Check ( 7, zero + zero , zero ); - Check ( 8, zero + one , one ); - Check ( 9, one + one , two ); - Check (10, one + two , thre ); + Check ( 6, (-one ) - two, -thre ); + + Check ( 7, zero + zero, zero ); + Check ( 8, zero + one, one ); + Check ( 9, one + one, two ); + Check (10, one + two, thre ); Check (11, one + (-one ), zero ); Check (12, (-one ) + (-two ), -thre ); - Check (13, (-one ) + two , one ); - - Check (14, zero * zero , zero ); - Check (15, zero * one , zero ); + Check (13, (-one ) + two, one ); + + Check (14, zero * zero, zero ); + Check (15, zero * one, zero ); Check (16, zero * (-one ), zero ); - Check (17, one * one , one ); + Check (17, one * one, one ); Check (18, one * (-one ), -one ); Check (19, (-one ) * (-one ), one ); - - Check (20, (two * thre ) / thre , two ); + + Check (20, (two * thre ) / thre, two ); const int64x64_t frac = int64x64_t (0, 0xc000000000000000ULL); // 0.75 const int64x64_t fplf2 = frac + frac * frac; // 1.3125 - + Check (21, frac, 0.75); Check (22, fplf2, 1.3125); - + const int64x64_t zerof = zero + frac; const int64x64_t onef = one + frac; const int64x64_t twof = two + frac; const int64x64_t thref = thre + frac; Check (23, zerof, frac); - - + + Check (24, zerof - zerof, zero ); Check (25, zerof - onef, -one ); Check (26, onef - onef, zero ); Check (27, onef - twof, -one ); Check (28, onef - (-onef), twof + frac ); - Check (29 , (-onef) - (-twof), one ); - Check (30 , (-onef) - twof, -thref - frac ); - + Check (29, (-onef) - (-twof), one ); + Check (30, (-onef) - twof, -thref - frac ); + Check (31, zerof + zerof, zerof + frac ); Check (32, zerof + onef, onef + frac ); Check (33, onef + onef, twof + frac ); Check (34, onef + twof, thref + frac ); Check (35, onef + (-onef), zero ); - Check (36 , (-onef) + (-twof), -thref - frac ); + Check (36, (-onef) + (-twof), -thref - frac ); Check (37, (-onef) + twof, one ); - + Check (38, zerof * zerof, frac * frac ); - Check (39 , zero * onef, zero ); - Check (40 , zerof * one, frac ); - + Check (39, zero * onef, zero ); + Check (40, zerof * one, frac ); + Check (41, zerof * onef, fplf2 ); Check (42, zerof * (-onef), -fplf2 ); Check (43, onef * onef, onef + fplf2 ); Check (44, onef * (-onef), -onef - fplf2 ); Check (45, (-onef) * (-onef), onef + fplf2 ); - - + + // Multiplication followed by division is exact: - Check (46, (two * thre ) / thre , two ); + Check (46, (two * thre ) / thre, two ); Check (47, (twof * thref) / thref, twof ); // Division followed by multiplication loses a bit or two: - Check (48, (two / thre) * thre, two , 2 * tol1 ); + Check (48, (two / thre) * thre, two, 2 * tol1 ); Check (49, (twof / thref) * thref, twof, 3 * tol1 ); // The example below shows that we really do not lose // much precision internally: it is almost always the // final conversion which loses precision. Check (50, (int64x64_t (2000000000) / int64x64_t (3)) * int64x64_t (3), - int64x64_t (1999999999, 0xfffffffffffffffeULL)); + int64x64_t (1999999999, 0xfffffffffffffffeULL)); // Check special values Check (51, int64x64_t (0, 0x159fa87f8aeaad21ULL) * 10, - int64x64_t (0, 0xd83c94fb6d2ac34aULL)); - + int64x64_t (0, 0xd83c94fb6d2ac34aULL)); + } @@ -497,26 +493,25 @@ public: Int64x64Bug455TestCase (); virtual void DoRun (void); void Check (const double result, const double expect, - const std::string & msg); + const std::string & msg); }; Int64x64Bug455TestCase::Int64x64Bug455TestCase () : TestCase ("Test case for bug 455") -{ -} +{} void Int64x64Bug455TestCase::Check (const double result, const double expect, - const std::string & msg) + const std::string & msg) { bool pass = result == expect; - + std::cout << GetParent ()->GetName () << " Bug 455: " - << (pass ? "pass " : "FAIL ") - << "res: " << result - << " exp: " << expect - << ": " << msg - << std::endl; - + << (pass ? "pass " : "FAIL ") + << "res: " << result + << " exp: " << expect + << ": " << msg + << std::endl; + NS_TEST_ASSERT_MSG_EQ (result, expect, msg); } @@ -525,24 +520,24 @@ Int64x64Bug455TestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Bug 455: " << GetName () - << std::endl; - + << std::endl; + int64x64_t a = int64x64_t (0.1); a /= int64x64_t (1.25); Check (a.GetDouble (), 0.08, "The original testcase"); - + a = int64x64_t (0.5); a *= int64x64_t (5); Check (a.GetDouble (), 2.5, "Simple test for multiplication"); - + a = int64x64_t (-0.5); a *= int64x64_t (5); Check (a.GetDouble (), -2.5, "Test sign, first operation negative"); - + a = int64x64_t (-0.5); - a *=int64x64_t (-5); + a *= int64x64_t (-5); Check (a.GetDouble (), 2.5, "both operands negative"); - + a = int64x64_t (0.5); a *= int64x64_t (-5); Check (a.GetDouble (), -2.5, "only second operand negative"); @@ -559,26 +554,25 @@ public: Int64x64Bug863TestCase (); virtual void DoRun (void); void Check (const double result, const double expect, - const std::string & msg); + const std::string & msg); }; Int64x64Bug863TestCase::Int64x64Bug863TestCase () : TestCase ("Test case for bug 863") -{ -} +{} void Int64x64Bug863TestCase::Check (const double result, const double expect, - const std::string & msg) + const std::string & msg) { bool pass = result == expect; - + std::cout << GetParent ()->GetName () << " Bug 863: " - << (pass ? "pass " : "FAIL ") - << "res: " << result - << " exp: " << expect - << ": " << msg - << std::endl; - + << (pass ? "pass " : "FAIL ") + << "res: " << result + << " exp: " << expect + << ": " << msg + << std::endl; + NS_TEST_ASSERT_MSG_EQ (result, expect, msg); } @@ -587,26 +581,26 @@ Int64x64Bug863TestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Bug 863: " << GetName () - << std::endl; - + << std::endl; + int64x64_t a = int64x64_t (0.9); a /= int64x64_t (1); Check (a.GetDouble (), 0.9, "The original testcase"); - + a = int64x64_t (0.5); a /= int64x64_t (0.5); Check (a.GetDouble (), 1.0, "Simple test for division"); - + a = int64x64_t (-0.5); Check (a.GetDouble (), -0.5, "Check that we actually convert doubles correctly"); - + a /= int64x64_t (0.5); Check (a.GetDouble (), -1.0, "first argument negative"); - + a = int64x64_t (0.5); a /= int64x64_t (-0.5); Check (a.GetDouble (), -1.0, "second argument negative"); - + a = int64x64_t (-0.5); a /= int64x64_t (-0.5); Check (a.GetDouble (), 1.0, "both arguments negative"); @@ -622,17 +616,16 @@ public: Int64x64Bug1786TestCase (); virtual void DoRun (void); void Check (const uint64_t low, const std::string & value, - const int64_t tolerance = 0); + const int64_t tolerance = 0); }; Int64x64Bug1786TestCase::Int64x64Bug1786TestCase () : TestCase ("Test case for bug 1786") -{ -} +{} void Int64x64Bug1786TestCase::Check (const uint64_t low, - const std::string & str, - const int64_t tolerance /* = 0 */) + const std::string & str, + const int64_t tolerance /* = 0 */) { int64x64_t value (0, low); std::ostringstream oss; @@ -641,30 +634,30 @@ Int64x64Bug1786TestCase::Check (const uint64_t low, if (tolerance == 0) { bool pass = oss.str () == str; - + std::cout << GetParent ()->GetName () << " Bug 1786: " - << (pass ? "pass " : "FAIL ") - << " 0x" << std::hex << std::setw (16) << low << std::dec - << " = " << oss.str (); + << (pass ? "pass " : "FAIL ") + << " 0x" << std::hex << std::setw (16) << low << std::dec + << " = " << oss.str (); if (!pass) - { - std::cout << ", expected " << str; - } + { + std::cout << ", expected " << str; + } std::cout << std::endl; NS_TEST_EXPECT_MSG_EQ (oss.str (), str, - "Fraction string not correct"); + "Fraction string not correct"); } else { // No obvious way to implement a tolerance on the strings - + std::cout << GetParent ()->GetName () << " Bug 1786: " - << "skip " - << " 0x" << std::hex << std::setw (16) << low << std::dec - << " = " << oss.str () - << ", expected " << str - << std::endl; + << "skip " + << " 0x" << std::hex << std::setw (16) << low << std::dec + << " = " << oss.str () + << ", expected " << str + << std::endl; } } @@ -673,7 +666,7 @@ Int64x64Bug1786TestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " But 1786: " << GetName () - << std::endl; + << std::endl; int64_t tolerance = 0; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -756,23 +749,22 @@ public: virtual void DoRun (void); void Check (const bool result, const bool expect, - const std::string & msg); + const std::string & msg); }; Int64x64CompareTestCase::Int64x64CompareTestCase () : TestCase ("Basic compare operations") -{ -} +{} void Int64x64CompareTestCase::Check (const bool result, const bool expect, - const std::string & msg) + const std::string & msg) { bool pass = result == expect; - + std::cout << GetParent ()->GetName () << " Compare: " - << (pass ? "pass " : "FAIL ") - << msg - << std::endl; - + << (pass ? "pass " : "FAIL ") + << msg + << std::endl; + NS_TEST_ASSERT_MSG_EQ (result, expect, msg); } @@ -781,7 +773,7 @@ Int64x64CompareTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Compare: " << GetName () - << std::endl; + << std::endl; const int64x64_t zero ( 0, 0); const int64x64_t one ( 1, 0); @@ -793,7 +785,7 @@ Int64x64CompareTestCase::DoRun (void) const int64x64_t onef = one + frac; const int64x64_t monef = mone - frac; const int64x64_t mtwof = mtwo - frac; - + Check ( zerof == zerof, true, "equality, zero"); Check ( onef == onef, true, "equality, positive"); Check ( mtwof == mtwof, true, "equality, negative"); @@ -862,24 +854,23 @@ public: virtual void DoRun (void); void Check (const int64_t factor); void CheckCase (const uint64_t factor, - const int64x64_t result, const int64x64_t expect, - const std::string & msg, - const double tolerance = 0); + const int64x64_t result, const int64x64_t expect, + const std::string & msg, + const double tolerance = 0); }; Int64x64InvertTestCase::Int64x64InvertTestCase () : TestCase ("Invert and MulByInvert") -{ -} +{} void Int64x64InvertTestCase::CheckCase (const uint64_t factor, - const int64x64_t result, - const int64x64_t expect, - const std::string & msg, - const double tolerance /* = 0 */) + const int64x64_t result, + const int64x64_t expect, + const std::string & msg, + const double tolerance /* = 0 */) { bool pass = Abs (result - expect) <= tolerance; - + std::cout << GetParent ()->GetName () << " Invert: "; if (pass) @@ -890,14 +881,14 @@ Int64x64InvertTestCase::CheckCase (const uint64_t factor, else { std::cout << "FAIL: " << factor << ": " - << "(res: " << result - << " exp: " << expect - << " tol: " << tolerance << ") "; + << "(res: " << result + << " exp: " << expect + << " tol: " << tolerance << ") "; } - std::cout << msg - << std::endl; - - NS_TEST_ASSERT_MSG_EQ_TOL (result, expect, int64x64_t(tolerance), msg); + std::cout << msg + << std::endl; + + NS_TEST_ASSERT_MSG_EQ_TOL (result, expect, int64x64_t (tolerance), msg); } void @@ -905,7 +896,7 @@ Int64x64InvertTestCase::Check (const int64_t factor) { const int64x64_t one (1, 0); const int64x64_t factorI = one / int64x64_t (factor); - + const int64x64_t a = int64x64_t::Invert (factor); int64x64_t b = int64x64_t (factor); @@ -915,18 +906,18 @@ Int64x64InvertTestCase::Check (const int64_t factor) // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 tolerance = 0.000000000000000001L; } - + b.MulByInvert (a); CheckCase (factor, b, one, "x * x^-1 == 1", tolerance); - + int64x64_t c = int64x64_t (1); c.MulByInvert (a); CheckCase (factor, c, factorI, "1 * x^-1 == 1 / x"); - + int64x64_t d = int64x64_t (1); d /= (int64x64_t (factor)); CheckCase (factor, d, c, "1/x == x^-1"); - + int64x64_t e = int64x64_t (-factor); e.MulByInvert (a); CheckCase (factor, e, -one, "-x * x^-1 == -1", tolerance); @@ -937,8 +928,8 @@ Int64x64InvertTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Invert: " << GetName () - << std::endl; - + << std::endl; + Check (2); Check (3); Check (4); @@ -971,8 +962,9 @@ public: virtual void DoRun (void); void Check (const int64_t intPart); void Check (const long double value, - const int64_t intPart, - const uint64_t lo); + const int64_t intPart, + const uint64_t lo); + private: long double m_last; int64x64_t m_deltaMax; @@ -981,13 +973,12 @@ private: Int64x64DoubleTestCase::Int64x64DoubleTestCase () : TestCase ("Construct from floating point.") -{ -} +{} void Int64x64DoubleTestCase::Check (const long double value, - const int64_t intPart, - const uint64_t lo) + const int64_t intPart, + const uint64_t lo) { // Construct the expected value int64x64_t expect = int64x64_t (0, lo); @@ -1014,58 +1005,58 @@ Int64x64DoubleTestCase::Check (const long double value, } const int64x64_t tolerance = (margin + std::fabs (value)) * epsilon; - + const int64x64_t delta = Abs (result - expect); const bool skip = value == m_last; const bool pass = delta <= tolerance; - + // Save stream format flags std::ios_base::fmtflags ff = std::cout.flags (); std::cout << std::fixed << std::setprecision (22); - + std::cout << GetParent ()->GetName () << " Double: " - << (skip ? "skip " : (pass ? "pass " : "FAIL ")) - << std::showpos << value << " == " - << Printer (result) - << std::endl; - + << (skip ? "skip " : (pass ? "pass " : "FAIL ")) + << std::showpos << value << " == " + << Printer (result) + << std::endl; + // Log non-zero delta - if ( delta > int64x64_t() ) + if ( delta > int64x64_t () ) { std::cout << GetParent ()->GetName () - << std::left << std::setw (43) << " expected" - << std::right << Printer (expect) - << std::endl; + << std::left << std::setw (43) << " expected" + << std::right << Printer (expect) + << std::endl; if (delta == tolerance) - { - std::cout << GetParent ()->GetName () - << std::left << std::setw (43) << " delta = tolerance" - << std::right << Printer (delta) - << std::endl; - } + { + std::cout << GetParent ()->GetName () + << std::left << std::setw (43) << " delta = tolerance" + << std::right << Printer (delta) + << std::endl; + } else - { - std::cout << GetParent ()->GetName () - << std::left << std::setw (43) << " delta" - << std::right << Printer (delta) - << std::endl; - std::cout << GetParent ()->GetName () - << std::left << std::setw (43) << " +/-" - << std::right << Printer (tolerance) - << std::endl; - } - + { + std::cout << GetParent ()->GetName () + << std::left << std::setw (43) << " delta" + << std::right << Printer (delta) + << std::endl; + std::cout << GetParent ()->GetName () + << std::left << std::setw (43) << " +/-" + << std::right << Printer (tolerance) + << std::endl; + } + ++m_deltaCount; - + if ( delta > m_deltaMax ) - { - m_deltaMax = delta; - } + { + m_deltaMax = delta; + } } - + NS_TEST_ASSERT_MSG_EQ_TOL (result, expect, tolerance, - "int64x64_t (long double) failed"); + "int64x64_t (long double) failed"); m_last = value; std::cout.flags (ff); @@ -1076,80 +1067,80 @@ Int64x64DoubleTestCase::Check (const int64_t intPart) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Double: " - << "integer: " << intPart - << std::endl; + << "integer: " << intPart + << std::endl; m_last = static_cast (intPart); m_deltaCount = 0; // Nudging the integer part eliminates deltas around 0 long double v = static_cast (intPart); - - Check (v +0.0000000000000000000542L, intPart, 0x1ULL); - Check (v +0.0000000000000000001084L, intPart, 0x2ULL); - Check (v +0.0000000000000000001626L, intPart, 0x3ULL); - Check (v +0.0000000000000000002168L, intPart, 0x4ULL); - Check (v +0.0000000000000000002710L, intPart, 0x5ULL); - Check (v +0.0000000000000000003253L, intPart, 0x6ULL); - Check (v +0.0000000000000000003795L, intPart, 0x7ULL); - Check (v +0.0000000000000000004337L, intPart, 0x8ULL); - Check (v +0.0000000000000000004879L, intPart, 0x9ULL); - Check (v +0.0000000000000000005421L, intPart, 0xAULL); - Check (v +0.0000000000000000008132L, intPart, 0xFULL); - Check (v +0.0000000000000000130104L, intPart, 0xF0ULL); - Check (v +0.0000000000000002081668L, intPart, 0xF00ULL); - Check (v +0.0000000000000033306691L, intPart, 0xF000ULL); - Check (v +0.0000000000000532907052L, intPart, 0xF0000ULL); - Check (v +0.0000000000008526512829L, intPart, 0xF00000ULL); - Check (v +0.0000000000136424205266L, intPart, 0xF000000ULL); - Check (v +0.0000000002182787284255L, intPart, 0xF0000000ULL); - Check (v +0.0000000034924596548080L, intPart, 0xF00000000ULL); - Check (v +0.0000000558793544769287L, intPart, 0xF000000000ULL); - Check (v +0.0000008940696716308594L, intPart, 0xF0000000000ULL); - Check (v +0.0000143051147460937500L, intPart, 0xF00000000000ULL); - Check (v +0.0002288818359375000000L, intPart, 0xF000000000000ULL); - Check (v +0.0036621093750000000000L, intPart, 0xF0000000000000ULL); - Check (v +0.0585937500000000000000L, intPart, 0xF00000000000000ULL); + + Check (v + 0.0000000000000000000542L, intPart, 0x1ULL); + Check (v + 0.0000000000000000001084L, intPart, 0x2ULL); + Check (v + 0.0000000000000000001626L, intPart, 0x3ULL); + Check (v + 0.0000000000000000002168L, intPart, 0x4ULL); + Check (v + 0.0000000000000000002710L, intPart, 0x5ULL); + Check (v + 0.0000000000000000003253L, intPart, 0x6ULL); + Check (v + 0.0000000000000000003795L, intPart, 0x7ULL); + Check (v + 0.0000000000000000004337L, intPart, 0x8ULL); + Check (v + 0.0000000000000000004879L, intPart, 0x9ULL); + Check (v + 0.0000000000000000005421L, intPart, 0xAULL); + Check (v + 0.0000000000000000008132L, intPart, 0xFULL); + Check (v + 0.0000000000000000130104L, intPart, 0xF0ULL); + Check (v + 0.0000000000000002081668L, intPart, 0xF00ULL); + Check (v + 0.0000000000000033306691L, intPart, 0xF000ULL); + Check (v + 0.0000000000000532907052L, intPart, 0xF0000ULL); + Check (v + 0.0000000000008526512829L, intPart, 0xF00000ULL); + Check (v + 0.0000000000136424205266L, intPart, 0xF000000ULL); + Check (v + 0.0000000002182787284255L, intPart, 0xF0000000ULL); + Check (v + 0.0000000034924596548080L, intPart, 0xF00000000ULL); + Check (v + 0.0000000558793544769287L, intPart, 0xF000000000ULL); + Check (v + 0.0000008940696716308594L, intPart, 0xF0000000000ULL); + Check (v + 0.0000143051147460937500L, intPart, 0xF00000000000ULL); + Check (v + 0.0002288818359375000000L, intPart, 0xF000000000000ULL); + Check (v + 0.0036621093750000000000L, intPart, 0xF0000000000000ULL); + Check (v + 0.0585937500000000000000L, intPart, 0xF00000000000000ULL); std::cout << std::endl; - Check (v +0.4999999999999999998374L, intPart, 0x7FFFFFFFFFFFFFFDULL); - Check (v +0.4999999999999999998916L, intPart, 0x7FFFFFFFFFFFFFFEULL); - Check (v +0.4999999999999999999458L, intPart, 0x7FFFFFFFFFFFFFFFULL); - Check (v +0.5000000000000000000000L, intPart, 0x8000000000000000ULL); - Check (v +0.5000000000000000000542L, intPart, 0x8000000000000001ULL); - Check (v +0.5000000000000000001084L, intPart, 0x8000000000000002ULL); - Check (v +0.5000000000000000001626L, intPart, 0x8000000000000003ULL); + Check (v + 0.4999999999999999998374L, intPart, 0x7FFFFFFFFFFFFFFDULL); + Check (v + 0.4999999999999999998916L, intPart, 0x7FFFFFFFFFFFFFFEULL); + Check (v + 0.4999999999999999999458L, intPart, 0x7FFFFFFFFFFFFFFFULL); + Check (v + 0.5000000000000000000000L, intPart, 0x8000000000000000ULL); + Check (v + 0.5000000000000000000542L, intPart, 0x8000000000000001ULL); + Check (v + 0.5000000000000000001084L, intPart, 0x8000000000000002ULL); + Check (v + 0.5000000000000000001626L, intPart, 0x8000000000000003ULL); std::cout << std::endl; - Check (v +0.9375000000000000000000L, intPart, 0xF000000000000000ULL); - Check (v +0.9960937500000000000000L, intPart, 0xFF00000000000000ULL); - Check (v +0.9997558593750000000000L, intPart, 0xFFF0000000000000ULL); - Check (v +0.9999847412109375000000L, intPart, 0xFFFF000000000000ULL); - Check (v +0.9999990463256835937500L, intPart, 0xFFFFF00000000000ULL); - Check (v +0.9999999403953552246094L, intPart, 0xFFFFFF0000000000ULL); - Check (v +0.9999999962747097015381L, intPart, 0xFFFFFFF000000000ULL); - Check (v +0.9999999997671693563461L, intPart, 0xFFFFFFFF00000000ULL); - Check (v +0.9999999999854480847716L, intPart, 0xFFFFFFFFF0000000ULL); - Check (v +0.9999999999990905052982L, intPart, 0xFFFFFFFFFF000000ULL); - Check (v +0.9999999999999431565811L, intPart, 0xFFFFFFFFFFF00000ULL); - Check (v +0.9999999999999964472863L, intPart, 0xFFFFFFFFFFFF0000ULL); - Check (v +0.9999999999999997779554L, intPart, 0xFFFFFFFFFFFFF000ULL); - Check (v +0.9999999999999999861222L, intPart, 0xFFFFFFFFFFFFFF00ULL); - Check (v +0.9999999999999999991326L, intPart, 0xFFFFFFFFFFFFFFF0ULL); - Check (v +0.9999999999999999994037L, intPart, 0xFFFFFFFFFFFFFFF5ULL); - Check (v +0.9999999999999999994579L, intPart, 0xFFFFFFFFFFFFFFF6ULL); - Check (v +0.9999999999999999995121L, intPart, 0xFFFFFFFFFFFFFFF7ULL); - Check (v +0.9999999999999999995663L, intPart, 0xFFFFFFFFFFFFFFF8ULL); - Check (v +0.9999999999999999996205L, intPart, 0xFFFFFFFFFFFFFFF9ULL); - Check (v +0.9999999999999999996747L, intPart, 0xFFFFFFFFFFFFFFFAULL); - Check (v +0.9999999999999999997289L, intPart, 0xFFFFFFFFFFFFFFFBULL); - Check (v +0.9999999999999999997832L, intPart, 0xFFFFFFFFFFFFFFFCULL); - Check (v +0.9999999999999999998374L, intPart, 0xFFFFFFFFFFFFFFFDULL); - Check (v +0.9999999999999999998916L, intPart, 0xFFFFFFFFFFFFFFFEULL); - Check (v +0.9999999999999999999458L, intPart, 0xFFFFFFFFFFFFFFFFULL); + Check (v + 0.9375000000000000000000L, intPart, 0xF000000000000000ULL); + Check (v + 0.9960937500000000000000L, intPart, 0xFF00000000000000ULL); + Check (v + 0.9997558593750000000000L, intPart, 0xFFF0000000000000ULL); + Check (v + 0.9999847412109375000000L, intPart, 0xFFFF000000000000ULL); + Check (v + 0.9999990463256835937500L, intPart, 0xFFFFF00000000000ULL); + Check (v + 0.9999999403953552246094L, intPart, 0xFFFFFF0000000000ULL); + Check (v + 0.9999999962747097015381L, intPart, 0xFFFFFFF000000000ULL); + Check (v + 0.9999999997671693563461L, intPart, 0xFFFFFFFF00000000ULL); + Check (v + 0.9999999999854480847716L, intPart, 0xFFFFFFFFF0000000ULL); + Check (v + 0.9999999999990905052982L, intPart, 0xFFFFFFFFFF000000ULL); + Check (v + 0.9999999999999431565811L, intPart, 0xFFFFFFFFFFF00000ULL); + Check (v + 0.9999999999999964472863L, intPart, 0xFFFFFFFFFFFF0000ULL); + Check (v + 0.9999999999999997779554L, intPart, 0xFFFFFFFFFFFFF000ULL); + Check (v + 0.9999999999999999861222L, intPart, 0xFFFFFFFFFFFFFF00ULL); + Check (v + 0.9999999999999999991326L, intPart, 0xFFFFFFFFFFFFFFF0ULL); + Check (v + 0.9999999999999999994037L, intPart, 0xFFFFFFFFFFFFFFF5ULL); + Check (v + 0.9999999999999999994579L, intPart, 0xFFFFFFFFFFFFFFF6ULL); + Check (v + 0.9999999999999999995121L, intPart, 0xFFFFFFFFFFFFFFF7ULL); + Check (v + 0.9999999999999999995663L, intPart, 0xFFFFFFFFFFFFFFF8ULL); + Check (v + 0.9999999999999999996205L, intPart, 0xFFFFFFFFFFFFFFF9ULL); + Check (v + 0.9999999999999999996747L, intPart, 0xFFFFFFFFFFFFFFFAULL); + Check (v + 0.9999999999999999997289L, intPart, 0xFFFFFFFFFFFFFFFBULL); + Check (v + 0.9999999999999999997832L, intPart, 0xFFFFFFFFFFFFFFFCULL); + Check (v + 0.9999999999999999998374L, intPart, 0xFFFFFFFFFFFFFFFDULL); + Check (v + 0.9999999999999999998916L, intPart, 0xFFFFFFFFFFFFFFFEULL); + Check (v + 0.9999999999999999999458L, intPart, 0xFFFFFFFFFFFFFFFFULL); std::cout << GetParent ()->GetName () << " Double: " - << "integer: " << intPart - << ": delta count: " << m_deltaCount - << ", max: " << Printer (m_deltaMax) - << std::endl; + << "integer: " << intPart + << ": delta count: " << m_deltaCount + << ", max: " << Printer (m_deltaMax) + << std::endl; } void @@ -1157,7 +1148,7 @@ Int64x64DoubleTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Double: " << GetName () - << std::endl; + << std::endl; // Save stream format flags std::ios_base::fmtflags ff = std::cout.flags (); @@ -1166,8 +1157,8 @@ Int64x64DoubleTestCase::DoRun (void) m_deltaMax = int64x64_t (); std::cout << GetParent ()->GetName () << " Double: " - << std::endl; - + << std::endl; + Check (-2); Check (-1); Check ( 0); @@ -1175,8 +1166,8 @@ Int64x64DoubleTestCase::DoRun (void) Check ( 2); std::cout << GetParent ()->GetName () << " Double: " - << "max delta: " << Printer (m_deltaMax) - << std::endl; + << "max delta: " << Printer (m_deltaMax) + << std::endl; std::cout.flags (ff); } @@ -1191,24 +1182,25 @@ public: Int64x64ImplTestCase::Int64x64ImplTestCase () : TestCase ("Print the implementation") -{ -} +{} void Int64x64ImplTestCase::DoRun (void) { std::cout << std::endl; std::cout << GetParent ()->GetName () << " Impl: " << GetName () - << std::endl; + << std::endl; + - std::cout << "int64x64_t::implementation: "; switch (int64x64_t::implementation) { + /* *NS_CHECK_STYLE_OFF* */ case (int64x64_t::int128_impl) : std::cout << "int128_impl"; break; case (int64x64_t::cairo_impl) : std::cout << "cairo_impl"; break; case (int64x64_t::ld_impl) : std::cout << "ld_impl"; break; default : std::cout << "unknown!"; + /* *NS_CHECK_STYLE_ON* */ } std::cout << std::endl; diff --git a/src/core/test/many-uniform-random-variables-one-get-value-call-test-suite.cc b/src/core/test/many-uniform-random-variables-one-get-value-call-test-suite.cc index ecc2721be..c9becc8e7 100644 --- a/src/core/test/many-uniform-random-variables-one-get-value-call-test-suite.cc +++ b/src/core/test/many-uniform-random-variables-one-get-value-call-test-suite.cc @@ -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 diff --git a/src/core/test/names-test-suite.cc b/src/core/test/names-test-suite.cc index 133299dfb..0cda153f9 100644 --- a/src/core/test/names-test-suite.cc +++ b/src/core/test/names-test-suite.cc @@ -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 () @@ -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 () @@ -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 context, std::string name, Ptr 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); * - * 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); - * + * */ 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); - * + * */ 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); - * + * */ 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 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 foundAlternateTestObject; foundTestObject = Names::Find ("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 ("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 ("Test Object"); - NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0, + NS_TEST_ASSERT_MSG_EQ (foundAlternateTestObject, 0, "Unexpectedly able to GetObject on a TestObject"); foundTestObject = Names::Find ("Alternate Test Object"); - NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0, + NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0, "Unexpectedly able to GetObject 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 diff --git a/src/core/test/object-test-suite.cc b/src/core/test/object-test-suite.cc index 7b1b65d61..0fcff7a45 100644 --- a/src/core/test/object-test-suite.cc +++ b/src/core/test/object-test-suite.cc @@ -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 template function") -{ -} +{} CreateObjectTestCase::~CreateObjectTestCase () -{ -} +{} void CreateObjectTestCase::DoRun (void) @@ -212,13 +218,13 @@ CreateObjectTestCase::DoRun (void) NS_TEST_ASSERT_MSG_EQ (baseA->GetObject (), baseA, "Unable to GetObject 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 (), 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 (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 (), 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 (), 0, "Cannot GetObject (through baseA) for BaseB Object"); @@ -353,7 +357,7 @@ AggregateObjectTestCase::DoRun (void) NS_TEST_ASSERT_MSG_NE (baseB->GetObject (), 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 (), 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 (), 0, "Cannot GetObject (through baseBCopy) for a BaseA Object"); NS_TEST_ASSERT_MSG_NE (baseBCopy->GetObject (), 0, "Cannot GetObject (through baseBCopy) for a BaseA Object"); // - // Since the Ptr is actually a DerivedB, we should be able to ask the + // Since the Ptr 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 (), 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 (), 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 (), 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 (), a, "Unable to use GetObject as dynamic_cast()"); @@ -499,6 +501,6 @@ ObjectTestSuite::ObjectTestSuite () static ObjectTestSuite g_objectTestSuite; - } // namespace tests +} // namespace tests } // namespace ns3 diff --git a/src/core/test/one-uniform-random-variable-many-get-value-calls-test-suite.cc b/src/core/test/one-uniform-random-variable-many-get-value-calls-test-suite.cc index d89b9f019..a5cab8bce 100644 --- a/src/core/test/one-uniform-random-variable-many-get-value-calls-test-suite.cc +++ b/src/core/test/one-uniform-random-variable-many-get-value-calls-test-suite.cc @@ -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 diff --git a/src/core/test/ptr-test-suite.cc b/src/core/test/ptr-test-suite.cc index 9587b6a0e..b3faa946b 100644 --- a/src/core/test/ptr-test-suite.cc +++ b/src/core/test/ptr-test-suite.cc @@ -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 p; p = Create (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 diff --git a/src/core/test/random-variable-stream-test-suite.cc b/src/core/test/random-variable-stream-test-suite.cc index 096735d85..e36916cae 100644 --- a/src/core/test/random-variable-stream-test-suite.cc +++ b/src/core/test/random-variable-stream-test-suite.cc @@ -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 (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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 (alpha - 1)) / + double expectedMean = + gsl_sf_zeta_int (static_cast (alpha - 1)) / gsl_sf_zeta_int (static_cast (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 (alpha) - 1) / + double expectedMean = + gsl_sf_zeta_int (static_cast (alpha) - 1) / gsl_sf_zeta_int (static_cast (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 y = CreateObject (); @@ -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 diff --git a/src/core/test/rng-test-suite.cc b/src/core/test/rng-test-suite.cc index 1ec622d6b..42b65cdb7 100644 --- a/src/core/test/rng-test-suite.cc +++ b/src/core/test/rng-test-suite.cc @@ -62,17 +62,15 @@ private: RngUniformTestCase::RngUniformTestCase () : TestCase ("Uniform Random Number Generator") -{ -} +{} RngUniformTestCase::~RngUniformTestCase () -{ -} +{} double RngUniformTestCase::ChiSquaredTest (Ptr 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 n) @@ -242,12 +238,10 @@ private: RngExponentialTestCase::RngExponentialTestCase () : TestCase ("Exponential Random Number Generator") -{ -} +{} RngExponentialTestCase::~RngExponentialTestCase () -{ -} +{} double RngExponentialTestCase::ChiSquaredTest (Ptr e) @@ -338,12 +332,10 @@ private: RngParetoTestCase::RngParetoTestCase () : TestCase ("Pareto Random Number Generator") -{ -} +{} RngParetoTestCase::~RngParetoTestCase () -{ -} +{} double RngParetoTestCase::ChiSquaredTest (Ptr p) diff --git a/src/core/test/sample-test-suite.cc b/src/core/test/sample-test-suite.cc index 17e7f9465..c0acb292d 100644 --- a/src/core/test/sample-test-suite.cc +++ b/src/core/test/sample-test-suite.cc @@ -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 diff --git a/src/core/test/simulator-test-suite.cc b/src/core/test/simulator-test-suite.cc index ce4cbed4c..79ce7302f 100644 --- a/src/core/test/simulator-test-suite.cc +++ b/src/core/test/simulator-test-suite.cc @@ -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) { diff --git a/src/core/test/threaded-test-suite.cc b/src/core/test/threaded-test-suite.cc index 131b3b94e..fe8657083 100644 --- a/src/core/test/threaded-test-suite.cc +++ b/src/core/test/threaded-test-suite.cc @@ -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 >::iterator it2 = m_threadlist.begin(); it2 != m_threadlist.end(); ++it2) + for (std::list >::iterator it2 = m_threadlist.begin (); it2 != m_threadlist.end (); ++it2) { - (*it2)->Join(); + (*it2)->Join (); } } void @@ -91,7 +90,7 @@ ThreadedSimulatorEventsTestCase::SchedulingThread (std::pairm_stop) { me->m_threadWaiting[threadno] = true; @@ -100,14 +99,14 @@ ThreadedSimulatorEventsTestCase::SchedulingThread (std::pairm_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 (MakeBoundCallback ( - &ThreadedSimulatorEventsTestCase::SchedulingThread, - std::pair(this,i) )) ); + &ThreadedSimulatorEventsTestCase::SchedulingThread, + std::pair (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 >::iterator it = m_threadlist.begin(); it != m_threadlist.end(); ++it) + + for (std::list >::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); } } diff --git a/src/core/test/time-test-suite.cc b/src/core/test/time-test-suite.cc index 026392e04..cb6bdedea 100644 --- a/src/core/test/time-test-suite.cc +++ b/src/core/test/time-test-suite.cc @@ -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: diff --git a/src/core/test/timer-test-suite.cc b/src/core/test/timer-test-suite.cc index 0a2f6f7f2..adc95274e 100644 --- a/src/core/test/timer-test-suite.cc +++ b/src/core/test/timer-test-suite.cc @@ -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) diff --git a/src/core/test/traced-callback-test-suite.cc b/src/core/test/traced-callback-test-suite.cc index b8b90905b..506669811 100644 --- a/src/core/test/traced-callback-test-suite.cc +++ b/src/core/test/traced-callback-test-suite.cc @@ -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 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. // diff --git a/src/core/test/type-id-test-suite.cc b/src/core/test/type-id-test-suite.cc index 17f0991b8..4ef654888 100644 --- a/src/core/test/type-id-test-suite.cc +++ b/src/core/test/type-id-test-suite.cc @@ -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 () ); - + 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 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 () - + // 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) { diff --git a/src/core/test/type-traits-test-suite.cc b/src/core/test/type-traits-test-suite.cc index 27c41cfdd..e6f36ec2a 100644 --- a/src/core/test/type-traits-test-suite.cc +++ b/src/core/test/type-traits-test-suite.cc @@ -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::IsPointerToMember, 1, - "Check pointer to member function (void)"); + (TypeTraits::IsPointerToMember, 1, + "Check pointer to member function (void)"); NS_TEST_ASSERT_MSG_EQ - (TypeTraits::IsPointerToMember, 1, - "Check pointer to member function (void) const"); + (TypeTraits::IsPointerToMember, 1, + "Check pointer to member function (void) const"); NS_TEST_ASSERT_MSG_EQ - (TypeTraits::IsPointerToMember, 1, - "Check pointer to member function (int)"); + (TypeTraits::IsPointerToMember, 1, + "Check pointer to member function (int)"); NS_TEST_ASSERT_MSG_EQ - (TypeTraits::IsPointerToMember, 1, - "Check pointer to member function (int) const"); + (TypeTraits::IsPointerToMember, 1, + "Check pointer to member function (int) const"); NS_TEST_ASSERT_MSG_EQ - (TypeTraits::PointerToMemberTraits::nArgs, 0, - "Check number of arguments for pointer to member function (void) const"); + (TypeTraits::PointerToMemberTraits::nArgs, 0, + "Check number of arguments for pointer to member function (void) const"); NS_TEST_ASSERT_MSG_EQ - (TypeTraits::PointerToMemberTraits::nArgs, 1, - "Check number of arguments for pointer to member function (int) const"); + (TypeTraits::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 diff --git a/src/core/test/watchdog-test-suite.cc b/src/core/test/watchdog-test-suite.cc index 8c638bc01..8afb6e3a3 100644 --- a/src/core/test/watchdog-test-suite.cc +++ b/src/core/test/watchdog-test-suite.cc @@ -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