[libsigcplusplus] tests: Use sigc::signal<R(Args...)> syntax only.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] tests: Use sigc::signal<R(Args...)> syntax only.
- Date: Wed, 16 Mar 2016 11:50:02 +0000 (UTC)
commit 8aa81869435b499d5bec44c541477df61f11dbf2
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 16 11:04:14 2016 +0100
tests: Use sigc::signal<R(Args...)> syntax only.
tests/test_accum_iter.cc | 2 +-
tests/test_accumulated.cc | 31 ++++---------------------------
tests/test_bind_refptr.cc | 4 ++--
tests/test_cpp11_lambda.cc | 10 +++++-----
tests/test_disconnect.cc | 8 ++++----
tests/test_disconnect_during_emit.cc | 2 +-
tests/test_signal.cc | 23 ++++++-----------------
tests/test_signal_move.cc | 6 +++---
tests/test_size.cc | 6 +++---
tests/test_track_obj.cc | 2 +-
10 files changed, 30 insertions(+), 64 deletions(-)
---
diff --git a/tests/test_accum_iter.cc b/tests/test_accum_iter.cc
index 909a466..f339354 100644
--- a/tests/test_accum_iter.cc
+++ b/tests/test_accum_iter.cc
@@ -35,7 +35,7 @@ int main(int argc, char* argv[])
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
- sigc::signal<int>::accumulated<min_accum<int>> signal;
+ sigc::signal<int()>::accumulated<min_accum<int>> signal;
signal.connect(sigc::bind(sigc::ptr_fun(ident), 3));
signal.connect(sigc::bind(sigc::ptr_fun(ident), 1));
diff --git a/tests/test_accumulated.cc b/tests/test_accumulated.cc
index 600793b..0e97f56 100644
--- a/tests/test_accumulated.cc
+++ b/tests/test_accumulated.cc
@@ -73,8 +73,8 @@ struct A : public sigc::trackable
void test_empty_signal()
{
- sigc::signal<int,int>::accumulated<arithmetic_mean_accumulator> sig;
- sigc::signal<int,int>::accumulated<vector_accumulator<int> > sig_vec;
+ sigc::signal<int(int)>::accumulated<arithmetic_mean_accumulator> sig;
+ sigc::signal<int(int)>::accumulated<vector_accumulator<int> > sig_vec;
result_stream << "Result (empty slot list): " << sig(0);
util->check_result(result_stream, "Result (empty slot list): -1");
@@ -85,7 +85,7 @@ void test_empty_signal()
void test_mean()
{
- sigc::signal<int,int>::accumulated<arithmetic_mean_accumulator> sig;
+ sigc::signal<int(int)>::accumulated<arithmetic_mean_accumulator> sig;
A a;
sig.connect(sigc::ptr_fun(&foo));
@@ -107,7 +107,7 @@ void test_mean()
void test_vector_accumulator()
{
- sigc::signal<int,int>::accumulated<vector_accumulator<int> > sig_vec;
+ sigc::signal<int(int)>::accumulated<vector_accumulator<int> > sig_vec;
A a;
sig_vec.connect(sigc::ptr_fun(&foo));
@@ -129,28 +129,6 @@ 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[])
@@ -163,7 +141,6 @@ 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_bind_refptr.cc b/tests/test_bind_refptr.cc
index a8909af..925f2fc 100644
--- a/tests/test_bind_refptr.cc
+++ b/tests/test_bind_refptr.cc
@@ -425,10 +425,10 @@ public:
void emit_sig1(int n) { sig1.emit(n); }
- sigc::signal<void, int>& signal_sig1() { return sig1; }
+ sigc::signal<void(int)>& signal_sig1() { return sig1; }
private:
- sigc::signal<void, int> sig1;
+ sigc::signal<void(int)> sig1;
int ref_count;
};
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index 5532f26..a927884 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -400,7 +400,7 @@ int main(int argc, char* argv[])
//int main(int argc, char* argv[])
//{
// int data;
- // sigc::signal<int> readValue;
+ // sigc::signal<int()> readValue;
//
// readValue.connect(sigc::var(data));
//
@@ -412,7 +412,7 @@ int main(int argc, char* argv[])
//}
{
int data;
- sigc::signal<int> readValue;
+ sigc::signal<int()> readValue;
readValue.connect([&data] () -> int { return data; });
@@ -457,7 +457,7 @@ int main(int argc, char* argv[])
util->check_result(result_stream, "foo_group1(int 18, int 2)");
{
- sigc::signal<void,int,int> some_signal;
+ sigc::signal<void(int, int)> some_signal;
//some_signal.connect(sigc::group(&foo,sigc::_2));
//some_signal.connect(std::bind(&foo_group2, std::placeholders::_2)); // does not compile (gcc 4.6.3)
some_signal.connect([](int, int y) { foo_group2(y); });
@@ -467,7 +467,7 @@ int main(int argc, char* argv[])
{
int some_int = 0;
- sigc::signal<void> some_signal;
+ sigc::signal<void()> some_signal;
//some_signal.connect(sigc::group(&foo,std::ref(some_int)));
//some_signal.connect(std::bind(&foo_group3, std::ref(some_int))); // does not compile (gcc 4.6.3)
//some_signal.connect(sigc::bind(&foo_group3, std::ref(some_int))); // compiles, but we prefer
std::bind() or C++11 lambda
@@ -479,7 +479,7 @@ int main(int argc, char* argv[])
{
//struct bar : public sigc::trackable {} some_bar;
- sigc::signal<void> some_signal;
+ sigc::signal<void()> some_signal;
{
bar_group4 some_bar;
//some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc
index 70cf786..c1ddf3b 100644
--- a/tests/test_disconnect.cc
+++ b/tests/test_disconnect.cc
@@ -70,7 +70,7 @@ struct B : public sigc::trackable
sig.emit();
}
- sigc::signal<void> sig;
+ sigc::signal<void()> sig;
};
} // end anonymous namespace
@@ -82,9 +82,9 @@ int main(int argc, char* argv[])
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
- sigc::signal<int, int> sig;
- sigc::signal<int, int>::iterator confoo;
- sigc::signal<int, int>::iterator conbar;
+ sigc::signal<int(int)> sig;
+ sigc::signal<int(int)>::iterator confoo;
+ sigc::signal<int(int)>::iterator conbar;
sigc::connection cona; // connection objects are safe to use beyond the life time of a signal.
{
diff --git a/tests/test_disconnect_during_emit.cc b/tests/test_disconnect_during_emit.cc
index 0723242..b610936 100644
--- a/tests/test_disconnect_during_emit.cc
+++ b/tests/test_disconnect_during_emit.cc
@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
HandlerClass instance;
- sigc::signal<void> signal_test;
+ sigc::signal<void()> signal_test;
connection = signal_test.connect(sigc::mem_fun(instance, &HandlerClass::handler));
result_stream << "Number of signal handlers before signal emission: " << signal_test.size();
util->check_result(result_stream, "Number of signal handlers before signal emission: 1");
diff --git a/tests/test_signal.cc b/tests/test_signal.cc
index 3cd51a5..e95bd6e 100644
--- a/tests/test_signal.cc
+++ b/tests/test_signal.cc
@@ -41,7 +41,7 @@ struct A : public sigc::trackable
void test_empty_signal()
{
// signal
- sigc::signal<int,int> sig;
+ sigc::signal<int(int)> sig;
// emit empty signal
sig(0);
@@ -50,7 +50,7 @@ void test_empty_signal()
void test_simple()
{
- sigc::signal<int, int> sig;
+ sigc::signal<int(int)> sig;
sig.connect(sigc::ptr_fun(&foo));
sig(1);
@@ -66,7 +66,7 @@ int bar(float i)
void test_auto_disconnection()
{
// signal
- sigc::signal<int,int> sig;
+ sigc::signal<int(int)> sig;
// connect some slots before emitting & test auto-disconnection
{
@@ -90,7 +90,7 @@ void test_reference()
// test reference
A a;
std::string str("guest book");
- sigc::signal<void,std::string&> sigstr;
+ sigc::signal<void(std::string&)> sigstr;
sigstr.connect(sigc::mem_fun(a, &A::bar));
sigstr(str);
result_stream << str;
@@ -100,26 +100,16 @@ void test_reference()
void test_make_slot()
{
// test make_slot()
- sigc::signal<int,int> sig;
+ sigc::signal<int(int)> sig;
sig.connect(sigc::ptr_fun(&foo));
sig.connect(sigc::ptr_fun(&bar));
sig.connect(sigc::ptr_fun(&foo));
- sigc::signal<int,int> sig2;
+ sigc::signal<int(int)> sig2;
sig2.connect(sig.make_slot());
sig2(3);
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[])
@@ -134,7 +124,6 @@ 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;
}
diff --git a/tests/test_signal_move.cc b/tests/test_signal_move.cc
index 6365e5b..cd9e69f 100644
--- a/tests/test_signal_move.cc
+++ b/tests/test_signal_move.cc
@@ -30,19 +30,19 @@ int main(int argc, char* argv[])
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
// signal
- sigc::signal<int, int> sig;
+ sigc::signal<int(int)> sig;
sig.connect(sigc::ptr_fun(&foo));
sig(1);
util->check_result(result_stream, "foo(int 1)");
//Test the move constructor:
- sigc::signal<int, int> sig2(std::move(sig));
+ sigc::signal<int(int)> sig2(std::move(sig));
sig(-2);
sig2(2);
util->check_result(result_stream, "foo(int 2)");
//Test the move assignment operator:
- sigc::signal<int, int> sig3;
+ sigc::signal<int(int)> sig3;
sig3 = std::move(sig2);
sig2(-3);
sig3(3);
diff --git a/tests/test_size.cc b/tests/test_size.cc
index d564a63..5931f9f 100644
--- a/tests/test_size.cc
+++ b/tests/test_size.cc
@@ -34,8 +34,8 @@ int main(int argc, char* argv[])
std::cout << " trackable: " << sizeof(sigc::trackable) << std::endl;
std::cout << " slot<void>: " << sizeof(sigc::slot<void>) << std::endl;
- std::cout << " signal<void>: " << sizeof(sigc::signal<void>) << std::endl;
- std::cout << " signal<void>::iterator: " << sizeof(sigc::signal<void>::iterator) << std::endl;
+ std::cout << " signal<void()>: " << sizeof(sigc::signal<void()>) << std::endl;
+ std::cout << " signal<void()>::iterator: " << sizeof(sigc::signal<void()>::iterator) << std::endl;
std::cout << " connection: " << sizeof(sigc::connection) << std::endl;
std::cout << std::endl << "sizes of internal classes:" << std::endl;
@@ -48,4 +48,4 @@ int main(int argc, char* argv[])
std::cout << " signal_impl: " << sizeof(sigc::internal::signal_impl) << std::endl;
}
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-}
\ No newline at end of file
+}
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index b56c5e2..a2a0019 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -199,7 +199,7 @@ int main(int argc, char* argv[])
// -----------------------------------------------------------------------
{
//struct bar : public sigc::trackable {} some_bar;
- sigc::signal<void> some_signal;
+ sigc::signal<void()> some_signal;
{
bar_group4 some_bar;
//some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]