summaryrefslogtreecommitdiff
path: root/tests/test_exception_catch.cc
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@src.gnome.org>2003-01-15 16:30:15 +0000
committerMurray Cumming <murrayc@src.gnome.org>2003-01-15 16:30:15 +0000
commitb9c14cc56d3db2fefc252c28d63042827351616b (patch)
tree1791f6be3f12913dd0fb28d2e7ffd237686ae3fc /tests/test_exception_catch.cc
parenta6c78f49e2636a4f5b1fa4c5f120bae5467bcc16 (diff)
downloadsigc++-b9c14cc56d3db2fefc252c28d63042827351616b.tar.gz
Added missing files.
Diffstat (limited to 'tests/test_exception_catch.cc')
-rw-r--r--tests/test_exception_catch.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_exception_catch.cc b/tests/test_exception_catch.cc
new file mode 100644
index 0000000..c6e3b37
--- /dev/null
+++ b/tests/test_exception_catch.cc
@@ -0,0 +1,46 @@
+// -*- c++ -*-
+/* Copyright 2002, The libsigc++ Development Team
+ * Assigned to public domain. Use as you wish without restriction.
+ */
+
+#include <sigc++/adaptors/exception_catch.h>
+#include <iostream>
+#include <stdexcept>
+
+using namespace std;
+using namespace sigc::functor;
+
+struct f
+{
+ int operator()(int i)
+ {cout << "f(int "<<i<<")"<<endl;
+ throw std::range_error("out of range");}
+};
+#if 0
+struct g
+{
+ int operator()()
+ {cout << "g()"<<endl;
+ throw std::range_error("out of range");}
+};
+#endif
+
+struct my_catch
+{
+ int operator()()
+ {
+ try { throw; }
+ catch (std::range_error e) // catch what types we know
+ {
+ cerr << "caught "<< e.what() <<endl;
+ }
+ return 1;
+ // all else continues out.
+ }
+};
+
+int main()
+{
+ exception_catch(f(), my_catch())(1);
+// exception_catch(g(), my_catch())();
+}