author | Josh Pelkey <jpelkey@gatech.edu> |
Fri, 13 May 2011 14:52:27 -0400 | |
changeset 7169 | 358f71a624d8 |
parent 7155 | e3e4192e2f67 |
child 9266 | d26408b17360 |
permissions | -rw-r--r-- |
5270 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
||
3 |
// An essential include is test.h |
|
4 |
#include "ns3/test.h" |
|
5 |
||
6 |
// Do not put your test classes in namespace ns3. You may find it useful |
|
7 |
// to use the using directive to access the ns3 namespace directly |
|
8 |
using namespace ns3; |
|
9 |
||
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7155
diff
changeset
|
10 |
// This is an example TestCase. |
5270 | 11 |
class SampleTestCase1 : public TestCase |
12 |
{ |
|
13 |
public: |
|
14 |
SampleTestCase1 (); |
|
15 |
virtual ~SampleTestCase1 (); |
|
16 |
||
17 |
private: |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
18 |
virtual void DoRun (void); |
5270 | 19 |
}; |
20 |
||
21 |
// Add some help text to this case to describe what it is intended to test |
|
22 |
SampleTestCase1::SampleTestCase1 () |
|
23 |
: TestCase ("Sample test case (does nothing)") |
|
24 |
{ |
|
25 |
} |
|
26 |
||
27 |
// This destructor does nothing but we include it as a reminder that |
|
28 |
// the test case should clean up after itself |
|
29 |
SampleTestCase1::~SampleTestCase1 () |
|
30 |
{ |
|
31 |
} |
|
32 |
||
33 |
// |
|
34 |
// This method is the pure virtual method from class TestCase that every |
|
35 |
// TestCase must implement |
|
36 |
// |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
37 |
void |
5270 | 38 |
SampleTestCase1::DoRun (void) |
39 |
{ |
|
40 |
// A wide variety of test macros are available in src/core/test.h |
|
41 |
NS_TEST_ASSERT_MSG_EQ (true, true, "true doesn't equal true for some reason"); |
|
42 |
// Use this one for floating point comparisons |
|
43 |
NS_TEST_ASSERT_MSG_EQ_TOL (0.01, 0.01, 0.001, "Numbers are not equal within tolerance"); |
|
44 |
} |
|
45 |
||
46 |
// The TestSuite class names the TestSuite, identifies what type of TestSuite, |
|
47 |
// and enables the TestCases to be run. Typically, only the constructor for |
|
48 |
// this class must be defined |
|
49 |
// |
|
50 |
class SampleTestSuite : public TestSuite |
|
51 |
{ |
|
52 |
public: |
|
53 |
SampleTestSuite (); |
|
54 |
}; |
|
55 |
||
56 |
SampleTestSuite::SampleTestSuite () |
|
7008
82c66d5c01f7
Relabel all build verification tests (BVT) to be unit tests (UNIT)
Mitch Watrous <watrous@u.washington.edu>
parents:
6775
diff
changeset
|
57 |
: TestSuite ("sample", UNIT) |
5270 | 58 |
{ |
59 |
AddTestCase (new SampleTestCase1); |
|
60 |
} |
|
61 |
||
62 |
// Do not forget to allocate an instance of this TestSuite |
|
6774
034f362af24d
Make all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
5270
diff
changeset
|
63 |
static SampleTestSuite sampleTestSuite; |