author | Tom Henderson <tomh@tomh.org> |
Fri, 18 Feb 2011 16:05:39 -0800 | |
changeset 6821 | 203367ae7433 |
parent 6775 | src/core/callback-test-suite.cc@0783f42a364b |
child 7169 | 358f71a624d8 |
permissions | -rw-r--r-- |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
*/ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
|
6821
203367ae7433
merge src/simulator into src/core; move src/core to new module layout
Tom Henderson <tomh@tomh.org>
parents:
6775
diff
changeset
|
19 |
#include "ns3/test.h" |
203367ae7433
merge src/simulator into src/core; move src/core to new module layout
Tom Henderson <tomh@tomh.org>
parents:
6775
diff
changeset
|
20 |
#include "ns3/callback.h" |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
#include <stdint.h> |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
namespace ns3 { |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// Test the basic Callback mechanism |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
class BasicCallbackTestCase : public TestCase |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
BasicCallbackTestCase (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
virtual ~BasicCallbackTestCase () {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
void Target1 (void) {m_test1 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
int Target2 (void) {m_test2 = true; return 2;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
void Target3 (double a) {m_test3 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
int Target4 (double a, int b) {m_test4 = true; return 4;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
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
|
40 |
virtual void DoRun (void); |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
virtual void DoSetup (void); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
bool m_test1; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
bool m_test2; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
bool m_test3; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
bool m_test4; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
static bool gBasicCallbackTest5; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
static bool gBasicCallbackTest6; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
static bool gBasicCallbackTest7; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
BasicCallbackTarget5 (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
gBasicCallbackTest5 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
BasicCallbackTarget6 (int) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
gBasicCallbackTest6 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
int |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
BasicCallbackTarget7 (int a) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
gBasicCallbackTest7 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
return a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
BasicCallbackTestCase::BasicCallbackTestCase () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
: TestCase ("Check basic Callback mechansim") |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
BasicCallbackTestCase::DoSetup (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
m_test1 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
m_test2 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
m_test3 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
m_test4 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
gBasicCallbackTest5 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
gBasicCallbackTest6 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
gBasicCallbackTest7 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
89 |
void |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
BasicCallbackTestCase::DoRun (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
// Make sure we can declare and compile a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
// function returning void and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
Callback<void> target1 (this, &BasicCallbackTestCase::Target1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
target1 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
// Make sure we can declare and compile a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
// function that returns an int and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
Callback<int> target2; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
target2 = Callback<int> (this, &BasicCallbackTestCase::Target2); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
target2 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
// Make sure we can declare and compile a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
// function that returns void, takes a double parameter, and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
Callback<void, double> target3 = Callback<void, double> (this, &BasicCallbackTestCase::Target3); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
target3 (0.0); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
// Make sure we can declare and compile a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
// function that returns void, takes two parameters, and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
Callback<int, double, int> target4 = Callback<int, double, int> (this, &BasicCallbackTestCase::Target4); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
target4 (0.0, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
// Make sure we can declare and compile a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
// function that returns void, and execute it. This is a lower level call |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
// than MakeCallback so we have got to include at least two arguments to make |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
// sure that the constructor is properly disambiguated. If the arguments are |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
// not needed, we just pass in dummy values. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
Callback<void> target5 = Callback<void> (&BasicCallbackTarget5, true, true); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
target5 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest5, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
// Make sure we can declare and compile a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
// function that returns void, takes one integer argument and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
// We also need to provide two dummy arguments to the constructor here. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
Callback<void, int> target6 = Callback<void, int> (&BasicCallbackTarget6, true, true); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
target6 (1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest6, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
// Make sure we can declare and compile a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
// function that returns int, takes one integer argument and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
// We also need to provide two dummy arguments to the constructor here. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
Callback<int, int> target7 = Callback<int, int> (&BasicCallbackTarget7, true, true); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
target7 (1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest7, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
153 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
// Test the MakeCallback mechanism |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
class MakeCallbackTestCase : public TestCase |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
MakeCallbackTestCase (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
virtual ~MakeCallbackTestCase () {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
164 |
void Target1 (void) {m_test1 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
165 |
int Target2 (void) {m_test2 = true; return 2;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
166 |
void Target3 (double a) {m_test3 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
167 |
int Target4 (double a, int b) {m_test4 = true; return 4;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
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
|
170 |
virtual void DoRun (void); |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
virtual void DoSetup (void); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
bool m_test1; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
bool m_test2; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
bool m_test3; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
bool m_test4; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
177 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
178 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
static bool gMakeCallbackTest5; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
static bool gMakeCallbackTest6; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
static bool gMakeCallbackTest7; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
183 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
MakeCallbackTarget5 (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
185 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
186 |
gMakeCallbackTest5 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
187 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
190 |
MakeCallbackTarget6 (int) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
191 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
gMakeCallbackTest6 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
int |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
196 |
MakeCallbackTarget7 (int a) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
197 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
gMakeCallbackTest7 = true; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
199 |
return a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
200 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
201 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
MakeCallbackTestCase::MakeCallbackTestCase () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
203 |
: TestCase ("Check MakeCallback() mechanism") |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
204 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
205 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
206 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
207 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
MakeCallbackTestCase::DoSetup (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
210 |
m_test1 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
211 |
m_test2 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
m_test3 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
213 |
m_test4 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
gMakeCallbackTest5 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
215 |
gMakeCallbackTest6 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
216 |
gMakeCallbackTest7 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
218 |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
219 |
void |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
MakeCallbackTestCase::DoRun (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
222 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
223 |
// Make sure we can declare and make a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
224 |
// function returning void and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
226 |
Callback<void> target1 = MakeCallback (&MakeCallbackTestCase::Target1, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
227 |
target1 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
229 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
// Make sure we can declare and make a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
232 |
// function that returns an int and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
234 |
Callback<int> target2 = MakeCallback (&MakeCallbackTestCase::Target2, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
235 |
target2 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
236 |
NS_TEST_ASSERT_MSG_EQ (m_test2, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
237 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
238 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
239 |
// Make sure we can declare and make a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
240 |
// function that returns void, takes a double parameter, and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
241 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
242 |
Callback<void, double> target3 = MakeCallback (&MakeCallbackTestCase::Target3, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
243 |
target3 (0.0); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
244 |
NS_TEST_ASSERT_MSG_EQ (m_test3, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
245 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
246 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
247 |
// Make sure we can declare and make a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
248 |
// function that returns void, takes two parameters, and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
249 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
250 |
Callback<int, double, int> target4 = MakeCallback (&MakeCallbackTestCase::Target4, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
251 |
target4 (0.0, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
252 |
NS_TEST_ASSERT_MSG_EQ (m_test4, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
253 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
254 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
255 |
// Make sure we can declare and make a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
256 |
// function that returns void, and execute it. This uses a higher level call |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
257 |
// than in the basic tests so we do not need to include any dummy arguments |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
258 |
// here. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
259 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
260 |
Callback<void> target5 = MakeCallback (&MakeCallbackTarget5); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
261 |
target5 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
262 |
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest5, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
263 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
264 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
265 |
// Make sure we can declare and compile a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
266 |
// function that returns void, takes one integer argument and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
267 |
// This uses a higher level call than in the basic tests so we do not need to |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
268 |
// include any dummy arguments here. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
269 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
270 |
Callback<void, int> target6 = MakeCallback (&MakeCallbackTarget6); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
271 |
target6 (1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
272 |
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest6, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
273 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
274 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
275 |
// Make sure we can declare and compile a Callback pointing to a non-member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
276 |
// function that returns int, takes one integer argument and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
277 |
// This uses a higher level call than in the basic tests so we do not need to |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
278 |
// include any dummy arguments here. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
279 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
280 |
Callback<int, int> target7 = MakeCallback (&MakeCallbackTarget7); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
281 |
target7 (1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
282 |
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest7, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
283 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
284 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
285 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
286 |
// Test the MakeBoundCallback mechanism |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
287 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
288 |
class MakeBoundCallbackTestCase : public TestCase |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
289 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
290 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
291 |
MakeBoundCallbackTestCase (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
292 |
virtual ~MakeBoundCallbackTestCase () {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
293 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
294 |
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
|
295 |
virtual void DoRun (void); |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
296 |
virtual void DoSetup (void); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
297 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
298 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
299 |
static int gMakeBoundCallbackTest1; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
300 |
static bool *gMakeBoundCallbackTest2; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
301 |
static bool *gMakeBoundCallbackTest3a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
302 |
static int gMakeBoundCallbackTest3b; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
303 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
304 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
305 |
MakeBoundCallbackTarget1 (int a) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
306 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
307 |
gMakeBoundCallbackTest1 = a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
308 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
309 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
310 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
311 |
MakeBoundCallbackTarget2 (bool *a) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
312 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
313 |
gMakeBoundCallbackTest2 = a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
314 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
315 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
316 |
int |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
317 |
MakeBoundCallbackTarget3 (bool *a, int b) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
318 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
319 |
gMakeBoundCallbackTest3a = a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
320 |
gMakeBoundCallbackTest3b = b; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
321 |
return 1234; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
322 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
323 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
324 |
MakeBoundCallbackTestCase::MakeBoundCallbackTestCase () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
325 |
: TestCase ("Check MakeBoundCallback() mechanism") |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
326 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
327 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
328 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
329 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
330 |
MakeBoundCallbackTestCase::DoSetup (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
331 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
332 |
gMakeBoundCallbackTest1 = 0; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
333 |
gMakeBoundCallbackTest2 = 0; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
334 |
gMakeBoundCallbackTest3a = 0; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
335 |
gMakeBoundCallbackTest3b = 0; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
336 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
337 |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
338 |
void |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
339 |
MakeBoundCallbackTestCase::DoRun (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
340 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
341 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
342 |
// This is slightly tricky to explain. A bound Callback allows us to package |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
343 |
// up arguments for use later. The arguments are bound when the callback is |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
344 |
// created and the code that fires the Callback does not know they are there. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
345 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
346 |
// Since the callback is *declared* according to the way it will be used, the |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
347 |
// arguments are not seen there. However, the target function of the callback |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
348 |
// will have the provided arguments present. The MakeBoundCallback template |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
349 |
// function is what connects the two together and where you provide the |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
350 |
// arguments to be bound. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
351 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
352 |
// Here we declare a Callback that returns a void and takes no parameters. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
353 |
// MakeBoundCallback connects this Callback to a target function that returns |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
354 |
// void and takes an integer argument. That integer argument is bound to the |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
355 |
// value 1234. When the Callback is fired, no integer argument is provided |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
356 |
// directly. The argument is provided by bound Callback mechanism. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
357 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
358 |
Callback<void> target1 = MakeBoundCallback (&MakeBoundCallbackTarget1, 1234); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
359 |
target1 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
360 |
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest1, 1234, "Callback did not fire or binding not correct"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
361 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
362 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
363 |
// Make sure we can bind a pointer value (a common use case). |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
364 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
365 |
bool a; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
366 |
Callback<void> target2 = MakeBoundCallback (&MakeBoundCallbackTarget2, &a); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
367 |
target2 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
368 |
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest2, &a, "Callback did not fire or binding not correct"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
369 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
370 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
371 |
// Make sure we can mix and match bound and unbound arguments. This callback |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
372 |
// returns an integer so we should see that appear. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
373 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
374 |
Callback<int, int> target3 = MakeBoundCallback (&MakeBoundCallbackTarget3, &a); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
375 |
int result = target3 (2468); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
376 |
NS_TEST_ASSERT_MSG_EQ (result, 1234, "Return value of callback not correct"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
377 |
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3a, &a, "Callback did not fire or binding not correct"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
378 |
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3b, 2468, "Callback did not fire or argument not correct"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
379 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
380 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
381 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
382 |
// Test the Nullify mechanism |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
383 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
384 |
class NullifyCallbackTestCase : public TestCase |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
385 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
386 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
387 |
NullifyCallbackTestCase (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
388 |
virtual ~NullifyCallbackTestCase () {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
389 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
390 |
void Target1 (void) {m_test1 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
391 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
392 |
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
|
393 |
virtual void DoRun (void); |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
394 |
virtual void DoSetup (void); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
395 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
396 |
bool m_test1; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
397 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
398 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
399 |
NullifyCallbackTestCase::NullifyCallbackTestCase () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
400 |
: TestCase ("Check Nullify() and IsNull()") |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
401 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
402 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
403 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
404 |
void |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
405 |
NullifyCallbackTestCase::DoSetup (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
406 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
407 |
m_test1 = false; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
408 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
409 |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
410 |
void |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
411 |
NullifyCallbackTestCase::DoRun (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
412 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
413 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
414 |
// Make sure we can declare and make a Callback pointing to a member |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
415 |
// function returning void and execute it. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
416 |
// |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
417 |
Callback<void> target1 = MakeCallback (&NullifyCallbackTestCase::Target1, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
418 |
target1 (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
419 |
NS_TEST_ASSERT_MSG_EQ (m_test1, true, "Callback did not fire"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
420 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
421 |
NS_TEST_ASSERT_MSG_EQ (target1.IsNull (), false, "Working Callback reports IsNull()"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
422 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
423 |
target1.Nullify (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
424 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
425 |
NS_TEST_ASSERT_MSG_EQ (target1.IsNull (), true, "Nullified Callback reports not IsNull()"); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
426 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
427 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
428 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
429 |
// Make sure that various MakeCallback template functions compile and execute. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
430 |
// Doesn't check an results of the execution. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
431 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
432 |
class MakeCallbackTemplatesTestCase : public TestCase |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
433 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
434 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
435 |
MakeCallbackTemplatesTestCase (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
436 |
virtual ~MakeCallbackTemplatesTestCase () {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
437 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
438 |
void Target1 (void) {m_test1 = true;} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
439 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
440 |
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
|
441 |
virtual void DoRun (void); |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
442 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
443 |
bool m_test1; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
444 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
445 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
446 |
void TestFZero (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
447 |
void TestFOne (int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
448 |
void TestFTwo (int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
449 |
void TestFThree (int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
450 |
void TestFFour (int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
451 |
void TestFFive (int, int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
452 |
void TestFSix (int, int, int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
453 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
454 |
void TestFROne (int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
455 |
void TestFRTwo (int &, int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
456 |
void TestFRThree (int &, int &, int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
457 |
void TestFRFour (int &, int &, int &, int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
458 |
void TestFRFive (int &, int &, int &, int &, int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
459 |
void TestFRSix (int &, int &, int &, int &, int &, int &) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
460 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
461 |
class CallbackTestParent |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
462 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
463 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
464 |
void PublicParent (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
465 |
protected: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
466 |
void ProtectedParent (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
467 |
static void StaticProtectedParent (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
468 |
private: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
469 |
void PrivateParent (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
470 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
471 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
472 |
class CallbackTestClass : public CallbackTestParent |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
473 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
474 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
475 |
void TestZero (void) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
476 |
void TestOne (int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
477 |
void TestTwo (int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
478 |
void TestThree (int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
479 |
void TestFour (int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
480 |
void TestFive (int, int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
481 |
void TestSix (int, int, int, int, int, int) {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
482 |
void TestCZero (void) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
483 |
void TestCOne (int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
484 |
void TestCTwo (int, int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
485 |
void TestCThree (int, int, int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
486 |
void TestCFour (int, int, int, int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
487 |
void TestCFive (int, int, int, int, int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
488 |
void TestCSix (int, int, int, int, int, int) const {} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
489 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
490 |
void CheckParentalRights (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
491 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
492 |
MakeCallback (&CallbackTestParent::StaticProtectedParent); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
493 |
MakeCallback (&CallbackTestParent::PublicParent, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
494 |
MakeCallback (&CallbackTestClass::ProtectedParent, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
495 |
// as expected, fails. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
496 |
// MakeCallback (&CallbackTestParent::PrivateParent, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
497 |
// unexpected, but fails too. It does fumble me. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
498 |
// MakeCallback (&CallbackTestParent::ProtectedParent, this); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
499 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
500 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
501 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
502 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
503 |
MakeCallbackTemplatesTestCase::MakeCallbackTemplatesTestCase () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
504 |
: TestCase ("Check various MakeCallback() template functions") |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
505 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
506 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
507 |
|
6775
0783f42a364b
Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
6774
diff
changeset
|
508 |
void |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
509 |
MakeCallbackTemplatesTestCase::DoRun (void) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
510 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
511 |
CallbackTestClass that; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
512 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
513 |
MakeCallback (&CallbackTestClass::TestZero, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
514 |
MakeCallback (&CallbackTestClass::TestOne, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
515 |
MakeCallback (&CallbackTestClass::TestTwo, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
516 |
MakeCallback (&CallbackTestClass::TestThree, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
517 |
MakeCallback (&CallbackTestClass::TestFour, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
518 |
MakeCallback (&CallbackTestClass::TestFive, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
519 |
MakeCallback (&CallbackTestClass::TestSix, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
520 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
521 |
MakeCallback (&CallbackTestClass::TestCZero, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
522 |
MakeCallback (&CallbackTestClass::TestCOne, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
523 |
MakeCallback (&CallbackTestClass::TestCTwo, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
524 |
MakeCallback (&CallbackTestClass::TestCThree, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
525 |
MakeCallback (&CallbackTestClass::TestCFour, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
526 |
MakeCallback (&CallbackTestClass::TestCFive, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
527 |
MakeCallback (&CallbackTestClass::TestCSix, &that); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
528 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
529 |
MakeCallback (&TestFZero); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
530 |
MakeCallback (&TestFOne); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
531 |
MakeCallback (&TestFTwo); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
532 |
MakeCallback (&TestFThree); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
533 |
MakeCallback (&TestFFour); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
534 |
MakeCallback (&TestFFive); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
535 |
MakeCallback (&TestFSix); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
536 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
537 |
MakeCallback (&TestFROne); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
538 |
MakeCallback (&TestFRTwo); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
539 |
MakeCallback (&TestFRThree); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
540 |
MakeCallback (&TestFRFour); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
541 |
MakeCallback (&TestFRFive); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
542 |
MakeCallback (&TestFRSix); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
543 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
544 |
MakeBoundCallback (&TestFOne, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
545 |
MakeBoundCallback (&TestFTwo, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
546 |
MakeBoundCallback (&TestFThree, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
547 |
MakeBoundCallback (&TestFFour, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
548 |
MakeBoundCallback (&TestFFive, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
549 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
550 |
MakeBoundCallback (&TestFROne, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
551 |
MakeBoundCallback (&TestFRTwo, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
552 |
MakeBoundCallback (&TestFRThree, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
553 |
MakeBoundCallback (&TestFRFour, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
554 |
MakeBoundCallback (&TestFRFive, 1); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
555 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
556 |
that.CheckParentalRights (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
557 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
558 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
559 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
560 |
// The Test Suite that glues all of the Test Cases together. |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
561 |
// =========================================================================== |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
562 |
class CallbackTestSuite : public TestSuite |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
563 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
564 |
public: |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
565 |
CallbackTestSuite (); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
566 |
}; |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
567 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
568 |
CallbackTestSuite::CallbackTestSuite () |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
569 |
: TestSuite ("callback", UNIT) |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
570 |
{ |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
571 |
AddTestCase (new BasicCallbackTestCase); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
572 |
AddTestCase (new MakeCallbackTestCase); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
573 |
AddTestCase (new MakeBoundCallbackTestCase); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
574 |
AddTestCase (new NullifyCallbackTestCase); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
575 |
AddTestCase (new MakeCallbackTemplatesTestCase); |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
576 |
} |
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
577 |
|
6774
034f362af24d
Make all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents:
5342
diff
changeset
|
578 |
static CallbackTestSuite CallbackTestSuite; |
5255
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
579 |
|
2f3abe6fa8a3
Remove and replace Callback unit test, add examples to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
580 |
} // namespace |