A Discrete-Event Network Simulator
API
type-traits-test-suite.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 
18 #include "ns3/test.h"
19 #include "ns3/type-traits.h"
20 
29 namespace ns3
30 {
31 
32 namespace tests
33 {
34 
40 {
41  public:
44 
47  {
48  }
49 
50  private:
51  void DoRun() override;
52 };
53 
55  : TestCase("Check type traits")
56 {
57 }
58 
59 void
61 {
62  NS_TEST_ASSERT_MSG_EQ(TypeTraits<void (TypeTraitsTestCase::*)()>::IsPointerToMember,
63  1,
64  "Check pointer to member function ()");
65  NS_TEST_ASSERT_MSG_EQ(TypeTraits<void (TypeTraitsTestCase::*)() const>::IsPointerToMember,
66  1,
67  "Check pointer to member function () const");
68  NS_TEST_ASSERT_MSG_EQ(TypeTraits<void (TypeTraitsTestCase::*)(int)>::IsPointerToMember,
69  1,
70  "Check pointer to member function (int)");
71  NS_TEST_ASSERT_MSG_EQ(TypeTraits<void (TypeTraitsTestCase::*)(int) const>::IsPointerToMember,
72  1,
73  "Check pointer to member function (int) const");
75  TypeTraits<void (TypeTraitsTestCase::*)() const>::PointerToMemberTraits::nArgs,
76  0,
77  "Check number of arguments for pointer to member function () const");
79  TypeTraits<void (TypeTraitsTestCase::*)(int) const>::PointerToMemberTraits::nArgs,
80  1,
81  "Check number of arguments for pointer to member function (int) const");
82 }
83 
89 {
90  public:
93 };
94 
96  : TestSuite("type-traits")
97 {
99 }
100 
106 
107 } // namespace tests
108 
109 } // namespace ns3
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
~TypeTraitsTestCase() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
static TypeTraitsTestSuite g_typeTraitsTestSuite
TypeTraitsTestSuite instance variable.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:144
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Inspect a type to deduce its features.
Definition: type-traits.h:40