]> git.llucax.com Git - software/eventxx.git/commitdiff
Add new tests.
authorLeandro Lucarella <llucarella@integratech.com.ar>
Tue, 2 Jan 2007 15:07:31 +0000 (15:07 +0000)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Tue, 2 Jan 2007 15:07:31 +0000 (15:07 +0000)
test/Makefile
test/c-way.cpp [new file with mode: 0644]
test/functor-way.cpp [new file with mode: 0644]
test/trivial.cpp [new file with mode: 0644]

index 63018a6fc88e0169880e9d699784acf952d089ec..f582ca4a942c7a7fd9165a50353f396cf9d28ca5 100644 (file)
@@ -1,11 +1,11 @@
 
-CXXFLAGS=-I.. -g
+CXXFLAGS=-I.. -g -Wall
 # Uncomment this if you have a fixed event_base_free().
 # See http://www.mail-archive.com/libevent-users@monkey.org/msg00112.html
-#CXXFLAGS+=-DEVENT_BASE_FREE_FIX
+CXXFLAGS+=-DEVENT_BASE_FREE_FIX
 LDFLAGS=-levent
 
-targets=bench test-eof test-time test-weof
+targets=bench test-eof test-time test-weof trivial c-way
 
 all: $(targets)
 
diff --git a/test/c-way.cpp b/test/c-way.cpp
new file mode 100644 (file)
index 0000000..889317d
--- /dev/null
@@ -0,0 +1,27 @@
+#include <eventxx>
+#include <iostream>
+#include <csignal>
+
+eventxx::dispatcher d;
+
+void sighandler(int signum, short event, void* data)
+{
+       unsigned &i = *(unsigned*)data;
+       std::cout << ++i << " interrupts, ";
+       if (i < 5) std::cout << "keep going...\n";
+       else
+       {
+               std::cout << "done!\n";
+               d.exit();
+       }
+}
+
+int main()
+{
+       int var = 0;
+       eventxx::csignal sigev(SIGINT, sighandler, &var);
+       d.add(sigev);
+       d.dispatch();
+       return 0;
+}
+
diff --git a/test/functor-way.cpp b/test/functor-way.cpp
new file mode 100644 (file)
index 0000000..b9f3b77
--- /dev/null
@@ -0,0 +1,33 @@
+#include <eventxx>
+#include <iostream>
+#include <csignal>
+
+using eventxx::dispatcher;
+
+struct handler
+{
+       dispatcher& d;
+       int i;
+       handler(dispatcher& d): d(d), i(0) {}
+       void operator() (int signum, short event)
+       {
+               std::cout << ++i << " interrupts, ";
+               if (i < 5) std::cout << "keep going...\n";
+               else
+               {
+                       std::cout << "done!\n";
+                       d.exit();
+               }
+       }
+};
+
+int main()
+{
+       dispatcher d;
+       handler h(d);
+       eventxx::signal< handler > e(SIGINT, h);
+       d.add(e);
+       d.dispatch();
+       return 0;
+}
+
diff --git a/test/trivial.cpp b/test/trivial.cpp
new file mode 100644 (file)
index 0000000..779806c
--- /dev/null
@@ -0,0 +1,9 @@
+#include <eventxx>
+
+int main()
+{
+       eventxx::dispatcher d;
+       d.dispatch();
+       return 0;
+}
+