OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/test.h" | 21 #include "ns3/test.h" |
22 #include "ns3/ptr.h" | 22 #include "ns3/ptr.h" |
23 | 23 |
24 using namespace ns3; | 24 using namespace ns3; |
25 | 25 |
26 class PtrTestCase; | 26 class PtrTestCase; |
27 | 27 |
| 28 /** |
| 29 * \ingroup core-test |
| 30 * \ingroup tests |
| 31 * |
| 32 * \brief Pointer base test class |
| 33 */ |
28 class PtrTestBase | 34 class PtrTestBase |
29 { | 35 { |
30 public: | 36 public: |
31 PtrTestBase (); | 37 PtrTestBase (); |
32 virtual ~PtrTestBase (); | 38 virtual ~PtrTestBase (); |
| 39 /// test function |
33 void Ref (void) const; | 40 void Ref (void) const; |
| 41 /// test function |
34 void Unref (void) const; | 42 void Unref (void) const; |
35 private: | 43 private: |
36 mutable uint32_t m_count; | 44 mutable uint32_t m_count; ///< test variable |
37 }; | 45 }; |
38 | 46 |
| 47 /** |
| 48 * \ingroup core-test |
| 49 * \ingroup tests |
| 50 * |
| 51 * \brief No Count class |
| 52 */ |
39 class NoCount : public PtrTestBase | 53 class NoCount : public PtrTestBase |
40 { | 54 { |
41 public: | 55 public: |
| 56 /** |
| 57 * Constructor |
| 58 * |
| 59 * \param test the test case |
| 60 */ |
42 NoCount (PtrTestCase *test); | 61 NoCount (PtrTestCase *test); |
43 ~NoCount (); | 62 ~NoCount (); |
| 63 /// test function |
44 void Nothing (void) const; | 64 void Nothing (void) const; |
45 private: | 65 private: |
46 PtrTestCase *m_test; | 66 PtrTestCase *m_test; ///< test variable |
47 }; | 67 }; |
48 | 68 |
49 | 69 |
| 70 /** |
| 71 * \ingroup core-test |
| 72 * \ingroup tests |
| 73 * |
| 74 * \brief Test case for pointer |
| 75 */ |
50 class PtrTestCase : public TestCase | 76 class PtrTestCase : public TestCase |
51 { | 77 { |
52 public: | 78 public: |
53 PtrTestCase (); | 79 PtrTestCase (); |
| 80 /// test function |
54 void DestroyNotify (void); | 81 void DestroyNotify (void); |
55 private: | 82 private: |
56 virtual void DoRun (void); | 83 virtual void DoRun (void); |
| 84 /** |
| 85 * Call test function |
| 86 * \param p Ptr<NoCount> |
| 87 * \returns Ptr<NoCount> |
| 88 */ |
57 Ptr<NoCount> CallTest (Ptr<NoCount> p); | 89 Ptr<NoCount> CallTest (Ptr<NoCount> p); |
| 90 /** |
| 91 * Call test const function |
| 92 * \param p Ptr<NoCount> |
| 93 * \returns Ptr<NoCount> |
| 94 */ |
58 Ptr<NoCount> const CallTestConst (Ptr<NoCount> const p); | 95 Ptr<NoCount> const CallTestConst (Ptr<NoCount> const p); |
59 uint32_t m_nDestroyed; | 96 uint32_t m_nDestroyed; ///< test variable |
60 }; | 97 }; |
61 | 98 |
62 | 99 |
63 PtrTestBase::PtrTestBase () | 100 PtrTestBase::PtrTestBase () |
64 : m_count (1) | 101 : m_count (1) |
65 { | 102 { |
66 } | 103 } |
67 PtrTestBase::~PtrTestBase () | 104 PtrTestBase::~PtrTestBase () |
68 { | 105 { |
69 } | 106 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 NS_TEST_EXPECT_MSG_EQ (m_nDestroyed, 1, "013"); | 293 NS_TEST_EXPECT_MSG_EQ (m_nDestroyed, 1, "013"); |
257 | 294 |
258 { | 295 { |
259 Ptr<PtrTestBase> p0 = Create<NoCount> (this); | 296 Ptr<PtrTestBase> p0 = Create<NoCount> (this); |
260 Ptr<NoCount> p1 = Create<NoCount> (this); | 297 Ptr<NoCount> p1 = Create<NoCount> (this); |
261 NS_TEST_EXPECT_MSG_EQ ((p0 == p1), false, "operator == failed"); | 298 NS_TEST_EXPECT_MSG_EQ ((p0 == p1), false, "operator == failed"); |
262 NS_TEST_EXPECT_MSG_EQ ((p0 != p1), true, "operator != failed"); | 299 NS_TEST_EXPECT_MSG_EQ ((p0 != p1), true, "operator != failed"); |
263 } | 300 } |
264 } | 301 } |
265 | 302 |
| 303 /** |
| 304 * \ingroup core-test |
| 305 * \ingroup tests |
| 306 * |
| 307 * \brief Test suite for pointer |
| 308 */ |
266 static class PtrTestSuite : public TestSuite | 309 static class PtrTestSuite : public TestSuite |
267 { | 310 { |
268 public: | 311 public: |
269 PtrTestSuite () | 312 PtrTestSuite () |
270 : TestSuite ("ptr", UNIT) | 313 : TestSuite ("ptr", UNIT) |
271 { | 314 { |
272 AddTestCase (new PtrTestCase (), TestCase::QUICK); | 315 AddTestCase (new PtrTestCase (), TestCase::QUICK); |
273 } | 316 } |
274 } g_ptrTestSuite; | 317 } g_ptrTestSuite; ///< the test suite |
OLD | NEW |