Move tests from some modules to their test libraries
authorMitch Watrous <watrous@u.washington.edu>
Fri, 25 Mar 2011 12:55:27 -0700
changeset 6952 91a77c7f3bb2
parent 6951 ba9081dbe0ee
child 6953 aa8081396a16
Move tests from some modules to their test libraries
src/aodv/model/aodv-id-cache.cc
src/aodv/test/aodv-id-cache-test-suite.cc
src/aodv/wscript
src/core/model/high-precision-128.cc
src/core/model/high-precision.cc
src/core/model/time.cc
src/core/model/timer.cc
src/core/model/watchdog.cc
src/core/test/high-precision-128-test-suite.cc
src/core/test/high-precision-test-suite.cc
src/core/test/time-test-suite.cc
src/core/test/timer-test-suite.cc
src/core/test/watchdog-test-suite.cc
src/core/wscript
src/flow-monitor/model/histogram.cc
src/flow-monitor/test/histogram-test-suite.cc
src/flow-monitor/wscript
--- a/src/aodv/model/aodv-id-cache.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/aodv/model/aodv-id-cache.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -26,7 +26,6 @@
  *          Pavel Boyko <[email protected]>
  */
 #include "aodv-id-cache.h"
-#include "ns3/test.h"
 #include <algorithm>
 
 namespace ns3
@@ -60,70 +59,4 @@
   return m_idCache.size ();
 }
 
-//-----------------------------------------------------------------------------
-// Tests
-//-----------------------------------------------------------------------------
-/// Unit test for id cache
-struct IdCacheTest : public TestCase
-{
-  IdCacheTest () : TestCase ("Id Cache"), cache (Seconds(10))
-  {}
-  virtual void DoRun();
-  void CheckTimeout1 ();
-  void CheckTimeout2 ();
-  void CheckTimeout3 ();
-
-  IdCache cache;
-};
-
-void
-IdCacheTest::DoRun ()
-{
-  NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(10), "Lifetime");
-  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), false, "Unknown ID & address");
-  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 4), false, "Unknown ID");
-  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("4.3.2.1"), 3), false, "Unknown address");
-  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), true, "Known address & ID");
-  cache.SetLifetime(Seconds(15));
-  NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(15), "New lifetime");
-  cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4);
-  cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4);
-  cache.IsDuplicate (Ipv4Address ("2.2.2.2"), 5);
-  cache.IsDuplicate (Ipv4Address ("3.3.3.3"), 6);
-  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 6, "trivial");
-
-  Simulator::Schedule (Seconds(5), &IdCacheTest::CheckTimeout1, this);
-  Simulator::Schedule (Seconds(11), &IdCacheTest::CheckTimeout2, this);
-  Simulator::Schedule (Seconds(30), &IdCacheTest::CheckTimeout3, this);
-  Simulator::Run ();
-  Simulator::Destroy ();
-}
-
-void
-IdCacheTest::CheckTimeout1 ()
-{
-  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 6, "Nothing expire");
-}
-
-void
-IdCacheTest::CheckTimeout2 ()
-{
-  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 3, "3 records left");
-}
-
-void
-IdCacheTest::CheckTimeout3 ()
-{
-  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 0, "All records expire");
-}
-//-----------------------------------------------------------------------------
-class IdCacheTestSuite : public TestSuite
-{
-public:
-  IdCacheTestSuite () : TestSuite ("routing-id-cache", UNIT)
-  {
-    AddTestCase (new IdCacheTest);
-  }
-} g_idCacheTestSuite;
-
 }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/aodv/test/aodv-id-cache-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,102 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 IITP RAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Based on
+ *      NS-2 AODV model developed by the CMU/MONARCH group and optimized and
+ *      tuned by Samir Das and Mahesh Marina, University of Cincinnati;
+ *
+ *      AODV-UU implementation by Erik Nordström of Uppsala University
+ *      http://core.it.uu.se/core/index.php/AODV-UU
+ *
+ * Authors: Elena Buchatskaia <[email protected]>
+ *          Pavel Boyko <[email protected]>
+ */
+#include "ns3/aodv-id-cache.h"
+#include "ns3/test.h"
+
+namespace ns3
+{
+namespace aodv
+{
+
+//-----------------------------------------------------------------------------
+// Tests
+//-----------------------------------------------------------------------------
+/// Unit test for id cache
+struct IdCacheTest : public TestCase
+{
+  IdCacheTest () : TestCase ("Id Cache"), cache (Seconds(10))
+  {}
+  virtual void DoRun();
+  void CheckTimeout1 ();
+  void CheckTimeout2 ();
+  void CheckTimeout3 ();
+
+  IdCache cache;
+};
+
+void
+IdCacheTest::DoRun ()
+{
+  NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(10), "Lifetime");
+  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), false, "Unknown ID & address");
+  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 4), false, "Unknown ID");
+  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("4.3.2.1"), 3), false, "Unknown address");
+  NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), true, "Known address & ID");
+  cache.SetLifetime(Seconds(15));
+  NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(15), "New lifetime");
+  cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4);
+  cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4);
+  cache.IsDuplicate (Ipv4Address ("2.2.2.2"), 5);
+  cache.IsDuplicate (Ipv4Address ("3.3.3.3"), 6);
+  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 6, "trivial");
+
+  Simulator::Schedule (Seconds(5), &IdCacheTest::CheckTimeout1, this);
+  Simulator::Schedule (Seconds(11), &IdCacheTest::CheckTimeout2, this);
+  Simulator::Schedule (Seconds(30), &IdCacheTest::CheckTimeout3, this);
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+
+void
+IdCacheTest::CheckTimeout1 ()
+{
+  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 6, "Nothing expire");
+}
+
+void
+IdCacheTest::CheckTimeout2 ()
+{
+  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 3, "3 records left");
+}
+
+void
+IdCacheTest::CheckTimeout3 ()
+{
+  NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 0, "All records expire");
+}
+//-----------------------------------------------------------------------------
+class IdCacheTestSuite : public TestSuite
+{
+public:
+  IdCacheTestSuite () : TestSuite ("routing-id-cache", UNIT)
+  {
+    AddTestCase (new IdCacheTest);
+  }
+} g_idCacheTestSuite;
+
+}}
--- a/src/aodv/wscript	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/aodv/wscript	Fri Mar 25 12:55:27 2011 -0700
@@ -16,6 +16,7 @@
 
     aodv_test = bld.create_ns3_module_test_library('aodv')
     aodv_test.source = [
+        'test/aodv-id-cache-test-suite.cc',
         'test/aodv-test-suite.cc',
         'test/aodv-regression.cc',
         'test/bug-772.cc',
--- a/src/core/model/high-precision-128.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/model/high-precision-128.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -281,129 +281,3 @@
 
 } // namespace ns3
 
-#include "ns3/test.h"
-
-namespace ns3
-{
-
-class HpFracTestCase : public TestCase
-{
-public:
-  HpFracTestCase ();
-  virtual void DoRun (void);
-  void CheckFrac (int64_t hi, uint64_t lo);
-};
-
-void 
-HpFracTestCase::CheckFrac (int64_t hi, uint64_t lo)
-{
-  HighPrecision tmp = HighPrecision (hi,lo);
-  NS_TEST_EXPECT_MSG_EQ (tmp.GetHigh (), hi,
-			 "High part does not match");
-  NS_TEST_EXPECT_MSG_EQ (tmp.GetLow (), lo,
-			 "Low part does not match");
-}
-
-HpFracTestCase::HpFracTestCase ()
-  : TestCase ("Check that we can manipulate the high and low part of every number")
-{
-}
-void
-HpFracTestCase::DoRun (void)
-{
-  CheckFrac (1, 0);
-  CheckFrac (1, 1);
-  CheckFrac (-1, 0);
-  CheckFrac (-1, 1);
-}
-
-
-class HpInputTestCase : public TestCase
-{
-public:
-  HpInputTestCase ();
-  virtual void DoRun (void);
-  void CheckString (std::string str, int64_t hi, uint64_t lo);
-};
-HpInputTestCase::HpInputTestCase ()
-  : TestCase ("Check that we parse HighPrecision numbers as strings")
-{
-}
-void 
-HpInputTestCase::CheckString (std::string str, int64_t hi, uint64_t lo)
-{
-  std::istringstream iss;
-  iss.str (str);
-  HighPrecision hp;
-  iss >> hp;
-  NS_TEST_EXPECT_MSG_EQ (hp.GetHigh (), hi, "High parts do not match for input string " << str);
-  NS_TEST_EXPECT_MSG_EQ (hp.GetLow (), lo, "Low parts do not match for input string " << str);
-}
-void
-HpInputTestCase::DoRun (void)
-{
-  CheckString ("1", 1, 0);
-  CheckString ("+1", 1, 0);
-  CheckString ("-1", -1, 0);
-  CheckString ("1.0", 1, 0);
-  CheckString ("+1.0", 1, 0);
-  CheckString ("001.0", 1, 0);
-  CheckString ("+001.0", 1, 0);
-  CheckString ("020.0", 20, 0);
-  CheckString ("+020.0", 20, 0);
-  CheckString ("-1.0", -1, 0);
-  CheckString ("-1.0000", -1, 0);
-  CheckString ("1.0000000", 1, 0);
-  CheckString ("1.08446744073709551615", 1, 8446744073709551615LL);
-  CheckString ("-1.08446744073709551615", -1, 8446744073709551615LL);
-}
-
-class HpInputOutputTestCase : public TestCase
-{
-public:
-  HpInputOutputTestCase ();
-  virtual void DoRun (void);
-  void CheckString (std::string str);
-};
-HpInputOutputTestCase::HpInputOutputTestCase ()
-  : TestCase ("Check that we can roundtrip HighPrecision numbers as strings")
-{
-}
-void 
-HpInputOutputTestCase::CheckString (std::string str)
-{
-  std::istringstream iss;
-  iss.str (str);
-  HighPrecision hp;
-  iss >> hp;
-  std::ostringstream oss;
-  oss << hp;
-  NS_TEST_EXPECT_MSG_EQ (oss.str (), str, "Converted string does not match expected string");
-}
-void
-HpInputOutputTestCase::DoRun (void)
-{
-  CheckString ("+1.0");
-  CheckString ("-1.0");
-  CheckString ("+20.0");
-  CheckString ("+1.08446744073709551615");
-  CheckString ("-1.08446744073709551615");
-  CheckString ("+1.18446744073709551615");
-  CheckString ("-1.18446744073709551615");
-}
-
-
-static class HighPrecision128TestSuite : public TestSuite
-{
-public:
-  HighPrecision128TestSuite ()
-    : TestSuite ("high-precision-128", UNIT)
-  {
-    AddTestCase (new HpFracTestCase ());
-    AddTestCase (new HpInputTestCase ());
-    //AddTestCase (new HpOutputTestCase ());
-    AddTestCase (new HpInputOutputTestCase ());
-  }
-} g_highPrecision128TestSuite;
-
-} // namespace ns3
--- a/src/core/model/high-precision.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/model/high-precision.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -41,314 +41,3 @@
 
 } /* namespace ns3 */
 
-#include "ns3/test.h"
-
-#define CHECK_EXPECTED(a,b) \
-  NS_TEST_ASSERT_MSG_EQ (a.GetInteger (),b,"Arithmetic failure: " << (a.GetInteger ()) << "!=" << (b))
-
-#define V(v) \
-  HighPrecision (v, false)
-
-namespace ns3 {
-
-class HpArithmeticTestCase : public TestCase
-{
-public:
-  HpArithmeticTestCase ();
-  virtual void DoRun (void);
-};
-
-HpArithmeticTestCase::HpArithmeticTestCase ()
-  : TestCase ("Check basic arithmetic operations")
-{
-}
-void
-HpArithmeticTestCase::DoRun (void)
-{
-  HighPrecision a, b;
-  a = HighPrecision (1, false);
-  b = HighPrecision (1, false);
-
-  a.Sub (b);
-  CHECK_EXPECTED (a, 0);
-
-  a = V (1);
-  a.Sub (V (2));
-  CHECK_EXPECTED (a, -1);
-
-  a = V (1);
-  a.Sub (V (3));
-  CHECK_EXPECTED (a, -2);
-
-  a = V (1);
-  a.Sub (V (-1));
-  CHECK_EXPECTED (a, 2);
-
-  a = V (1);
-  a.Sub (V (-2));
-  CHECK_EXPECTED (a, 3);
-
-  a = V (-3);
-  a.Sub (V (-4));
-  CHECK_EXPECTED (a, 1);
-
-  a = V (-2);
-  a.Sub (V (3));
-  CHECK_EXPECTED (a, -5);
-
-  a = V (1);
-  a.Add (V (2));
-  CHECK_EXPECTED (a, 3);
-
-  a = V (1);
-  a.Add (V (-3));
-  CHECK_EXPECTED (a, -2);
-
-  a = V (0);
-  a.Add (V (0));
-  CHECK_EXPECTED (a, 0);
-
-  a = V (0);
-  a.Mul (V (0));
-  CHECK_EXPECTED (a, 0);
-  a = V (0);
-  a.Mul (V (1));
-  CHECK_EXPECTED (a, 0);
-  a = V (0);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, 0);
-  a = V (1);
-  a.Mul (V (0));
-  CHECK_EXPECTED (a, 0);
-  a = V (1);
-  a.Mul (V (1));
-  CHECK_EXPECTED (a, 1);
-  a = V (1);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, -1);
-  a = V (-1);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, 1);
-
-  a = V (0);
-  a.Mul (V (1));
-  CHECK_EXPECTED (a, 0);
-  a = V (0);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, 0);
-  a = V (1);
-  a.Mul (V (1));
-  CHECK_EXPECTED (a, 1);
-  a = V (1);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, -1);
-  a = V (-1);
-  a.Mul (V (1));
-  CHECK_EXPECTED (a, -1);
-  a = V (-1);
-  a.Mul (V (-1));
-  CHECK_EXPECTED (a, 1);
-
-
-
-  a = V (2);
-  a.Mul (V (3));
-  a.Div (V (3));
-  CHECK_EXPECTED (a, 2);
-
-  // Below, the division loses precision because 2/3 is not
-  // representable exactly in 64.64 integers. So, we got
-  // something super close but the final rounding kills us.
-  a = V (2);
-  a.Div (V (3));
-  a.Mul (V (3));
-  CHECK_EXPECTED (a, 1);
-
-  // The example below shows that we really do not lose
-  // much precision internally: it is almost always the
-  // final conversion which loses precision.
-  a = V (2000000000);
-  a.Div (V (3));
-  a.Mul (V (3));
-  CHECK_EXPECTED (a, 1999999999);
-}
-
-class HpBug455TestCase : public TestCase
-{
-public:
-  HpBug455TestCase ();
-  virtual void DoRun (void);
-};
-
-HpBug455TestCase::HpBug455TestCase ()
-  : TestCase ("Test case for bug 455")
-{
-}
-void
-HpBug455TestCase::DoRun (void)
-{
-  HighPrecision a = HighPrecision (0.1);
-  a.Div (HighPrecision (1.25));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 0.08, "The original testcase");
-  a = HighPrecision (0.5);
-  a.Mul (HighPrecision (5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 2.5, "Simple test for multiplication");
-  a = HighPrecision (-0.5);
-  a.Mul (HighPrecision (5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -2.5, "Test sign, first operation negative");
-  a = HighPrecision (-0.5);
-  a.Mul (HighPrecision (-5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 2.5, "both operands negative");
-  a = HighPrecision (0.5);
-  a.Mul (HighPrecision (-5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -2.5, "only second operand negative");
-}
-
-
-class HpBug863TestCase : public TestCase
-{
-public:
-  HpBug863TestCase ();
-  virtual void DoRun (void);
-};
-
-HpBug863TestCase::HpBug863TestCase ()
-  : TestCase ("Test case for bug 863")
-{
-}
-void
-HpBug863TestCase::DoRun (void)
-{
-  HighPrecision a = HighPrecision (0.9);
-  a.Div (HighPrecision (1));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 0.9, "The original testcase");
-  a = HighPrecision (0.5);
-  a.Div (HighPrecision (0.5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 1.0, "Simple test for division");
-  a = HighPrecision (-0.5);
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -0.5, "Check that we actually convert doubles correctly");
-  a.Div (HighPrecision (0.5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -1.0, "first argument negative");
-  a = HighPrecision (0.5);
-  a.Div (HighPrecision (-0.5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -1.0, "second argument negative");
-  a = HighPrecision (-0.5);
-  a.Div (HighPrecision (-0.5));
-  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 1.0, "both arguments negative");
-}
-
-class HpCompareTestCase : public TestCase
-{
-public:
-  HpCompareTestCase ();
-  virtual void DoRun (void);
-};
-
-HpCompareTestCase::HpCompareTestCase ()
-  : TestCase ("Check basic compare operations")
-{
-}
-void
-HpCompareTestCase::DoRun (void)
-{
-  HighPrecision a, b;
-
-  a = V (-1);
-  b = V (1);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), -1, "a is smaller than b");
-  a = V (-1);
-  b = V (-2);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 1, "a is bigger than b");
-  a = V (-1);
-  b = V (-1);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 0, "a is equal to b");
-
-  a = V (1);
-  b = V (-1);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 1, "a is bigger than b");
-  a = V (1);
-  b = V (2);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), -1, "a is smaller than b");
-  a = V (1);
-  b = V (1);
-  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 0, "a is equal to b");
-}
-
-class HpInvertTestCase : public TestCase
-{
-public:
-  HpInvertTestCase ();
-  virtual void DoRun (void);
-};
-
-HpInvertTestCase::HpInvertTestCase ()
-  : TestCase ("Test case for invertion")
-{
-}
-
-void
-HpInvertTestCase::DoRun (void)
-{
-#define TEST(factor)                                                    \
-  do {                                                                  \
-    HighPrecision a;                                                    \
-    a = HighPrecision::Invert (factor);                                 \
-    HighPrecision b = V (factor);                                       \
-    b.MulByInvert (a);                                                  \
-    NS_TEST_ASSERT_MSG_EQ (b.GetInteger (), 1,                          \
-                           "x * 1/x should be 1 for x=" << factor);     \
-    HighPrecision c = V (1);                                            \
-    c.MulByInvert (a);                                                  \
-    NS_TEST_ASSERT_MSG_EQ (c.GetInteger (), 0,                          \
-                           "1 * 1/x should be 0 for x=" << factor);     \
-    HighPrecision d = V (1);                                            \
-    d.Div (V(factor));                                                  \
-    NS_TEST_ASSERT_MSG_EQ (d.GetDouble (), c.GetDouble (),              \
-                           "1 * 1/x should be equal to 1/x for x=" << factor); \
-    HighPrecision e = V (-factor);                                      \
-    e.MulByInvert (a);                                                  \
-    NS_TEST_ASSERT_MSG_EQ (e.GetInteger (), -1,                         \
-                           "-x * 1/x should be -1 for x=" << factor);   \
-  } while(false)
-
-  TEST(2);
-  TEST(3);
-  TEST(4);
-  TEST(5);
-  TEST(6);
-  TEST(10);
-  TEST(99);
-  TEST(100);
-  TEST(1000);
-  TEST(10000);
-  TEST(100000);
-  TEST(100000);
-  TEST(1000000);
-  TEST(10000000);
-  TEST(100000000);
-  TEST(1000000000);
-  TEST(10000000000LL);
-  TEST(100000000000LL);
-  TEST(1000000000000LL);
-  TEST(10000000000000LL);
-  TEST(100000000000000LL);
-  TEST(1000000000000000LL);
-#undef TEST
-}
-
-
-static class HighPrecisionTestSuite : public TestSuite
-{
-public:
-  HighPrecisionTestSuite ()
-    : TestSuite ("high-precision", UNIT)
-  {
-    AddTestCase (new HpArithmeticTestCase ());
-    AddTestCase (new HpBug455TestCase ());
-    AddTestCase (new HpBug863TestCase ());
-    AddTestCase (new HpCompareTestCase ());
-    AddTestCase (new HpInvertTestCase ());
-  }
-} g_highPrecisionTestSuite;
-
-} // namespace ns3
--- a/src/core/model/time.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/model/time.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -190,121 +190,3 @@
 
 } // namespace ns3
 
-#include "ns3/test.h"
-
-namespace ns3 {
-
-class Bug863TestCase : public TestCase
-{
-public:
-  Bug863TestCase ();
-  virtual void DoRun (void);
-};
-
-Bug863TestCase::Bug863TestCase ()
-  : TestCase ("Bug 863")
-{
-}
-
-void Bug863TestCase::DoRun (void)
-{
-  Scalar result = Scalar (0.9) / Scalar (1.0);
-  NS_TEST_ASSERT_MSG_EQ ((result == Scalar (0.9)), true, "Invalid arithmetic result");
-}
-
-class TimeSimpleTestCase : public TestCase
-{
-public:
-  TimeSimpleTestCase (enum Time::Unit resolution);
-private:
-  virtual void DoRun (void);
-  virtual void DoTearDown (void);
-  enum Time::Unit m_originalResolution;
-  enum Time::Unit m_resolution;
-};
-
-TimeSimpleTestCase::TimeSimpleTestCase (enum Time::Unit resolution)
-  : TestCase ("Sanity check of common time operations"),
-    m_resolution (resolution)
-{}
-void
-TimeSimpleTestCase::DoRun (void)
-{
-  m_originalResolution = Time::GetResolution ();
-  Time::SetResolution (m_resolution);
-  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 (), 
-                             "is 10 really 10 ?");
-  NS_TEST_ASSERT_MSG_EQ (MilliSeconds (1).GetMilliSeconds (), 1, 
-                         "is 1ms really 1ms ?");
-  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, 
-                         "is 1ns really 1ns ?");
-  NS_TEST_ASSERT_MSG_EQ (PicoSeconds (1).GetPicoSeconds (), 1, 
-                         "is 1ps really 1ps ?");
-  NS_TEST_ASSERT_MSG_EQ (FemtoSeconds (1).GetFemtoSeconds (), 1, 
-                         "is 1fs really 1fs ?");
-#endif
-}
-
-void 
-TimeSimpleTestCase::DoTearDown (void)
-{
-  Time::SetResolution (m_originalResolution);
-}
-
-class ArithTestCase : public TestCase
-{
-public:
-  ArithTestCase ();
-private:
-  virtual void DoRun (void);
-};
-
-ArithTestCase::ArithTestCase ()
-  : TestCase ("check arithmetic operators")
-{
-}
-void
-ArithTestCase::DoRun (void)
-{
-  Time a, b, c;
-  c = a + b;
-  c = a * b;
-  c = a / Seconds (1.0);
-  c = a - b;
-  c += a;
-  c -= a;
-  c /= Seconds (1.0);
-  c *= a;
-  bool x;
-  x = a < b;
-  x = a > b;
-  x = a <= b;
-  x = a >= b;
-  x = a == b;
-  x = a != b;
-  //a = 1.0;
-  //a = 1;
-}
-
-
-
-static class TimeTestSuite : public TestSuite
-{
-public:
-  TimeTestSuite ()
-    : TestSuite ("time", UNIT)
-  {
-    AddTestCase (new Bug863TestCase ());
-    AddTestCase (new TimeSimpleTestCase (Time::US));
-    AddTestCase (new ArithTestCase ());
-  }
-} g_timeTestSuite;
-
-} // namespace ns3
--- a/src/core/model/timer.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/model/timer.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -170,216 +170,3 @@
 
 } // namespace ns3
 
-#include "ns3/test.h"
-#include "ns3/simulator.h"
-#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 bar6i (int, int, int, int, int, int)
-{
-}
-void barcir (const int &)
-{
-}
-void barir (int &)
-{
-}
-void barip (int *)
-{
-}
-void barcip (const int *)
-{
-}
-} // anonymous namespace
-
-namespace ns3 {
-
-class TimerStateTestCase : public TestCase
-{
-public:
-  TimerStateTestCase ();
-  virtual void DoRun (void);
-};
-
-TimerStateTestCase::TimerStateTestCase ()
-  : TestCase ("Check correct state transitions")
-{
-}
-void
-TimerStateTestCase::DoRun (void)
-{
-  Timer timer = Timer (Timer::CANCEL_ON_DESTROY);
-
-  timer.SetFunction (&bari);
-  timer.SetArguments (1);
-  timer.SetDelay (Seconds (10.0));
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.IsExpired (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::EXPIRED, "");
-  timer.Schedule ();
-  NS_TEST_ASSERT_MSG_EQ (timer.IsRunning (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::RUNNING, "");
-  timer.Suspend ();
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.IsSuspended (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::SUSPENDED, "");
-  timer.Resume ();
-  NS_TEST_ASSERT_MSG_EQ (timer.IsRunning (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::RUNNING, "");
-  timer.Cancel ();
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.IsExpired (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
-  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::EXPIRED, "");
-}
-
-class TimerTemplateTestCase : public TestCase
-{
-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 *)
-  {
-  }
-};
-
-TimerTemplateTestCase::TimerTemplateTestCase ()
-  : TestCase ("Check that template magic is working")
-{
-}
-
-void
-TimerTemplateTestCase::DoRun (void)
-{
-  Timer timer = Timer (Timer::CANCEL_ON_DESTROY);
-
-  int a = 0;
-  int &b = a;
-  const int &c = a;
-
-  timer.SetFunction (&bari);
-  timer.SetArguments (2);
-  timer.SetArguments (a);
-  timer.SetArguments (b);
-  timer.SetArguments (c);
-  timer.SetFunction (&barir);
-  timer.SetArguments (2);
-  timer.SetArguments (a);
-  timer.SetArguments (b);
-  timer.SetArguments (c);
-  timer.SetFunction (&barcir);
-  timer.SetArguments (2);
-  timer.SetArguments (a);
-  timer.SetArguments (b);
-  timer.SetArguments (c);
-  // the following call cannot possibly work and is flagged by
-  // a runtime error.
-  // timer.SetArguments (0.0);
-  timer.SetDelay (Seconds (1.0));
-  timer.Schedule ();
-
-  timer.SetFunction (&TimerTemplateTestCase::bazi, this);
-  timer.SetArguments (3);
-  timer.SetFunction (&TimerTemplateTestCase::bazir, this);
-  timer.SetArguments (3);
-  timer.SetFunction (&TimerTemplateTestCase::bazcir, this);
-  timer.SetArguments (3);
-
-  timer.SetFunction (&bar2i);
-  timer.SetArguments (1, 1);
-  timer.SetFunction (&bar3i);
-  timer.SetArguments (1, 1, 1);
-  timer.SetFunction (&bar4i);
-  timer.SetArguments (1, 1, 1, 1);
-  timer.SetFunction (&bar5i);
-  timer.SetArguments (1, 1, 1, 1, 1);
-  // unsupported in simulator class
-  // timer.SetFunction (&bar6i);
-  // timer.SetArguments (1, 1, 1, 1, 1, 1);
-
-  timer.SetFunction (&TimerTemplateTestCase::baz2i, this);
-  timer.SetArguments (1, 1);
-  timer.SetFunction (&TimerTemplateTestCase::baz3i, this);
-  timer.SetArguments (1, 1, 1);
-  timer.SetFunction (&TimerTemplateTestCase::baz4i, this);
-  timer.SetArguments (1, 1, 1, 1);
-  timer.SetFunction (&TimerTemplateTestCase::baz5i, this);
-  timer.SetArguments (1, 1, 1, 1, 1);
-  // unsupported in simulator class
-  // timer.SetFunction (&TimerTemplateTestCase::baz6i, this);
-  // timer.SetArguments (1, 1, 1, 1, 1, 1);
-
-  Simulator::Run ();
-  Simulator::Destroy ();
-}
-
-void
-TimerTemplateTestCase::DoTeardown (void)
-{
-  Simulator::Run ();
-  Simulator::Destroy ();
-}
-
-static class TimerTestSuite : public TestSuite
-{
-public:
-  TimerTestSuite ()
-    : TestSuite ("timer", UNIT)
-  {
-    AddTestCase (new TimerStateTestCase ());
-    AddTestCase (new TimerTemplateTestCase ());
-  }
-} g_timerTestSuite;
-
-} // namespace ns3
-
-
--- a/src/core/model/watchdog.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/model/watchdog.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -59,64 +59,3 @@
 
 } // namespace ns3
 
-#include "ns3/test.h"
-
-namespace ns3 {
-
-class WatchdogTestCase : public TestCase
-{
-public:
-  WatchdogTestCase ();
-  virtual void DoRun (void);
-  void Expire (Time expected);
-  bool m_expired;
-  Time m_expiredTime;
-  Time m_expiredArgument;
-};
-
-WatchdogTestCase::WatchdogTestCase()
-  : TestCase ("Check that we can keepalive a watchdog")
-{}
-
-void
-WatchdogTestCase::Expire (Time expected)
-{
-  m_expired = true;
-  m_expiredTime = Simulator::Now ();
-  m_expiredArgument = expected;
-}
-
-void
-WatchdogTestCase::DoRun (void)
-{
-  m_expired = false;
-  m_expiredArgument = Seconds (0);
-  m_expiredTime = Seconds (0);
-  Watchdog watchdog;
-  watchdog.SetFunction (&WatchdogTestCase::Expire, this);
-  watchdog.SetArguments (MicroSeconds (40));
-  watchdog.Ping (MicroSeconds (10));
-  Simulator::Schedule (MicroSeconds (5), &Watchdog::Ping, &watchdog, MicroSeconds (20));
-  Simulator::Schedule (MicroSeconds (20), &Watchdog::Ping, &watchdog, MicroSeconds (2));
-  Simulator::Schedule (MicroSeconds (23), &Watchdog::Ping, &watchdog, MicroSeconds (17));
-  Simulator::Run ();
-  Simulator::Destroy ();
-  NS_TEST_ASSERT_MSG_EQ (m_expired, true, "The timer did not expire ??");
-  NS_TEST_ASSERT_MSG_EQ (m_expiredTime, MicroSeconds (40), "The timer did not expire at the expected time ?");
-  NS_TEST_ASSERT_MSG_EQ (m_expiredArgument, MicroSeconds (40), "We did not get the right argument");
-}
-
-
-
-static class WatchdogTestSuite : public TestSuite
-{
-public:
-  WatchdogTestSuite()
-    : TestSuite ("watchdog", UNIT)
-  {
-    AddTestCase (new WatchdogTestCase ());
-  }
-} g_watchdogTestSuite;
-
-} // namespace ns3
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/high-precision-128-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,127 @@
+#include "ns3/high-precision-128.h"
+#include "ns3/test.h"
+
+namespace ns3
+{
+
+class HpFracTestCase : public TestCase
+{
+public:
+  HpFracTestCase ();
+  virtual void DoRun (void);
+  void CheckFrac (int64_t hi, uint64_t lo);
+};
+
+void 
+HpFracTestCase::CheckFrac (int64_t hi, uint64_t lo)
+{
+  HighPrecision tmp = HighPrecision (hi,lo);
+  NS_TEST_EXPECT_MSG_EQ (tmp.GetHigh (), hi,
+			 "High part does not match");
+  NS_TEST_EXPECT_MSG_EQ (tmp.GetLow (), lo,
+			 "Low part does not match");
+}
+
+HpFracTestCase::HpFracTestCase ()
+  : TestCase ("Check that we can manipulate the high and low part of every number")
+{
+}
+void
+HpFracTestCase::DoRun (void)
+{
+  CheckFrac (1, 0);
+  CheckFrac (1, 1);
+  CheckFrac (-1, 0);
+  CheckFrac (-1, 1);
+}
+
+
+class HpInputTestCase : public TestCase
+{
+public:
+  HpInputTestCase ();
+  virtual void DoRun (void);
+  void CheckString (std::string str, int64_t hi, uint64_t lo);
+};
+HpInputTestCase::HpInputTestCase ()
+  : TestCase ("Check that we parse HighPrecision numbers as strings")
+{
+}
+void 
+HpInputTestCase::CheckString (std::string str, int64_t hi, uint64_t lo)
+{
+  std::istringstream iss;
+  iss.str (str);
+  HighPrecision hp;
+  iss >> hp;
+  NS_TEST_EXPECT_MSG_EQ (hp.GetHigh (), hi, "High parts do not match for input string " << str);
+  NS_TEST_EXPECT_MSG_EQ (hp.GetLow (), lo, "Low parts do not match for input string " << str);
+}
+void
+HpInputTestCase::DoRun (void)
+{
+  CheckString ("1", 1, 0);
+  CheckString ("+1", 1, 0);
+  CheckString ("-1", -1, 0);
+  CheckString ("1.0", 1, 0);
+  CheckString ("+1.0", 1, 0);
+  CheckString ("001.0", 1, 0);
+  CheckString ("+001.0", 1, 0);
+  CheckString ("020.0", 20, 0);
+  CheckString ("+020.0", 20, 0);
+  CheckString ("-1.0", -1, 0);
+  CheckString ("-1.0000", -1, 0);
+  CheckString ("1.0000000", 1, 0);
+  CheckString ("1.08446744073709551615", 1, 8446744073709551615LL);
+  CheckString ("-1.08446744073709551615", -1, 8446744073709551615LL);
+}
+
+class HpInputOutputTestCase : public TestCase
+{
+public:
+  HpInputOutputTestCase ();
+  virtual void DoRun (void);
+  void CheckString (std::string str);
+};
+HpInputOutputTestCase::HpInputOutputTestCase ()
+  : TestCase ("Check that we can roundtrip HighPrecision numbers as strings")
+{
+}
+void 
+HpInputOutputTestCase::CheckString (std::string str)
+{
+  std::istringstream iss;
+  iss.str (str);
+  HighPrecision hp;
+  iss >> hp;
+  std::ostringstream oss;
+  oss << hp;
+  NS_TEST_EXPECT_MSG_EQ (oss.str (), str, "Converted string does not match expected string");
+}
+void
+HpInputOutputTestCase::DoRun (void)
+{
+  CheckString ("+1.0");
+  CheckString ("-1.0");
+  CheckString ("+20.0");
+  CheckString ("+1.08446744073709551615");
+  CheckString ("-1.08446744073709551615");
+  CheckString ("+1.18446744073709551615");
+  CheckString ("-1.18446744073709551615");
+}
+
+
+static class HighPrecision128TestSuite : public TestSuite
+{
+public:
+  HighPrecision128TestSuite ()
+    : TestSuite ("high-precision-128", UNIT)
+  {
+    AddTestCase (new HpFracTestCase ());
+    AddTestCase (new HpInputTestCase ());
+    //AddTestCase (new HpOutputTestCase ());
+    AddTestCase (new HpInputOutputTestCase ());
+  }
+} g_highPrecision128TestSuite;
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/high-precision-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,332 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <[email protected]>
+ */
+#include "ns3/high-precision.h"
+#include "ns3/assert.h"
+#include "ns3/test.h"
+
+#define CHECK_EXPECTED(a,b) \
+  NS_TEST_ASSERT_MSG_EQ (a.GetInteger (),b,"Arithmetic failure: " << (a.GetInteger ()) << "!=" << (b))
+
+#define V(v) \
+  HighPrecision (v, false)
+
+namespace ns3 {
+
+class HpArithmeticTestCase : public TestCase
+{
+public:
+  HpArithmeticTestCase ();
+  virtual void DoRun (void);
+};
+
+HpArithmeticTestCase::HpArithmeticTestCase ()
+  : TestCase ("Check basic arithmetic operations")
+{
+}
+void
+HpArithmeticTestCase::DoRun (void)
+{
+  HighPrecision a, b;
+  a = HighPrecision (1, false);
+  b = HighPrecision (1, false);
+
+  a.Sub (b);
+  CHECK_EXPECTED (a, 0);
+
+  a = V (1);
+  a.Sub (V (2));
+  CHECK_EXPECTED (a, -1);
+
+  a = V (1);
+  a.Sub (V (3));
+  CHECK_EXPECTED (a, -2);
+
+  a = V (1);
+  a.Sub (V (-1));
+  CHECK_EXPECTED (a, 2);
+
+  a = V (1);
+  a.Sub (V (-2));
+  CHECK_EXPECTED (a, 3);
+
+  a = V (-3);
+  a.Sub (V (-4));
+  CHECK_EXPECTED (a, 1);
+
+  a = V (-2);
+  a.Sub (V (3));
+  CHECK_EXPECTED (a, -5);
+
+  a = V (1);
+  a.Add (V (2));
+  CHECK_EXPECTED (a, 3);
+
+  a = V (1);
+  a.Add (V (-3));
+  CHECK_EXPECTED (a, -2);
+
+  a = V (0);
+  a.Add (V (0));
+  CHECK_EXPECTED (a, 0);
+
+  a = V (0);
+  a.Mul (V (0));
+  CHECK_EXPECTED (a, 0);
+  a = V (0);
+  a.Mul (V (1));
+  CHECK_EXPECTED (a, 0);
+  a = V (0);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, 0);
+  a = V (1);
+  a.Mul (V (0));
+  CHECK_EXPECTED (a, 0);
+  a = V (1);
+  a.Mul (V (1));
+  CHECK_EXPECTED (a, 1);
+  a = V (1);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, -1);
+  a = V (-1);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, 1);
+
+  a = V (0);
+  a.Mul (V (1));
+  CHECK_EXPECTED (a, 0);
+  a = V (0);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, 0);
+  a = V (1);
+  a.Mul (V (1));
+  CHECK_EXPECTED (a, 1);
+  a = V (1);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, -1);
+  a = V (-1);
+  a.Mul (V (1));
+  CHECK_EXPECTED (a, -1);
+  a = V (-1);
+  a.Mul (V (-1));
+  CHECK_EXPECTED (a, 1);
+
+
+
+  a = V (2);
+  a.Mul (V (3));
+  a.Div (V (3));
+  CHECK_EXPECTED (a, 2);
+
+  // Below, the division loses precision because 2/3 is not
+  // representable exactly in 64.64 integers. So, we got
+  // something super close but the final rounding kills us.
+  a = V (2);
+  a.Div (V (3));
+  a.Mul (V (3));
+  CHECK_EXPECTED (a, 1);
+
+  // The example below shows that we really do not lose
+  // much precision internally: it is almost always the
+  // final conversion which loses precision.
+  a = V (2000000000);
+  a.Div (V (3));
+  a.Mul (V (3));
+  CHECK_EXPECTED (a, 1999999999);
+}
+
+class HpBug455TestCase : public TestCase
+{
+public:
+  HpBug455TestCase ();
+  virtual void DoRun (void);
+};
+
+HpBug455TestCase::HpBug455TestCase ()
+  : TestCase ("Test case for bug 455")
+{
+}
+void
+HpBug455TestCase::DoRun (void)
+{
+  HighPrecision a = HighPrecision (0.1);
+  a.Div (HighPrecision (1.25));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 0.08, "The original testcase");
+  a = HighPrecision (0.5);
+  a.Mul (HighPrecision (5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 2.5, "Simple test for multiplication");
+  a = HighPrecision (-0.5);
+  a.Mul (HighPrecision (5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -2.5, "Test sign, first operation negative");
+  a = HighPrecision (-0.5);
+  a.Mul (HighPrecision (-5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 2.5, "both operands negative");
+  a = HighPrecision (0.5);
+  a.Mul (HighPrecision (-5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -2.5, "only second operand negative");
+}
+
+
+class HpBug863TestCase : public TestCase
+{
+public:
+  HpBug863TestCase ();
+  virtual void DoRun (void);
+};
+
+HpBug863TestCase::HpBug863TestCase ()
+  : TestCase ("Test case for bug 863")
+{
+}
+void
+HpBug863TestCase::DoRun (void)
+{
+  HighPrecision a = HighPrecision (0.9);
+  a.Div (HighPrecision (1));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 0.9, "The original testcase");
+  a = HighPrecision (0.5);
+  a.Div (HighPrecision (0.5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 1.0, "Simple test for division");
+  a = HighPrecision (-0.5);
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -0.5, "Check that we actually convert doubles correctly");
+  a.Div (HighPrecision (0.5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -1.0, "first argument negative");
+  a = HighPrecision (0.5);
+  a.Div (HighPrecision (-0.5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), -1.0, "second argument negative");
+  a = HighPrecision (-0.5);
+  a.Div (HighPrecision (-0.5));
+  NS_TEST_ASSERT_MSG_EQ (a.GetDouble (), 1.0, "both arguments negative");
+}
+
+class HpCompareTestCase : public TestCase
+{
+public:
+  HpCompareTestCase ();
+  virtual void DoRun (void);
+};
+
+HpCompareTestCase::HpCompareTestCase ()
+  : TestCase ("Check basic compare operations")
+{
+}
+void
+HpCompareTestCase::DoRun (void)
+{
+  HighPrecision a, b;
+
+  a = V (-1);
+  b = V (1);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), -1, "a is smaller than b");
+  a = V (-1);
+  b = V (-2);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 1, "a is bigger than b");
+  a = V (-1);
+  b = V (-1);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 0, "a is equal to b");
+
+  a = V (1);
+  b = V (-1);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 1, "a is bigger than b");
+  a = V (1);
+  b = V (2);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), -1, "a is smaller than b");
+  a = V (1);
+  b = V (1);
+  NS_TEST_ASSERT_MSG_EQ (a.Compare (b), 0, "a is equal to b");
+}
+
+class HpInvertTestCase : public TestCase
+{
+public:
+  HpInvertTestCase ();
+  virtual void DoRun (void);
+};
+
+HpInvertTestCase::HpInvertTestCase ()
+  : TestCase ("Test case for invertion")
+{
+}
+
+void
+HpInvertTestCase::DoRun (void)
+{
+#define TEST(factor)                                                    \
+  do {                                                                  \
+    HighPrecision a;                                                    \
+    a = HighPrecision::Invert (factor);                                 \
+    HighPrecision b = V (factor);                                       \
+    b.MulByInvert (a);                                                  \
+    NS_TEST_ASSERT_MSG_EQ (b.GetInteger (), 1,                          \
+                           "x * 1/x should be 1 for x=" << factor);     \
+    HighPrecision c = V (1);                                            \
+    c.MulByInvert (a);                                                  \
+    NS_TEST_ASSERT_MSG_EQ (c.GetInteger (), 0,                          \
+                           "1 * 1/x should be 0 for x=" << factor);     \
+    HighPrecision d = V (1);                                            \
+    d.Div (V(factor));                                                  \
+    NS_TEST_ASSERT_MSG_EQ (d.GetDouble (), c.GetDouble (),              \
+                           "1 * 1/x should be equal to 1/x for x=" << factor); \
+    HighPrecision e = V (-factor);                                      \
+    e.MulByInvert (a);                                                  \
+    NS_TEST_ASSERT_MSG_EQ (e.GetInteger (), -1,                         \
+                           "-x * 1/x should be -1 for x=" << factor);   \
+  } while(false)
+
+  TEST(2);
+  TEST(3);
+  TEST(4);
+  TEST(5);
+  TEST(6);
+  TEST(10);
+  TEST(99);
+  TEST(100);
+  TEST(1000);
+  TEST(10000);
+  TEST(100000);
+  TEST(100000);
+  TEST(1000000);
+  TEST(10000000);
+  TEST(100000000);
+  TEST(1000000000);
+  TEST(10000000000LL);
+  TEST(100000000000LL);
+  TEST(1000000000000LL);
+  TEST(10000000000000LL);
+  TEST(100000000000000LL);
+  TEST(1000000000000000LL);
+#undef TEST
+}
+
+
+static class HighPrecisionTestSuite : public TestSuite
+{
+public:
+  HighPrecisionTestSuite ()
+    : TestSuite ("high-precision", UNIT)
+  {
+    AddTestCase (new HpArithmeticTestCase ());
+    AddTestCase (new HpBug455TestCase ());
+    AddTestCase (new HpBug863TestCase ());
+    AddTestCase (new HpCompareTestCase ());
+    AddTestCase (new HpInvertTestCase ());
+  }
+} g_highPrecisionTestSuite;
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/time-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,140 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,2006 INRIA
+ * Copyright (c) 2007 Emmanuelle Laprise
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <[email protected]>
+ * TimeStep support by Emmanuelle Laprise <[email protected]>
+ */
+#include "ns3/nstime.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+class Bug863TestCase : public TestCase
+{
+public:
+  Bug863TestCase ();
+  virtual void DoRun (void);
+};
+
+Bug863TestCase::Bug863TestCase ()
+  : TestCase ("Bug 863")
+{
+}
+
+void Bug863TestCase::DoRun (void)
+{
+  Scalar result = Scalar (0.9) / Scalar (1.0);
+  NS_TEST_ASSERT_MSG_EQ ((result == Scalar (0.9)), true, "Invalid arithmetic result");
+}
+
+class TimeSimpleTestCase : public TestCase
+{
+public:
+  TimeSimpleTestCase (enum Time::Unit resolution);
+private:
+  virtual void DoRun (void);
+  virtual void DoTearDown (void);
+  enum Time::Unit m_originalResolution;
+  enum Time::Unit m_resolution;
+};
+
+TimeSimpleTestCase::TimeSimpleTestCase (enum Time::Unit resolution)
+  : TestCase ("Sanity check of common time operations"),
+    m_resolution (resolution)
+{}
+void
+TimeSimpleTestCase::DoRun (void)
+{
+  m_originalResolution = Time::GetResolution ();
+  Time::SetResolution (m_resolution);
+  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 (), 
+                             "is 10 really 10 ?");
+  NS_TEST_ASSERT_MSG_EQ (MilliSeconds (1).GetMilliSeconds (), 1, 
+                         "is 1ms really 1ms ?");
+  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, 
+                         "is 1ns really 1ns ?");
+  NS_TEST_ASSERT_MSG_EQ (PicoSeconds (1).GetPicoSeconds (), 1, 
+                         "is 1ps really 1ps ?");
+  NS_TEST_ASSERT_MSG_EQ (FemtoSeconds (1).GetFemtoSeconds (), 1, 
+                         "is 1fs really 1fs ?");
+#endif
+}
+
+void 
+TimeSimpleTestCase::DoTearDown (void)
+{
+  Time::SetResolution (m_originalResolution);
+}
+
+class ArithTestCase : public TestCase
+{
+public:
+  ArithTestCase ();
+private:
+  virtual void DoRun (void);
+};
+
+ArithTestCase::ArithTestCase ()
+  : TestCase ("check arithmetic operators")
+{
+}
+void
+ArithTestCase::DoRun (void)
+{
+  Time a, b, c;
+  c = a + b;
+  c = a * b;
+  c = a / Seconds (1.0);
+  c = a - b;
+  c += a;
+  c -= a;
+  c /= Seconds (1.0);
+  c *= a;
+  bool x;
+  x = a < b;
+  x = a > b;
+  x = a <= b;
+  x = a >= b;
+  x = a == b;
+  x = a != b;
+  //a = 1.0;
+  //a = 1;
+}
+
+
+
+static class TimeTestSuite : public TestSuite
+{
+public:
+  TimeTestSuite ()
+    : TestSuite ("time", UNIT)
+  {
+    AddTestCase (new Bug863TestCase ());
+    AddTestCase (new TimeSimpleTestCase (Time::US));
+    AddTestCase (new ArithTestCase ());
+  }
+} g_timeTestSuite;
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/timer-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,233 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <[email protected]>
+ */
+#include "ns3/timer.h"
+#include "ns3/test.h"
+#include "ns3/simulator.h"
+#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 bar6i (int, int, int, int, int, int)
+{
+}
+void barcir (const int &)
+{
+}
+void barir (int &)
+{
+}
+void barip (int *)
+{
+}
+void barcip (const int *)
+{
+}
+} // anonymous namespace
+
+namespace ns3 {
+
+class TimerStateTestCase : public TestCase
+{
+public:
+  TimerStateTestCase ();
+  virtual void DoRun (void);
+};
+
+TimerStateTestCase::TimerStateTestCase ()
+  : TestCase ("Check correct state transitions")
+{
+}
+void
+TimerStateTestCase::DoRun (void)
+{
+  Timer timer = Timer (Timer::CANCEL_ON_DESTROY);
+
+  timer.SetFunction (&bari);
+  timer.SetArguments (1);
+  timer.SetDelay (Seconds (10.0));
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.IsExpired (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::EXPIRED, "");
+  timer.Schedule ();
+  NS_TEST_ASSERT_MSG_EQ (timer.IsRunning (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::RUNNING, "");
+  timer.Suspend ();
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.IsSuspended (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::SUSPENDED, "");
+  timer.Resume ();
+  NS_TEST_ASSERT_MSG_EQ (timer.IsRunning (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsExpired (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::RUNNING, "");
+  timer.Cancel ();
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsRunning (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.IsExpired (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (!timer.IsSuspended (), true, "");
+  NS_TEST_ASSERT_MSG_EQ (timer.GetState (), Timer::EXPIRED, "");
+}
+
+class TimerTemplateTestCase : public TestCase
+{
+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 *)
+  {
+  }
+};
+
+TimerTemplateTestCase::TimerTemplateTestCase ()
+  : TestCase ("Check that template magic is working")
+{
+}
+
+void
+TimerTemplateTestCase::DoRun (void)
+{
+  Timer timer = Timer (Timer::CANCEL_ON_DESTROY);
+
+  int a = 0;
+  int &b = a;
+  const int &c = a;
+
+  timer.SetFunction (&bari);
+  timer.SetArguments (2);
+  timer.SetArguments (a);
+  timer.SetArguments (b);
+  timer.SetArguments (c);
+  timer.SetFunction (&barir);
+  timer.SetArguments (2);
+  timer.SetArguments (a);
+  timer.SetArguments (b);
+  timer.SetArguments (c);
+  timer.SetFunction (&barcir);
+  timer.SetArguments (2);
+  timer.SetArguments (a);
+  timer.SetArguments (b);
+  timer.SetArguments (c);
+  // the following call cannot possibly work and is flagged by
+  // a runtime error.
+  // timer.SetArguments (0.0);
+  timer.SetDelay (Seconds (1.0));
+  timer.Schedule ();
+
+  timer.SetFunction (&TimerTemplateTestCase::bazi, this);
+  timer.SetArguments (3);
+  timer.SetFunction (&TimerTemplateTestCase::bazir, this);
+  timer.SetArguments (3);
+  timer.SetFunction (&TimerTemplateTestCase::bazcir, this);
+  timer.SetArguments (3);
+
+  timer.SetFunction (&bar2i);
+  timer.SetArguments (1, 1);
+  timer.SetFunction (&bar3i);
+  timer.SetArguments (1, 1, 1);
+  timer.SetFunction (&bar4i);
+  timer.SetArguments (1, 1, 1, 1);
+  timer.SetFunction (&bar5i);
+  timer.SetArguments (1, 1, 1, 1, 1);
+  // unsupported in simulator class
+  // timer.SetFunction (&bar6i);
+  // timer.SetArguments (1, 1, 1, 1, 1, 1);
+
+  timer.SetFunction (&TimerTemplateTestCase::baz2i, this);
+  timer.SetArguments (1, 1);
+  timer.SetFunction (&TimerTemplateTestCase::baz3i, this);
+  timer.SetArguments (1, 1, 1);
+  timer.SetFunction (&TimerTemplateTestCase::baz4i, this);
+  timer.SetArguments (1, 1, 1, 1);
+  timer.SetFunction (&TimerTemplateTestCase::baz5i, this);
+  timer.SetArguments (1, 1, 1, 1, 1);
+  // unsupported in simulator class
+  // timer.SetFunction (&TimerTemplateTestCase::baz6i, this);
+  // timer.SetArguments (1, 1, 1, 1, 1, 1);
+
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+
+void
+TimerTemplateTestCase::DoTeardown (void)
+{
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+
+static class TimerTestSuite : public TestSuite
+{
+public:
+  TimerTestSuite ()
+    : TestSuite ("timer", UNIT)
+  {
+    AddTestCase (new TimerStateTestCase ());
+    AddTestCase (new TimerTemplateTestCase ());
+  }
+} g_timerTestSuite;
+
+} // namespace ns3
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/test/watchdog-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,81 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <[email protected]>
+ */
+#include "ns3/watchdog.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+class WatchdogTestCase : public TestCase
+{
+public:
+  WatchdogTestCase ();
+  virtual void DoRun (void);
+  void Expire (Time expected);
+  bool m_expired;
+  Time m_expiredTime;
+  Time m_expiredArgument;
+};
+
+WatchdogTestCase::WatchdogTestCase()
+  : TestCase ("Check that we can keepalive a watchdog")
+{}
+
+void
+WatchdogTestCase::Expire (Time expected)
+{
+  m_expired = true;
+  m_expiredTime = Simulator::Now ();
+  m_expiredArgument = expected;
+}
+
+void
+WatchdogTestCase::DoRun (void)
+{
+  m_expired = false;
+  m_expiredArgument = Seconds (0);
+  m_expiredTime = Seconds (0);
+  Watchdog watchdog;
+  watchdog.SetFunction (&WatchdogTestCase::Expire, this);
+  watchdog.SetArguments (MicroSeconds (40));
+  watchdog.Ping (MicroSeconds (10));
+  Simulator::Schedule (MicroSeconds (5), &Watchdog::Ping, &watchdog, MicroSeconds (20));
+  Simulator::Schedule (MicroSeconds (20), &Watchdog::Ping, &watchdog, MicroSeconds (2));
+  Simulator::Schedule (MicroSeconds (23), &Watchdog::Ping, &watchdog, MicroSeconds (17));
+  Simulator::Run ();
+  Simulator::Destroy ();
+  NS_TEST_ASSERT_MSG_EQ (m_expired, true, "The timer did not expire ??");
+  NS_TEST_ASSERT_MSG_EQ (m_expiredTime, MicroSeconds (40), "The timer did not expire at the expected time ?");
+  NS_TEST_ASSERT_MSG_EQ (m_expiredArgument, MicroSeconds (40), "We did not get the right argument");
+}
+
+
+
+static class WatchdogTestSuite : public TestSuite
+{
+public:
+  WatchdogTestSuite()
+    : TestSuite ("watchdog", UNIT)
+  {
+    AddTestCase (new WatchdogTestCase ());
+  }
+} g_watchdogTestSuite;
+
+} // namespace ns3
+
--- a/src/core/wscript	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/core/wscript	Fri Mar 25 12:55:27 2011 -0700
@@ -144,10 +144,14 @@
     core_test.source = [
         'test/attribute-test-suite.cc',
         'test/callback-test-suite.cc',
+        'test/high-precision-test-suite.cc',
         'test/names-test-suite.cc',
+        'test/ptr-test-suite.cc',
+        'test/time-test-suite.cc',
+        'test/timer-test-suite.cc',
+        'test/traced-callback-test-suite.cc',
         'test/type-traits-test-suite.cc',
-        'test/traced-callback-test-suite.cc',
-        'test/ptr-test-suite.cc',
+        'test/watchdog-test-suite.cc',
         ]
 
     headers = bld.new_task_gen('ns3header')
@@ -232,8 +236,9 @@
     if env['USE_HIGH_PRECISION_DOUBLE']:
         headers.source.extend(['model/high-precision-double.h'])
     elif env['USE_HIGH_PRECISION_128']:
-        headers.source.extend(['model/high-precision-128.h'])
-        core.source.extend(['model/high-precision-128.cc'])
+        headers  .source.extend(['model/high-precision-128.h'])
+        core     .source.extend(['model/high-precision-128.cc'])
+        core_test.source.extend(['test/high-precision-128-test-suite.cc'])
     elif env['USE_HIGH_PRECISION_CAIRO']:
         core.source.extend([
             'model/high-precision-cairo.cc',
--- a/src/flow-monitor/model/histogram.cc	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/flow-monitor/model/histogram.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -148,65 +148,3 @@
 } // namespace ns3
 
 
-#include "ns3/test.h"
-
-namespace ns3 {
-
-class HistogramTestCase : public ns3::TestCase {
-private:
-public:
-  HistogramTestCase ();
-  virtual void DoRun (void);
-
-
-};
-
-HistogramTestCase::HistogramTestCase ()
-  : ns3::TestCase ("Histogram")
-{}
-
-
-void
-HistogramTestCase::DoRun (void)
-{
-  Histogram h0(3.5);
-  // Testing floating-point bin widths
-  {
-    for (int i=1; i <= 10; i++)
-      { 
-        h0.AddValue (3.4);
-      }
-    
-    for (int i=1; i <= 5; i++)
-      {    
-        h0.AddValue (3.6);
-      }
-    
-    NS_TEST_EXPECT_MSG_EQ_TOL (h0.GetBinWidth (0),  3.5, 1e-6, "");
-    NS_TEST_EXPECT_MSG_EQ (h0.GetNBins (),  2, "");
-    NS_TEST_EXPECT_MSG_EQ_TOL (h0.GetBinStart (1),  3.5, 1e-6, "");
-    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (0),  10, "");
-    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (1),  5, "");
-  }
-  
-  {
-    // Testing bin expansion
-    h0.AddValue (74.3);
-    NS_TEST_EXPECT_MSG_EQ (h0.GetNBins (), 22, "");
-    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (21), 1, "");
-  }
-}
-
-static class HistogramTestSuite : public TestSuite
-{
-public:
-  HistogramTestSuite ()
-    : TestSuite ("histogram", UNIT) 
-  {
-    AddTestCase (new HistogramTestCase ());
-  }
-} g_HistogramTestSuite;
-
-} // namespace
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flow-monitor/test/histogram-test-suite.cc	Fri Mar 25 12:55:27 2011 -0700
@@ -0,0 +1,83 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+//
+// Copyright (c) 2009 INESC Porto
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation;
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Author: Pedro Fortuna  <[email protected]> <[email protected]>
+//
+
+#include "ns3/histogram.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+class HistogramTestCase : public ns3::TestCase {
+private:
+public:
+  HistogramTestCase ();
+  virtual void DoRun (void);
+
+
+};
+
+HistogramTestCase::HistogramTestCase ()
+  : ns3::TestCase ("Histogram")
+{}
+
+
+void
+HistogramTestCase::DoRun (void)
+{
+  Histogram h0(3.5);
+  // Testing floating-point bin widths
+  {
+    for (int i=1; i <= 10; i++)
+      { 
+        h0.AddValue (3.4);
+      }
+    
+    for (int i=1; i <= 5; i++)
+      {    
+        h0.AddValue (3.6);
+      }
+    
+    NS_TEST_EXPECT_MSG_EQ_TOL (h0.GetBinWidth (0),  3.5, 1e-6, "");
+    NS_TEST_EXPECT_MSG_EQ (h0.GetNBins (),  2, "");
+    NS_TEST_EXPECT_MSG_EQ_TOL (h0.GetBinStart (1),  3.5, 1e-6, "");
+    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (0),  10, "");
+    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (1),  5, "");
+  }
+  
+  {
+    // Testing bin expansion
+    h0.AddValue (74.3);
+    NS_TEST_EXPECT_MSG_EQ (h0.GetNBins (), 22, "");
+    NS_TEST_EXPECT_MSG_EQ (h0.GetBinCount (21), 1, "");
+  }
+}
+
+static class HistogramTestSuite : public TestSuite
+{
+public:
+  HistogramTestSuite ()
+    : TestSuite ("histogram", UNIT) 
+  {
+    AddTestCase (new HistogramTestCase ());
+  }
+} g_HistogramTestSuite;
+
+} // namespace
+
+
--- a/src/flow-monitor/wscript	Fri Mar 25 10:16:24 2011 -0700
+++ b/src/flow-monitor/wscript	Fri Mar 25 12:55:27 2011 -0700
@@ -12,6 +12,11 @@
         ]]
     obj.source.append("helper/flow-monitor-helper.cc")
 
+    module_test = bld.create_ns3_module_test_library('flow-monitor')
+    module_test.source = [
+        'test/histogram-test-suite.cc',
+        ]
+
     headers = bld.new_task_gen('ns3header')
     headers.module = 'flow-monitor'
     headers.source = ["model/%s" % s for s in [