src/core/model/command-line.cc
changeset 7003 a0b1500cdaad
parent 6821 203367ae7433
child 7169 358f71a624d8
--- a/src/core/model/command-line.cc	Wed Apr 06 15:26:57 2011 -0400
+++ b/src/core/model/command-line.cc	Wed Apr 06 15:32:12 2011 -0700
@@ -22,7 +22,6 @@
 #include "config.h"
 #include "global-value.h"
 #include "type-id.h"
-#include "test.h"
 #include "string.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -306,202 +305,4 @@
   m_items.push_back (item);
 }
 
-// ===========================================================================
-// A test base class that drives Command Line parsing
-// ===========================================================================
-class CommandLineTestCaseBase : public TestCase
-{
-public:
-  CommandLineTestCaseBase (std::string description);
-  virtual ~CommandLineTestCaseBase () {}
-
-  void Parse (const CommandLine &cmd, int n, ...);
-};
-
-CommandLineTestCaseBase::CommandLineTestCaseBase (std::string description)
-  : TestCase (description)
-{
-}
-
-void
-CommandLineTestCaseBase::Parse (const CommandLine &cmd, int n, ...)
-{
-  char **args = new char* [n+1];
-  args[0] = (char *) "Test";
-  va_list ap;
-  va_start (ap, n);
-  int i = 0;
-  while (i < n)
-    {
-      char *arg = va_arg (ap, char *);
-      args[i+1] = arg;
-      i++;
-    }
-  int argc = n + 1;
-  cmd.Parse (argc, args);
-  delete [] args;
-}
-
-// ===========================================================================
-// Test boolean Command Line processing
-// ===========================================================================
-class CommandLineBooleanTestCase : public CommandLineTestCaseBase
-{
-public:
-  CommandLineBooleanTestCase ();
-  virtual ~CommandLineBooleanTestCase () {}
-
-private:
-  virtual void DoRun (void);
-
-};
-
-CommandLineBooleanTestCase::CommandLineBooleanTestCase ()
-  : CommandLineTestCaseBase ("Check boolean arguments")
-{
-}
-
-void
-CommandLineBooleanTestCase::DoRun (void)
-{
-  CommandLine cmd;
-  bool myBool = true;
-
-  cmd.AddValue ("my-bool", "help", myBool);
-
-  Parse (cmd, 1, "--my-bool=0");
-  NS_TEST_ASSERT_MSG_EQ (myBool, false, "Command parser did not correctly set a boolean value to false");
-
-  Parse (cmd, 1, "--my-bool=1");
-  NS_TEST_ASSERT_MSG_EQ (myBool, true, "Command parser did not correctly set a boolean value to true");
-}
-
-// ===========================================================================
-// Test int Command Line processing
-// ===========================================================================
-class CommandLineIntTestCase : public CommandLineTestCaseBase
-{
-public:
-  CommandLineIntTestCase ();
-  virtual ~CommandLineIntTestCase () {}
-
-private:
-  virtual void DoRun (void);
-
-};
-
-CommandLineIntTestCase::CommandLineIntTestCase ()
-  : CommandLineTestCaseBase ("Check int arguments")
-{
-}
-
-void
-CommandLineIntTestCase::DoRun (void)
-{
-  CommandLine cmd;
-  bool myBool = true;
-  int32_t myInt32 = 10;
-
-  cmd.AddValue ("my-bool", "help", myBool);
-  cmd.AddValue ("my-int32", "help", myInt32);
-
-  Parse (cmd, 2, "--my-bool=0", "--my-int32=-3");
-  NS_TEST_ASSERT_MSG_EQ (myBool, false, "Command parser did not correctly set a boolean value to false");
-  NS_TEST_ASSERT_MSG_EQ (myInt32, -3, "Command parser did not correctly set an integer value to -3");
-
-  Parse (cmd, 2, "--my-bool=1", "--my-int32=+2");
-  NS_TEST_ASSERT_MSG_EQ (myBool, true, "Command parser did not correctly set a boolean value to true");
-  NS_TEST_ASSERT_MSG_EQ (myInt32, +2, "Command parser did not correctly set an integer value to +2");
-}
-
-// ===========================================================================
-// Test unsigned int Command Line processing
-// ===========================================================================
-class CommandLineUnsignedIntTestCase : public CommandLineTestCaseBase
-{
-public:
-  CommandLineUnsignedIntTestCase ();
-  virtual ~CommandLineUnsignedIntTestCase () {}
-
-private:
-  virtual void DoRun (void);
-
-};
-
-CommandLineUnsignedIntTestCase::CommandLineUnsignedIntTestCase ()
-  : CommandLineTestCaseBase ("Check unsigned int arguments")
-{
-}
-
-void
-CommandLineUnsignedIntTestCase::DoRun (void)
-{
-  CommandLine cmd;
-  bool myBool = true;
-  uint32_t myUint32 = 10;
-
-  cmd.AddValue ("my-bool", "help", myBool);
-  cmd.AddValue ("my-uint32", "help", myUint32);
-
-  Parse (cmd, 2, "--my-bool=0", "--my-uint32=9");
-
-  NS_TEST_ASSERT_MSG_EQ (myBool, false, "Command parser did not correctly set a boolean value to true");
-  NS_TEST_ASSERT_MSG_EQ (myUint32, 9, "Command parser did not correctly set an unsigned integer value to 9");
-}
-
-// ===========================================================================
-// Test string Command Line processing
-// ===========================================================================
-class CommandLineStringTestCase : public CommandLineTestCaseBase
-{
-public:
-  CommandLineStringTestCase ();
-  virtual ~CommandLineStringTestCase () {}
-
-private:
-  virtual void DoRun (void);
-
-};
-
-CommandLineStringTestCase::CommandLineStringTestCase ()
-  : CommandLineTestCaseBase ("Check unsigned int arguments")
-{
-}
-
-void
-CommandLineStringTestCase::DoRun (void)
-{
-  CommandLine cmd;
-  uint32_t myUint32 = 10;
-  std::string myStr = "MyStr";
-
-  cmd.AddValue ("my-uint32", "help", myUint32);
-  cmd.AddValue ("my-str", "help", myStr);
-
-  Parse (cmd, 2, "--my-uint32=9", "--my-str=XX");
-
-  NS_TEST_ASSERT_MSG_EQ (myUint32, 9, "Command parser did not correctly set an unsigned integer value to 9");
-  NS_TEST_ASSERT_MSG_EQ (myStr, "XX", "Command parser did not correctly set an string value to \"XX\"");
-}
-
-// ===========================================================================
-// The Test Suite that glues all of the Test Cases together.
-// ===========================================================================
-class CommandLineTestSuite : public TestSuite
-{
-public:
-  CommandLineTestSuite ();
-};
-
-CommandLineTestSuite::CommandLineTestSuite ()
-  : TestSuite ("command-line", BVT)
-{
-  AddTestCase (new CommandLineBooleanTestCase);
-  AddTestCase (new CommandLineIntTestCase);
-  AddTestCase (new CommandLineUnsignedIntTestCase);
-  AddTestCase (new CommandLineStringTestCase);
-}
-
-static CommandLineTestSuite CommandLineTestSuite;
-
 } // namespace ns3