LEFT | RIGHT |
(no file at all) | |
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) 2009 University of Washington | 3 * Copyright (c) 2009 University of Washington |
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 | 18 |
19 #include "ns3/test.h" | 19 #include "ns3/test.h" |
20 #include "ns3/callback.h" | 20 #include "ns3/callback.h" |
| 21 #include "ns3/unused.h" |
21 #include <stdint.h> | 22 #include <stdint.h> |
22 | 23 |
23 using namespace ns3; | 24 using namespace ns3; |
24 | 25 |
25 // =========================================================================== | 26 // =========================================================================== |
26 // Test the basic Callback mechanism | 27 // Test the basic Callback mechanism |
27 // =========================================================================== | 28 // =========================================================================== |
28 class BasicCallbackTestCase : public TestCase | 29 class BasicCallbackTestCase : public TestCase |
29 { | 30 { |
30 public: | 31 public: |
31 BasicCallbackTestCase (); | 32 BasicCallbackTestCase (); |
32 virtual ~BasicCallbackTestCase () {} | 33 virtual ~BasicCallbackTestCase () {} |
33 | 34 |
34 void Target1 (void) { m_test1 = true; } | 35 void Target1 (void) { m_test1 = true; } |
35 int Target2 (void) { m_test2 = true; return 2; } | 36 int Target2 (void) { m_test2 = true; return 2; } |
36 void Target3 (double a) { m_test3 = true; } | 37 void Target3 (double a) |
37 int Target4 (double a, int b) { m_test4 = true; return 4; } | 38 {· |
| 39 NS_UNUSED (a);· |
| 40 m_test3 = true;· |
| 41 } |
| 42 int Target4 (double a, int b) |
| 43 {· |
| 44 NS_UNUSED (a);· |
| 45 NS_UNUSED (b);· |
| 46 m_test4 = true; |
| 47 return 4; |
| 48 } |
38 | 49 |
39 private: | 50 private: |
40 virtual void DoRun (void); | 51 virtual void DoRun (void); |
41 virtual void DoSetup (void); | 52 virtual void DoSetup (void); |
42 | 53 |
43 bool m_test1; | 54 bool m_test1; |
44 bool m_test2; | 55 bool m_test2; |
45 bool m_test3; | 56 bool m_test3; |
46 bool m_test4; | 57 bool m_test4; |
47 }; | 58 }; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Test the MakeCallback mechanism | 167 // Test the MakeCallback mechanism |
157 // =========================================================================== | 168 // =========================================================================== |
158 class MakeCallbackTestCase : public TestCase | 169 class MakeCallbackTestCase : public TestCase |
159 { | 170 { |
160 public: | 171 public: |
161 MakeCallbackTestCase (); | 172 MakeCallbackTestCase (); |
162 virtual ~MakeCallbackTestCase () {} | 173 virtual ~MakeCallbackTestCase () {} |
163 | 174 |
164 void Target1 (void) { m_test1 = true; } | 175 void Target1 (void) { m_test1 = true; } |
165 int Target2 (void) { m_test2 = true; return 2; } | 176 int Target2 (void) { m_test2 = true; return 2; } |
166 void Target3 (double a) { m_test3 = true; } | 177 void Target3 (double a) |
167 int Target4 (double a, int b) { m_test4 = true; return 4; } | 178 {· |
| 179 NS_UNUSED (a);· |
| 180 m_test3 = true;· |
| 181 } |
| 182 int Target4 (double a, int b) |
| 183 {· |
| 184 NS_UNUSED (a);· |
| 185 NS_UNUSED (b);· |
| 186 m_test4 = true; |
| 187 return 4; |
| 188 } |
168 | 189 |
169 private: | 190 private: |
170 virtual void DoRun (void); | 191 virtual void DoRun (void); |
171 virtual void DoSetup (void); | 192 virtual void DoSetup (void); |
172 | 193 |
173 bool m_test1; | 194 bool m_test1; |
174 bool m_test2; | 195 bool m_test2; |
175 bool m_test3; | 196 bool m_test3; |
176 bool m_test4; | 197 bool m_test4; |
177 }; | 198 }; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 : TestSuite ("callback", UNIT) | 722 : TestSuite ("callback", UNIT) |
702 { | 723 { |
703 AddTestCase (new BasicCallbackTestCase, TestCase::QUICK); | 724 AddTestCase (new BasicCallbackTestCase, TestCase::QUICK); |
704 AddTestCase (new MakeCallbackTestCase, TestCase::QUICK); | 725 AddTestCase (new MakeCallbackTestCase, TestCase::QUICK); |
705 AddTestCase (new MakeBoundCallbackTestCase, TestCase::QUICK); | 726 AddTestCase (new MakeBoundCallbackTestCase, TestCase::QUICK); |
706 AddTestCase (new NullifyCallbackTestCase, TestCase::QUICK); | 727 AddTestCase (new NullifyCallbackTestCase, TestCase::QUICK); |
707 AddTestCase (new MakeCallbackTemplatesTestCase, TestCase::QUICK); | 728 AddTestCase (new MakeCallbackTemplatesTestCase, TestCase::QUICK); |
708 } | 729 } |
709 | 730 |
710 static CallbackTestSuite CallbackTestSuite; | 731 static CallbackTestSuite CallbackTestSuite; |
LEFT | RIGHT |