summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/Makefile4
-rw-r--r--src/tests/testSignals.cc24
2 files changed, 25 insertions, 3 deletions
diff --git a/src/tests/Makefile b/src/tests/Makefile
index 668126e..dd329e6 100644
--- a/src/tests/Makefile
+++ b/src/tests/Makefile
@@ -1,5 +1,5 @@
1CXX=g++ 1CXX=g++
2CXXFLAGS= -I.. -I../FbTk -I../.. -DDEBUG -DUSE_XFT -Wall -g -O2 ../FbTk/libFbTk.a 2CXXFLAGS= -I.. -I../FbTk -I../.. -DDEBUG -DUSE_XFT -Wall -g -O2 -fno-inline
3LIBS= 3LIBS=
4XFLAGS= -I/usr/X11R6/include 4XFLAGS= -I/usr/X11R6/include
5XLIBS= -L/usr/X11R6/lib -lX11 -lXft -lXpm -lImlib2 5XLIBS= -L/usr/X11R6/lib -lX11 -lXft -lXpm -lImlib2
@@ -17,7 +17,7 @@ glxtest: ../FbTk/App.hh glxtest.cc
17 ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest 17 ${CXX} glxtest.cc ${CXXFLAGS} ${XLIBS} -lGL -lGLU -lXpm -o glxtest
18 18
19testSignals: testSignals.o ../FbTk/Signal.hh ../FbTk/MemFun.hh 19testSignals: testSignals.o ../FbTk/Signal.hh ../FbTk/MemFun.hh
20 $(CXX) $(LIBS) testSignals.o -o testSignals 20 $(CXX) $(LIBS) testSignals.o -o testSignals ../FbTk/libFbTk.a
21 21
22testStringUtil: StringUtiltest.o 22testStringUtil: StringUtiltest.o
23 $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil 23 $(CXX) $(LIBS) StringUtiltest.o ../FbTk/libFbTk.a -o testStringUtil
diff --git a/src/tests/testSignals.cc b/src/tests/testSignals.cc
index 6d68d3a..f382289 100644
--- a/src/tests/testSignals.cc
+++ b/src/tests/testSignals.cc
@@ -3,6 +3,9 @@ using namespace std;
3 3
4#include "../FbTk/Signal.hh" 4#include "../FbTk/Signal.hh"
5#include "../FbTk/MemFun.hh" 5#include "../FbTk/MemFun.hh"
6#include "../FbTk/RelaySignal.hh"
7#include "../FbTk/Observer.hh"
8#include "../FbTk/Subject.hh"
6 9
7#include <string> 10#include <string>
8 11
@@ -138,5 +141,24 @@ int main() {
138 2.9); 141 2.9);
139 142
140 } 143 }
141 144 // Test relay new signals to old
145 {
146 cout << "---------- Testing relay of signals" << endl;
147 struct Observer: public FbTk::Observer {
148 void update(FbTk::Subject* subj) {
149 cout << "Observer called." << endl;
150 }
151 };
152 // setup old subject->observer listening
153 FbTk::Subject destination;
154 Observer obs;
155 destination.attach(&obs);
156 // create a new signal and relay it to the
157 // old subject
158 FbTk::Signal<void, string> source;
159 FbTk::relaySignal(source, destination);
160 // the new signal should now make the old
161 // subject notify its observers
162 source.emit("hello world");
163 }
142} 164}