summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-03-11 11:00:05 +0100
committerMurray Cumming <murrayc@murrayc.com>2016-03-11 11:12:30 +0100
commite399c4ebdb633d242e7086ceb2a548057cd5889b (patch)
treebd25d080bc8a8a1feb4b65cfc82f093ff9c3fcc2 /tests
parent911398e6f70693833f515c44aec9899a092d9250 (diff)
downloadsigc++-e399c4ebdb633d242e7086ceb2a548057cd5889b.tar.gz
signal: Allow sigc::signal<R(Args...)> declaration, like std::function.
By adding a template specialization that repeats the main template declaration, though it would be good to avoid the repetition. Bug #763393 Please enter the commit message for your changes. Lines starting
Diffstat (limited to 'tests')
-rw-r--r--tests/test_accumulated.cc23
-rw-r--r--tests/test_signal.cc11
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_accumulated.cc b/tests/test_accumulated.cc
index 9311131..600793b 100644
--- a/tests/test_accumulated.cc
+++ b/tests/test_accumulated.cc
@@ -129,6 +129,28 @@ void test_vector_accumulator()
"foo: 10, A::foo: 46, bar: 12, Vector accumulator: Result (i=3): 10 46 12 ");
}
+void test_mean_std_function_style_syntax()
+{
+ sigc::signal<int(int)>::accumulated<arithmetic_mean_accumulator> sig;
+
+ A a;
+ sig.connect(sigc::ptr_fun(&foo));
+ sig.connect(sigc::mem_fun(a, &A::foo));
+ sig.connect(sigc::ptr_fun(&bar));
+
+ double dres = sig(1);
+ result_stream << "Mean accumulator: Result (i=1): "
+ << std::fixed << std::setprecision(3) << dres;
+ util->check_result(result_stream,
+ "foo: 4, A::foo: 6, bar: 2, Mean accumulator: Result (i=1): 4.000");
+
+ dres = sig(11);
+ result_stream << "Mean accumulator: Plain Result (i=11): "
+ << std::fixed << std::setprecision(3) << dres;
+ util->check_result(result_stream,
+ "foo: 34, A::foo: 206, bar: 52, Mean accumulator: Plain Result (i=11): 97.333");
+}
+
} // end anonymous namespace
int main(int argc, char* argv[])
@@ -141,6 +163,7 @@ int main(int argc, char* argv[])
test_empty_signal();
test_mean();
test_vector_accumulator();
+ test_mean_std_function_style_syntax();
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/test_signal.cc b/tests/test_signal.cc
index 7172b29..3cd51a5 100644
--- a/tests/test_signal.cc
+++ b/tests/test_signal.cc
@@ -110,6 +110,16 @@ void test_make_slot()
util->check_result(result_stream, "foo(int 3) bar(float 3) foo(int 3) ");
}
+void test_std_function_style_syntax()
+{
+ sigc::signal<int(int)> sig;
+ sig.connect(sigc::ptr_fun(&foo));
+
+ sig(1);
+ util->check_result(result_stream, "foo(int 1) ");
+}
+
+
} // end anonymous namespace
int main(int argc, char* argv[])
@@ -124,6 +134,7 @@ int main(int argc, char* argv[])
test_auto_disconnection();
test_reference();
test_make_slot();
+ test_std_function_style_syntax();
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
}