samples/main-test.cc
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 150 663120712cd9
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
#include "ns3/test.h"
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
using namespace ns3;
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
65
253ffbc475dc fix test sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 63
diff changeset
     7
#ifdef RUN_SELF_TESTS
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
63
242eb09c8521 comment a bit the sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 60
diff changeset
     9
// declare subclass of base class Test
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
class MyTest : public Test {
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
public:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    12
  MyTest (bool ok);
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    13
  virtual ~MyTest ();
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    14
  virtual bool RunTests (void);
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
private:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    16
  bool m_ok;
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
};
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
63
242eb09c8521 comment a bit the sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 60
diff changeset
    19
// implement MyTest
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
MyTest::MyTest (bool ok)
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    21
  : Test ("My"),
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    22
    m_ok (ok)
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
{}
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
MyTest::~MyTest ()
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
{}
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
bool
122
6b8f1eda5c57 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 111
diff changeset
    27
MyTest::RunTests (void)
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
{
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    29
  return m_ok;
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
}
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
63
242eb09c8521 comment a bit the sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 60
diff changeset
    32
// instantiate MyTest once
65
253ffbc475dc fix test sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 63
diff changeset
    33
static MyTest g_my_test = MyTest (true);
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
#endif /* RUN_SELF_TESTS */
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
int main (int argc, char *argv[])
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
{
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    39
  // run tests
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    40
  TestManager::EnableVerbose ();
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    41
  TestManager::RunTests ();
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
    42
  return 0;
60
6672664e72bb add sample code for test, add doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
}