[libsigcplusplus] Add .clang-format file and reformat tests and examples.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus] Add .clang-format file and reformat tests and examples.
- Date: Wed, 30 Mar 2016 14:09:23 +0000 (UTC)
commit 9656bc2c0ead7e2155d5df701ca5ce34f2b00f49
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 30 16:04:17 2016 +0200
Add .clang-format file and reformat tests and examples.
.clang-format | 14 ++
examples/hello_world.cc | 12 +-
examples/member_method.cc | 18 ++--
tests/test_accum_iter.cc | 10 +-
tests/test_accumulated.cc | 53 ++++----
tests/test_bind.cc | 38 +++---
tests/test_bind_as_slot.cc | 25 ++--
tests/test_bind_ref.cc | 25 ++--
tests/test_bind_refptr.cc | 173 ++++++++++++------------
tests/test_bind_return.cc | 12 +-
tests/test_compose.cc | 27 ++--
tests/test_copy_invalid_slot.cc | 6 +-
tests/test_cpp11_lambda.cc | 253 ++++++++++++++++++----------------
tests/test_custom.cc | 3 +-
tests/test_disconnect.cc | 63 +++++----
tests/test_disconnect_during_emit.cc | 3 +-
tests/test_exception_catch.cc | 3 +-
tests/test_functor_trait.cc | 64 ++++-----
tests/test_hide.cc | 13 +-
tests/test_limit_reference.cc | 24 +--
tests/test_mem_fun.cc | 43 +++----
tests/test_member_method_trait.cc | 71 +++++-----
tests/test_ptr_fun.cc | 59 ++++----
tests/test_retype.cc | 27 +++--
tests/test_retype_return.cc | 3 +-
tests/test_signal.cc | 24 ++-
tests/test_signal_move.cc | 10 +-
tests/test_size.cc | 15 ++-
tests/test_slot.cc | 34 +++---
tests/test_slot_disconnect.cc | 11 +-
tests/test_slot_move.cc | 19 +--
tests/test_track_obj.cc | 58 ++++----
tests/test_trackable.cc | 10 +-
tests/test_trackable_move.cc | 24 +---
tests/test_tuple_cdr.cc | 45 +++---
tests/test_tuple_end.cc | 56 ++++----
tests/test_tuple_for_each.cc | 118 +++++++++-------
tests/test_tuple_start.cc | 50 ++++----
tests/test_tuple_transform_each.cc | 165 +++++++++-------------
tests/test_visit_each.cc | 38 ++----
tests/testutilities.cc | 20 ++--
41 files changed, 885 insertions(+), 854 deletions(-)
---
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..b1a077a
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,14 @@
+BasedOnStyle: Mozilla
+Standard: Cpp11
+AlignAfterOpenBracket: false
+AlignEscapedNewlinesLeft: true
+AlwaysBreakAfterDefinitionReturnType: None
+BreakBeforeBraces: Allman
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit: 100
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 0
+IndentCaseLabels: false
+SortIncludes: false
+AlignTrailingComments: false
+
diff --git a/examples/hello_world.cc b/examples/hello_world.cc
index efe85e0..08bb48f 100644
--- a/examples/hello_world.cc
+++ b/examples/hello_world.cc
@@ -9,17 +9,19 @@
#include <sigc++/sigc++.h>
-void on_print(const std::string& str)
+void
+on_print(const std::string& str)
{
std::cout << str;
}
-int main()
+int
+main()
{
sigc::signal<void(const std::string&)> signal_print;
-
- signal_print.connect( sigc::ptr_fun(&on_print) );
-
+
+ signal_print.connect(sigc::ptr_fun(&on_print));
+
signal_print.emit("hello world\n");
return 0;
diff --git a/examples/member_method.cc b/examples/member_method.cc
index 311f0ef..87cb97c 100644
--- a/examples/member_method.cc
+++ b/examples/member_method.cc
@@ -15,32 +15,32 @@ public:
Something();
protected:
-
virtual void on_print(int a);
-
+
using type_signal_print = sigc::signal<void(int)>;
type_signal_print signal_print;
-
};
Something::Something()
{
- auto iter = signal_print.connect( sigc::mem_fun(*this, &Something::on_print) );
+ auto iter = signal_print.connect(sigc::mem_fun(*this, &Something::on_print));
signal_print.emit(2);
- //This isn't necessary - it's just to demonstrate how to disconnect:
+ // This isn't necessary - it's just to demonstrate how to disconnect:
iter->disconnect();
- signal_print.emit(3); //Prove that it is no longer connected.
+ signal_print.emit(3); // Prove that it is no longer connected.
}
-void Something::on_print(int a)
+void
+Something::on_print(int a)
{
std::cout << "on_print recieved: " << a << std::endl;
}
-int main()
+int
+main()
{
- Something something;
+ Something something;
return 0;
}
diff --git a/tests/test_accum_iter.cc b/tests/test_accum_iter.cc
index f339354..43cf2d7 100644
--- a/tests/test_accum_iter.cc
+++ b/tests/test_accum_iter.cc
@@ -9,17 +9,18 @@ namespace
{
std::ostringstream result_stream;
-int ident(int i)
+int
+ident(int i)
{
return i;
}
-template<typename T>
+template <typename T>
struct min_accum
{
using result_type = T;
- template<class I>
+ template <class I>
typename std::iterator_traits<I>::value_type operator()(I i1, I i2)
{
return *std::min_element(i1, i2);
@@ -28,7 +29,8 @@ struct min_accum
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_accumulated.cc b/tests/test_accumulated.cc
index 0e97f56..4e60136 100644
--- a/tests/test_accumulated.cc
+++ b/tests/test_accumulated.cc
@@ -22,7 +22,7 @@ std::ostringstream result_stream;
struct arithmetic_mean_accumulator
{
using result_type = double;
- template<typename T_iterator>
+ template <typename T_iterator>
double operator()(T_iterator first, T_iterator last) const
{
double value_ = 0;
@@ -33,11 +33,11 @@ struct arithmetic_mean_accumulator
}
};
-template<class Ret>
+template <class Ret>
struct vector_accumulator
{
using result_type = std::vector<Ret>;
- template<typename T_iterator>
+ template <typename T_iterator>
result_type operator()(T_iterator first, T_iterator last) const
{
result_type vec;
@@ -47,14 +47,16 @@ struct vector_accumulator
}
};
-int foo(int i)
+int
+foo(int i)
{
const int result = 3 * i + 1;
result_stream << "foo: " << result << ", ";
return result;
}
-int bar(double i)
+int
+bar(double i)
{
const int result = 5 * int(i) - 3;
result_stream << "bar: " << result << ", ";
@@ -71,10 +73,11 @@ struct A : public sigc::trackable
}
};
-void test_empty_signal()
+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<vector_accumulator<int>> sig_vec;
result_stream << "Result (empty slot list): " << sig(0);
util->check_result(result_stream, "Result (empty slot list): -1");
@@ -83,7 +86,8 @@ void test_empty_signal()
util->check_result(result_stream, "Vector result (empty slot list): empty");
}
-void test_mean()
+void
+test_mean()
{
sigc::signal<int(int)>::accumulated<arithmetic_mean_accumulator> sig;
@@ -93,45 +97,46 @@ void test_mean()
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");
+ 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");
+ 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");
}
-void test_vector_accumulator()
+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));
sig_vec.connect(sigc::mem_fun(a, &A::foo));
sig_vec.connect(sigc::ptr_fun(&bar));
-
+
auto res1 = sig_vec(1);
result_stream << "Vector accumulator: Result (i=1): ";
for (auto num : res1)
result_stream << num << " ";
- util->check_result(result_stream,
- "foo: 4, A::foo: 6, bar: 2, Vector accumulator: Result (i=1): 4 6 2 ");
+ util->check_result(
+ result_stream, "foo: 4, A::foo: 6, bar: 2, Vector accumulator: Result (i=1): 4 6 2 ");
auto res3 = sig_vec(3);
result_stream << "Vector accumulator: Result (i=3): ";
for (auto num : res3)
result_stream << num << " ";
- util->check_result(result_stream,
- "foo: 10, A::foo: 46, bar: 12, Vector accumulator: Result (i=3): 10 46 12 ");
+ util->check_result(
+ result_stream, "foo: 10, A::foo: 46, bar: 12, Vector accumulator: Result (i=3): 10 46 12 ");
}
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
util = TestUtilities::get_instance();
diff --git a/tests/test_bind.cc b/tests/test_bind.cc
index 94e2f61..fd46fe8 100644
--- a/tests/test_bind.cc
+++ b/tests/test_bind.cc
@@ -28,7 +28,7 @@ struct foo : public sigc::functor_base
int operator()(int i, int j)
{
- result_stream << "foo(int " << i << ", int "<< j << ") ";
+ result_stream << "foo(int " << i << ", int " << j << ") ";
return i + j;
}
@@ -43,45 +43,44 @@ struct foo_void : public sigc::functor_base
{
using result_type = void;
- void operator()(int i)
- {
- result_stream << "foo_void(int " << i << ")";
- }
+ void operator()(int i) { result_stream << "foo_void(int " << i << ")"; }
};
-int bar(int i, int j)
+int
+bar(int i, int j)
{
result_stream << "bar(int " << i << ", int " << j << ") ";
return i + j;
}
-bool simple(bool test)
+bool
+simple(bool test)
{
result_stream << "simple(bool " << test << ") ";
return test;
}
-void egon(std::string& str)
+void
+egon(std::string& str)
{
result_stream << "egon(string '" << str << "')";
str = "egon was here";
}
-
struct book : public sigc::trackable
{
book(const std::string& name) : name_(name) {}
- //non-copyable:
+ // non-copyable:
book(const book&) = delete;
book& operator=(const book&) = delete;
-
- //non movable:
+
+ // non movable:
book(book&&) = delete;
book& operator=(book&&) = delete;
- std::string& get_name() { return name_; }
- operator std::string& () { return get_name(); }
+ std::string& get_name() { return name_; }
+ operator std::string&() { return get_name(); }
private:
std::string name_;
@@ -89,7 +88,8 @@ private:
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -126,7 +126,7 @@ int main(int argc, char* argv[])
util->check_result(result_stream, "foo_void(int 12)");
// function pointer instead of functor
- sigc::bind(&bar, 13, 14)();
+ sigc::bind (&bar, 13, 14)();
util->check_result(result_stream, "bar(int 13, int 14) ");
// method pointer instead of functor
@@ -143,8 +143,10 @@ int main(int argc, char* argv[])
// test references
std::string str("guest book");
- sigc::bind(&egon, std::ref(str))(); // Tell bind that it shall store a reference.
- result_stream << " " << str; // (This cannot be the default behaviour: just think about what happens if
str dies!)
+ sigc::bind (&egon, std::ref(str))(); // Tell bind that it shall store a reference.
+ result_stream
+ << " "
+ << str; // (This cannot be the default behaviour: just think about what happens if str dies!)
util->check_result(result_stream, "egon(string 'guest book') egon was here");
sigc::slot<void()> sl;
diff --git a/tests/test_bind_as_slot.cc b/tests/test_bind_as_slot.cc
index 763e48f..efcd360 100644
--- a/tests/test_bind_as_slot.cc
+++ b/tests/test_bind_as_slot.cc
@@ -16,19 +16,22 @@ namespace
std::ostringstream result_stream;
-bool func_to_bind(int a, int b)
+bool
+func_to_bind(int a, int b)
{
result_stream << "func_to_bind(" << a << ", " << b << ")";
return true;
}
-bool func_to_bind_with_iter(int a, std::string::iterator& b)
+bool
+func_to_bind_with_iter(int a, std::string::iterator& b)
{
result_stream << "func_to_bind_with_iter(" << a << ", " << *b << ")";
return true;
}
-bool func_to_bind_with_const_iter(int a, std::string::const_iterator& b)
+bool
+func_to_bind_with_const_iter(int a, std::string::const_iterator& b)
{
result_stream << "func_to_bind_with_const_iter(" << a << ", " << *b << ")";
return true;
@@ -36,33 +39,35 @@ bool func_to_bind_with_const_iter(int a, std::string::const_iterator& b)
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-
- //Test that sigc::bind()'s result can be converted to a sigc::slot<>.
+ // Test that sigc::bind()'s result can be converted to a sigc::slot<>.
{
sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind), 2);
bound_slot(1);
util->check_result(result_stream, "func_to_bind(1, 2)");
}
- //Test with a non-const iterator:
+ // Test with a non-const iterator:
{
std::string c = "2";
- sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_iter), c.begin());
+ sigc::slot<bool(int)> bound_slot =
+ sigc::bind(sigc::ptr_fun(&func_to_bind_with_iter), c.begin());
bound_slot(1);
util->check_result(result_stream, "func_to_bind_with_iter(1, 2)");
}
- //Test with a const_iterator:
+ // Test with a const_iterator:
{
const std::string c = "2";
- sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_const_iter), c.begin());
+ sigc::slot<bool(int)> bound_slot =
+ sigc::bind(sigc::ptr_fun(&func_to_bind_with_const_iter), c.begin());
bound_slot(1);
util->check_result(result_stream, "func_to_bind_with_const_iter(1, 2)");
}
diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc
index d1e02c6..831c3bc 100644
--- a/tests/test_bind_ref.cc
+++ b/tests/test_bind_ref.cc
@@ -12,30 +12,30 @@ std::ostringstream result_stream;
class Param : public sigc::trackable
{
public:
- Param(const std::string& name)
- : name_(name)
- {}
+ Param(const std::string& name) : name_(name) {}
- //non-copyable,
- //so it can only be used with sigc::bind() via sigc::ref()
+ // non-copyable,
+ // so it can only be used with sigc::bind() via sigc::ref()
Param(const Param&) = delete;
Param& operator=(const Param&) = delete;
- //non movable:
+ // non movable:
Param(Param&&) = delete;
Param& operator=(Param&&) = delete;
std::string name_;
};
-void handler(Param& param)
+void
+handler(Param& param)
{
result_stream << " handler(param): param.name_=" << param.name_;
}
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -49,17 +49,18 @@ int main(int argc, char* argv[])
util->check_result(result_stream, "");
{
- //Because Param derives from sigc::trackable(), std::ref() should disconnect
+ // Because Param derives from sigc::trackable(), std::ref() should disconnect
// the signal handler when param is destroyed.
Param param("murrayc");
// A convoluted way to do
// slot_bound = sigc::bind(slot_full, std::ref(param));
- slot_bound = sigc::bind< -1, decltype(slot_full), std::reference_wrapper<Param> >(slot_full,
std::ref(param));
+ slot_bound = sigc::bind<-1, decltype(slot_full), std::reference_wrapper<Param>>(
+ slot_full, std::ref(param));
result_stream << "Calling slot when param exists:";
slot_bound();
- util->check_result(result_stream,
- "Calling slot when param exists: handler(param): param.name_=murrayc");
+ util->check_result(
+ result_stream, "Calling slot when param exists: handler(param): param.name_=murrayc");
} // auto-disconnect
result_stream << "Calling slot when param does not exist:";
diff --git a/tests/test_bind_refptr.cc b/tests/test_bind_refptr.cc
index 925f2fc..04ad92c 100644
--- a/tests/test_bind_refptr.cc
+++ b/tests/test_bind_refptr.cc
@@ -130,9 +130,10 @@ public:
inline explicit operator bool() const;
#ifndef GLIBMM_DISABLE_DEPRECATED
- /// @deprecated Use reset() instead because this leads to confusion with clear() methods on the underlying
class. For instance, people use .clear() when they mean ->clear().
+ /// @deprecated Use reset() instead because this leads to confusion with clear() methods on the
+ /// underlying class. For instance, people use .clear() when they mean ->clear().
inline void clear();
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
/** Set underlying instance to 0, decrementing reference count of existing instance appropriately.
* @newin{2,16}
@@ -193,43 +194,38 @@ private:
T_CppObject* pCppObject_;
};
-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// RefPtr<>::operator->() comes first here since it's used by other methods.
// If it would come after them it wouldn't be inlined.
-template <class T_CppObject> inline
-T_CppObject* RefPtr<T_CppObject>::operator->() const
+template <class T_CppObject>
+inline T_CppObject* RefPtr<T_CppObject>::operator->() const
{
return pCppObject_;
}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>::RefPtr()
-:
- pCppObject_ (nullptr)
-{}
+template <class T_CppObject>
+inline RefPtr<T_CppObject>::RefPtr() : pCppObject_(nullptr)
+{
+}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>::~RefPtr()
+template <class T_CppObject>
+inline RefPtr<T_CppObject>::~RefPtr()
{
- if(pCppObject_)
+ if (pCppObject_)
pCppObject_->unreference(); // This could cause pCppObject to be deleted.
}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>::RefPtr(T_CppObject* pCppObject)
-:
- pCppObject_ (pCppObject)
-{}
+template <class T_CppObject>
+inline RefPtr<T_CppObject>::RefPtr(T_CppObject* pCppObject) : pCppObject_(pCppObject)
+{
+}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CppObject>& src)
-:
- pCppObject_ (src.pCppObject_)
+template <class T_CppObject>
+inline RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CppObject>& src) : pCppObject_(src.pCppObject_)
{
- if(pCppObject_)
+ if (pCppObject_)
pCppObject_->reference();
}
@@ -237,29 +233,29 @@ RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CppObject>& src)
// castable. Thus, it does downcasts:
// base_ref = derived_ref
template <class T_CppObject>
- template <class T_CastFrom>
-inline
-RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CastFrom>& src)
-:
- // A different RefPtr<> will not allow us access to pCppObject_. We need
+template <class T_CastFrom>
+inline RefPtr<T_CppObject>::RefPtr(const RefPtr<T_CastFrom>& src)
+: // A different RefPtr<> will not allow us access to pCppObject_. We need
// to add a get_underlying() for this, but that would encourage incorrect
// use, so we use the less well-known operator->() accessor:
- pCppObject_ (src.operator->())
+ pCppObject_(src.operator->())
{
- if(pCppObject_)
+ if (pCppObject_)
pCppObject_->reference();
}
-template <class T_CppObject> inline
-void RefPtr<T_CppObject>::swap(RefPtr<T_CppObject>& other)
+template <class T_CppObject>
+inline void
+RefPtr<T_CppObject>::swap(RefPtr<T_CppObject>& other)
{
const auto temp = pCppObject_;
pCppObject_ = other.pCppObject_;
other.pCppObject_ = temp;
}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CppObject>& src)
+template <class T_CppObject>
+inline RefPtr<T_CppObject>&
+RefPtr<T_CppObject>::operator=(const RefPtr<T_CppObject>& src)
{
// In case you haven't seen the swap() technique to implement copy
// assignment before, here's what it does:
@@ -285,113 +281,121 @@ RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CppObject>& s
// even thinking about it to implement copy assignment whereever the
// object data is managed indirectly via a pointer, which is very common.
- RefPtr<T_CppObject> temp (src);
+ RefPtr<T_CppObject> temp(src);
this->swap(temp);
return *this;
}
template <class T_CppObject>
- template <class T_CastFrom>
-inline
-RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CastFrom>& src)
+template <class T_CastFrom>
+inline RefPtr<T_CppObject>&
+RefPtr<T_CppObject>::operator=(const RefPtr<T_CastFrom>& src)
{
- RefPtr<T_CppObject> temp (src);
+ RefPtr<T_CppObject> temp(src);
this->swap(temp);
return *this;
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator==(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator==(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ == src.pCppObject_);
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator!=(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator!=(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ != src.pCppObject_);
}
-template <class T_CppObject> inline
-RefPtr<T_CppObject>::operator bool() const
+template <class T_CppObject>
+inline RefPtr<T_CppObject>::operator bool() const
{
return (pCppObject_ != nullptr);
}
#ifndef GLIBMM_DISABLE_DEPRECATED
-template <class T_CppObject> inline
-void RefPtr<T_CppObject>::clear()
+template <class T_CppObject>
+inline void
+RefPtr<T_CppObject>::clear()
{
reset();
}
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
-template <class T_CppObject> inline
-void RefPtr<T_CppObject>::reset()
+template <class T_CppObject>
+inline void
+RefPtr<T_CppObject>::reset()
{
RefPtr<T_CppObject> temp; // swap with an empty RefPtr<> to clear *this
this->swap(temp);
}
template <class T_CppObject>
- template <class T_CastFrom>
-inline
-RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_dynamic(const RefPtr<T_CastFrom>& src)
+template <class T_CastFrom>
+inline RefPtr<T_CppObject>
+RefPtr<T_CppObject>::cast_dynamic(const RefPtr<T_CastFrom>& src)
{
const auto pCppObject = dynamic_cast<T_CppObject*>(src.operator->());
- if(pCppObject)
+ if (pCppObject)
pCppObject->reference();
return RefPtr<T_CppObject>(pCppObject);
}
template <class T_CppObject>
- template <class T_CastFrom>
-inline
-RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_static(const RefPtr<T_CastFrom>& src)
+template <class T_CastFrom>
+inline RefPtr<T_CppObject>
+RefPtr<T_CppObject>::cast_static(const RefPtr<T_CastFrom>& src)
{
const auto pCppObject = static_cast<T_CppObject*>(src.operator->());
- if(pCppObject)
+ if (pCppObject)
pCppObject->reference();
return RefPtr<T_CppObject>(pCppObject);
}
template <class T_CppObject>
- template <class T_CastFrom>
-inline
-RefPtr<T_CppObject> RefPtr<T_CppObject>::cast_const(const RefPtr<T_CastFrom>& src)
+template <class T_CastFrom>
+inline RefPtr<T_CppObject>
+RefPtr<T_CppObject>::cast_const(const RefPtr<T_CastFrom>& src)
{
const auto pCppObject = const_cast<T_CppObject*>(src.operator->());
- if(pCppObject)
+ if (pCppObject)
pCppObject->reference();
return RefPtr<T_CppObject>(pCppObject);
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator<(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator<(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ < src.pCppObject_);
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator<=(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator<=(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ <= src.pCppObject_);
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator>(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator>(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ > src.pCppObject_);
}
-template <class T_CppObject> inline
-bool RefPtr<T_CppObject>::operator>=(const RefPtr<T_CppObject>& src) const
+template <class T_CppObject>
+inline bool
+RefPtr<T_CppObject>::operator>=(const RefPtr<T_CppObject>& src) const
{
return (pCppObject_ >= src.pCppObject_);
}
@@ -399,18 +403,17 @@ bool RefPtr<T_CppObject>::operator>=(const RefPtr<T_CppObject>& src) const
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/** @relates Glib::RefPtr */
-template <class T_CppObject> inline
-void swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs)
+template <class T_CppObject>
+inline void
+swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs)
{
lhs.swap(rhs);
}
} // namespace Glib
-
#endif /* _GLIBMM_REFPTR_H */
-
namespace
{
std::ostringstream result_stream;
@@ -418,10 +421,14 @@ std::ostringstream result_stream;
class Action : public sigc::trackable
{
public:
- Action() : ref_count(1) { }
+ Action() : ref_count(1) {}
void reference() { ++ref_count; }
- void unreference() { if (--ref_count <= 0) delete this; }
+ void unreference()
+ {
+ if (--ref_count <= 0)
+ delete this;
+ }
void emit_sig1(int n) { sig1.emit(n); }
@@ -430,17 +437,15 @@ public:
private:
sigc::signal<void(int)> sig1;
int ref_count;
-
};
class Test : public sigc::trackable
{
public:
- Test()
- : action(new Action)
+ Test() : action(new Action)
{
result_stream << "new Test; ";
-#ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c14
+#ifdef ACTIVATE_BUG // See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c14
action->signal_sig1().connect(sigc::bind(sigc::mem_fun(*this, &Test::on_sig1), action));
#else
Glib::RefPtr<Action> action2(new Action);
@@ -448,10 +453,7 @@ public:
#endif
}
- ~Test()
- {
- result_stream << "delete Test; ";
- }
+ ~Test() { result_stream << "delete Test; "; }
void on_sig1(int n, Glib::RefPtr<Action> /* action */)
{
@@ -464,7 +466,8 @@ public:
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_bind_return.cc b/tests/test_bind_return.cc
index 737e96b..c9bf9b4 100644
--- a/tests/test_bind_return.cc
+++ b/tests/test_bind_return.cc
@@ -17,15 +17,12 @@ std::ostringstream result_stream;
struct foo
{
- void operator()(int i)
- {
- result_stream << "foo(int " << i << ") ";
- }
+ void operator()(int i) { result_stream << "foo(int " << i << ") "; }
float operator()(float i)
{
result_stream << "foo(float " << i << ") ";
- return i*5;
+ return i * 5;
}
};
@@ -38,7 +35,8 @@ struct bar : public sigc::trackable
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -54,7 +52,7 @@ int main(int argc, char* argv[])
std::string str("guest book");
// A convoluted way to do
// sigc::bind_return(foo(), std::ref(str))(6) = "main";
- sigc::bind_return<std::reference_wrapper<std::string> >(foo(), std::ref(str))(6) = "main";
+ sigc::bind_return<std::reference_wrapper<std::string>>(foo(), std::ref(str))(6) = "main";
result_stream << str;
util->check_result(result_stream, "foo(int 6) main");
diff --git a/tests/test_compose.cc b/tests/test_compose.cc
index 1169be6..414947e 100644
--- a/tests/test_compose.cc
+++ b/tests/test_compose.cc
@@ -9,7 +9,10 @@
#include <cstdlib>
// assume existance of T_functor::result_type for unknown functor types:
-namespace sigc { SIGC_FUNCTORS_HAVE_RESULT_TYPE }
+namespace sigc
+{
+SIGC_FUNCTORS_HAVE_RESULT_TYPE
+}
namespace
{
@@ -23,13 +26,13 @@ struct set
double operator()(int i)
{
result_stream << "set(int " << i << ") ";
- return i*i;
+ return i * i;
}
double operator()(double i)
{
result_stream << "set(double " << i << ") ";
- return i*5;
+ return i * 5;
}
};
@@ -37,10 +40,7 @@ struct set_void
{
using result_type = void;
- void operator()(double i)
- {
- result_stream << "set_void(double " << i << ")";
- }
+ void operator()(double i) { result_stream << "set_void(double " << i << ")"; }
};
struct get
@@ -55,13 +55,13 @@ struct get
int operator()(int i)
{
result_stream << "get(" << i << ") ";
- return i*2;
+ return i * 2;
}
double operator()(int i, int j)
{
result_stream << "get(" << i << ", " << j << ") ";
- return double(i)/double(j);
+ return double(i) / double(j);
}
#else
// choose a type that can hold all return values
@@ -76,20 +76,21 @@ struct get
double operator()(int i)
{
result_stream << "get(" << i << ") ";
- return i*2;
+ return i * 2;
}
double operator()(int i, int j)
{
result_stream << "get(" << i << ", " << j << ") ";
- return double(i)/double(j);
+ return double(i) / double(j);
}
#endif
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -105,7 +106,7 @@ int main(int argc, char* argv[])
result_stream << sigc::compose(set(), get())(1, 2);
util->check_result(result_stream, "get(1, 2) set(double 0.5) 2.5");
- sigc::compose(set_void(), get())(3); //void test
+ sigc::compose(set_void(), get())(3); // void test
util->check_result(result_stream, "get(3) set_void(double 6)");
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/test_copy_invalid_slot.cc b/tests/test_copy_invalid_slot.cc
index 4dcb6d6..5af9121 100644
--- a/tests/test_copy_invalid_slot.cc
+++ b/tests/test_copy_invalid_slot.cc
@@ -10,14 +10,16 @@ namespace
{
std::ostringstream result_stream;
-void Foo(sigc::trackable&)
+void
+Foo(sigc::trackable&)
{
result_stream << "Foo(x)";
}
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index 8d62536..624bb0d 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -42,7 +42,6 @@
// echo $?
// If test_cpp11_lambda writes nothing and the return code is 0, the test has passed.
-
#include "testutilities.h"
#include <string>
#include <iostream>
@@ -54,18 +53,19 @@
#include <sigc++/adaptors/track_obj.h>
#include <sigc++/signal.h>
-
namespace
{
std::ostringstream result_stream;
-int foo(int i, int j)
+int
+foo(int i, int j)
{
result_stream << "foo(int " << i << ", int " << j << ") ";
- return 4*i + j;
+ return 4 * i + j;
}
-void foo_void(int i)
+void
+foo_void(int i)
{
result_stream << "foo_void(int " << i << ")";
}
@@ -75,16 +75,14 @@ struct bar
int test(int i, int j)
{
result_stream << "bar::test(int " << i << ", int " << j << ") ";
- return 4*i + j;
+ return 4 * i + j;
}
- void test_void(int i)
- {
- result_stream << "bar::test_void(int " << i << ")";
- }
+ void test_void(int i) { result_stream << "bar::test_void(int " << i << ")"; }
};
-void egon(std::string& str)
+void
+egon(std::string& str)
{
result_stream << "egon(string '" << str << "')";
str = "egon was here";
@@ -93,33 +91,38 @@ void egon(std::string& str)
struct book : public sigc::trackable
{
explicit book(const std::string& name) : name_(name) {}
- operator std::string& () { return name_; }
+ operator std::string&() { return name_; }
std::string name_;
};
-inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
+inline std::ostringstream&
+operator<<(std::ostringstream& s, const book& b)
{
s << b.name_;
return s;
}
-void foo_group1(int i, int j)
+void
+foo_group1(int i, int j)
{
result_stream << "foo_group1(int " << i << ", int " << j << ")";
}
-int bar_group1(int i)
+int
+bar_group1(int i)
{
result_stream << "bar_group1(int " << i << ") ";
return i + 2;
}
-void foo_group2(int i)
+void
+foo_group2(int i)
{
result_stream << "foo_group2(int " << i << ")";
}
-void foo_group3(int& i)
+void
+foo_group3(int& i)
{
result_stream << "foo_group3(int " << i << ")";
++i;
@@ -129,135 +132,141 @@ struct bar_group4 : public sigc::trackable
{
};
-void foo_group4(bar_group4&)
+void
+foo_group4(bar_group4&)
{
result_stream << "foo_group4(bar_group4&)";
}
} // end anonymous namespace
-
-
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-
// test lambda operators
- //std::cout << "(_1 + _2) (3,4): " << (_1 + _2) (3,4) << std::endl;
- result_stream << ([] (int a, int b) -> int { return a + b; }(3,4));
+ // std::cout << "(_1 + _2) (3,4): " << (_1 + _2) (3,4) << std::endl;
+ result_stream << ([](int a, int b) -> int { return a + b; }(3, 4));
util->check_result(result_stream, "7");
- //std::cout << "(_1 + 1) (3,4): " << (_1 + 1) (3,4) << std::endl;
- result_stream << ([] (int a, int) -> int { return a + 1; }(3,4));
+ // std::cout << "(_1 + 1) (3,4): " << (_1 + 1) (3,4) << std::endl;
+ result_stream << ([](int a, int) -> int { return a + 1; }(3, 4));
util->check_result(result_stream, "4");
- //std::cout << "(_2 + 1) (3,4): " << (_2 + 1) (3,4) << std::endl;
- result_stream << ([] (int, int b) -> int { return b + 1; }(3,4));
+ // std::cout << "(_2 + 1) (3,4): " << (_2 + 1) (3,4) << std::endl;
+ result_stream << ([](int, int b) -> int { return b + 1; }(3, 4));
util->check_result(result_stream, "5");
- //std::cout << "(2 + _1) (3,4): " << (2 + _1) (3,4) << std::endl;
- result_stream << ([] (int a, int) -> int { return 2 + a; }(3,4));
+ // std::cout << "(2 + _1) (3,4): " << (2 + _1) (3,4) << std::endl;
+ result_stream << ([](int a, int) -> int { return 2 + a; }(3, 4));
util->check_result(result_stream, "5");
- //std::cout << "(2 + _2) (3,4): " << (2 + _2) (3,4) << std::endl;
- result_stream << ([] (int, int b) -> int { return 2 + b; }(3,4));
+ // std::cout << "(2 + _2) (3,4): " << (2 + _2) (3,4) << std::endl;
+ result_stream << ([](int, int b) -> int { return 2 + b; }(3, 4));
util->check_result(result_stream, "6");
- //std::cout << "(_1+_2*_3)(1,2,3): " << (_1+_2*_3)(1,2,3) << std::endl;
- result_stream << ([] (int a, int b, int c) -> int { return a + b*c; }(1,2,3));
+ // std::cout << "(_1+_2*_3)(1,2,3): " << (_1+_2*_3)(1,2,3) << std::endl;
+ result_stream << ([](int a, int b, int c) -> int { return a + b * c; }(1, 2, 3));
util->check_result(result_stream, "7");
- //std::cout << "((++_1)*2)(1): " << ((++_1)*2)(1) << std::endl;
- result_stream << ([] (int a) -> int { return ++a * 2; }(1));
+ // std::cout << "((++_1)*2)(1): " << ((++_1)*2)(1) << std::endl;
+ result_stream << ([](int a) -> int { return ++a * 2; }(1));
util->check_result(result_stream, "4");
- //std::cout << "((++_1)*2)(a): " << ((++_1)*2)(a);
- //std::cout << "; a: " << a << std::endl;
+ // std::cout << "((++_1)*2)(a): " << ((++_1)*2)(a);
+ // std::cout << "; a: " << a << std::endl;
int a_outer = 1;
- result_stream << ([] (int x) -> int { return ++x * 2; }(a_outer)) << " " << a_outer;
+ result_stream << ([](int x) -> int { return ++x * 2; }(a_outer)) << " " << a_outer;
util->check_result(result_stream, "4 1");
// gcc can't compile libsigc++ lambda expressions with std::ref() parameters.
// See https://bugzilla.gnome.org/show_bug.cgi?id=669128
// std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(std::ref(a));
// std::cout << "; a: " << a << std::endl;
- result_stream << ([] (std::reference_wrapper<int> x) -> int { return ++x * 2; }(std::ref(a_outer)));
+ result_stream << ([](std::reference_wrapper<int> x) -> int { return ++x * 2; }(
+ std::ref(a_outer)));
result_stream << " " << a_outer;
util->check_result(result_stream, "4 2");
- result_stream << ([] (int& x) -> int { return ++x * 2; }(a_outer));
+ result_stream << ([](int& x) -> int { return ++x * 2; }(a_outer));
result_stream << " " << a_outer;
util->check_result(result_stream, "6 3");
- //std::cout << "((++(*_1))*2)(&a): " << ((++(*_1))*2)(&a);
- //std::cout << "; a: " << a << std::endl;
- result_stream << ([] (int* x) -> int { return ++(*x) * 2; }(&a_outer));
+ // std::cout << "((++(*_1))*2)(&a): " << ((++(*_1))*2)(&a);
+ // std::cout << "; a: " << a << std::endl;
+ result_stream << ([](int* x) -> int { return ++(*x) * 2; }(&a_outer));
result_stream << " " << a_outer;
util->check_result(result_stream, "8 4");
// std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(std::ref(a));
// std::cout << "; a: " << a << std::endl;
- result_stream << ([] (std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(std::ref(a_outer)));
+ result_stream << ([](std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(
+ std::ref(a_outer)));
result_stream << " " << a_outer;
util->check_result(result_stream, "6 3");
- result_stream << ([] (int& x) -> int { return --(*(&x)) * 2; }(a_outer));
+ result_stream << ([](int& x) -> int { return --(*(&x)) * 2; }(a_outer));
result_stream << " " << a_outer;
util->check_result(result_stream, "4 2");
- //std::cout << "(-_1) (-5): " << (-_1) (-5) << std::endl;
- result_stream << ([] (int x) -> int { return -x; }(-5));
+ // std::cout << "(-_1) (-5): " << (-_1) (-5) << std::endl;
+ result_stream << ([](int x) -> int { return -x; }(-5));
util->check_result(result_stream, "5");
- //std::cout << "(var(&a)[0])(): " << (sigc::var(&a)[0])() << std::endl;
+ // std::cout << "(var(&a)[0])(): " << (sigc::var(&a)[0])() << std::endl;
result_stream << ([&a_outer]() -> int { return a_outer; }());
util->check_result(result_stream, "2");
- //std::cout << "(_1[_2]) (&a,0): " << (_1[_2]) (&a,0) << std::endl;
- result_stream << ([] (int* x, int y) -> int { return x[y]; }(&a_outer,0));
+ // std::cout << "(_1[_2]) (&a,0): " << (_1[_2]) (&a,0) << std::endl;
+ result_stream << ([](int* x, int y) -> int { return x[y]; }(&a_outer, 0));
util->check_result(result_stream, "2");
- //std::cout << "(*_1=_2) (&a,1): " << (*_1=_2) (&a,1) << std::endl;
- result_stream << ([] (int* x, int y) -> int { *x = y; return *x; }(&a_outer,1));
+ // std::cout << "(*_1=_2) (&a,1): " << (*_1=_2) (&a,1) << std::endl;
+ result_stream << ([](int* x, int y) -> int {
+ *x = y;
+ return *x;
+ }(&a_outer, 1));
util->check_result(result_stream, "1");
// Comma operator, https://bugzilla.gnome.org/show_bug.cgi?id=342911
a_outer = -1;
int b_outer = -1;
int c_outer = -1;
- //std::cout << "(var(c) = (var(a) = _1, var(b) = _2))(2,3): "
+ // std::cout << "(var(c) = (var(a) = _1, var(b) = _2))(2,3): "
// << (sigc::var(c) = (sigc::var(a) = _1, sigc::var(b) = _2))(2,3);
- //std::cout << "; a: " << a << "; b: " << b << "; c: " << c << std::endl;
- result_stream << ([&a_outer,&b_outer,&c_outer](int x, int y) -> int { return c_outer = (a_outer = x,
b_outer = y); }(2,3));
+ // std::cout << "; a: " << a << "; b: " << b << "; c: " << c << std::endl;
+ result_stream << ([&a_outer, &b_outer, &c_outer](
+ int x, int y) -> int { return c_outer = (a_outer = x, b_outer = y); }(2, 3));
result_stream << " " << a_outer << " " << b_outer << " " << c_outer;
util->check_result(result_stream, "3 2 3 3");
// c++ restrictions:
// - ref() must be used to indicate that the value shall not be copied
// - constant() is used to create a lambda and delay execution of "std::cout << 1"
- // - var() is used to create a lambda that holds a reference and is interchangable with ref() in lambda
operator expressions
+ // - var() is used to create a lambda that holds a reference and is interchangable with ref() in
+ // lambda operator expressions
// - cannot use std::endl without much hackery because it is defined as a template function
// - cannot use "\n" without var() because arrays cannot be copied
// (std::ref(std::cout) << sigc::constant(1) << sigc::var("\n"))();
- [](){ result_stream << 1 << "\n"; }();
+ []() { result_stream << 1 << "\n"; }();
util->check_result(result_stream, "1\n");
//(std::ref(std::cout) << _1 << std::string("\n"))("hello world");
- [](const char* a){ result_stream << a << std::string("\n"); }("hello world");
+ [](const char* a) { result_stream << a << std::string("\n"); }("hello world");
util->check_result(result_stream, "hello world\n");
//(std::ref(std::cout) << sigc::static_cast_<int>(_1) << std::string("\n"))(1.234);
- [](double a){ result_stream << static_cast<int>(a) << std::string("\n"); }(1.234);
+ [](double a) { result_stream << static_cast<int>(a) << std::string("\n"); }(1.234);
util->check_result(result_stream, "1\n");
// (sigc::var(std::cout) << 1 << sigc::var("\n"))();
- [](){ result_stream << 1 << "\n"; }();
+ []() { result_stream << 1 << "\n"; }();
util->check_result(result_stream, "1\n");
//(sigc::var(std::cout) << _1 << std::string("\n"))("hello world");
- [](const char* a){ result_stream << a << std::string("\n"); }("hello world");
+ [](const char* a) { result_stream << a << std::string("\n"); }("hello world");
util->check_result(result_stream, "hello world\n");
// auto-disconnect
@@ -268,9 +277,11 @@ int main(int argc, char* argv[])
sigc::slot<void(std::ostringstream&)> sl1;
{
book guest_book("karl");
- //sl1 = (sigc::var(std::cout) << std::ref(guest_book) << sigc::var("\n"));
- // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no
auto-disconnect
- sl1 = sigc::track_obj([&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; },
guest_book);
+ // sl1 = (sigc::var(std::cout) << std::ref(guest_book) << sigc::var("\n"));
+ // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no
+ // auto-disconnect
+ sl1 = sigc::track_obj(
+ [&guest_book](std::ostringstream& stream) { stream << guest_book << "\n"; }, guest_book);
sl1(result_stream);
util->check_result(result_stream, "karl\n");
@@ -281,27 +292,28 @@ int main(int argc, char* argv[])
// test group adaptor, here replaced by std::bind
bar the_bar;
- //std::cout << (sigc::group(&foo, _1, _2)) (1, 2) << std::endl;
+ // std::cout << (sigc::group(&foo, _1, _2)) (1, 2) << std::endl;
result_stream << std::bind(&foo, std::placeholders::_1, std::placeholders::_2)(1, 2);
util->check_result(result_stream, "foo(int 1, int 2) 6");
- //std::cout << (sigc::group(&foo, _2, _1)) (1, 2) << std::endl;
+ // std::cout << (sigc::group(&foo, _2, _1)) (1, 2) << std::endl;
result_stream << std::bind(&foo, std::placeholders::_2, std::placeholders::_1)(1, 2);
util->check_result(result_stream, "foo(int 2, int 1) 9");
- //std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (std::ref(the_bar), 1, 2) << std::endl;
+ // std::cout << (sigc::group(sigc::mem_fun(&bar::test), _1, _2, _3)) (std::ref(the_bar), 1, 2) <<
+ // std::endl;
// std::ref(the_bar) is not necessary. It can make the call ambiguous.
// Even without std::ref() the_bar is not copied.
- result_stream << std::bind(std::mem_fn(&bar::test), std::placeholders::_1,
- std::placeholders::_2, std::placeholders::_3)(the_bar, 1, 2);
+ result_stream << std::bind(std::mem_fn(&bar::test), std::placeholders::_1, std::placeholders::_2,
+ std::placeholders::_3)(the_bar, 1, 2);
util->check_result(result_stream, "bar::test(int 1, int 2) 6");
// same functionality as bind
- //std::cout << (sigc::group(&foo, _1, 2)) (1) << std::endl;
+ // std::cout << (sigc::group(&foo, _1, 2)) (1) << std::endl;
result_stream << std::bind(&foo, std::placeholders::_1, 2)(1);
util->check_result(result_stream, "foo(int 1, int 2) 6");
- //std::cout << (sigc::group(&foo, 1, 2)) () << std::endl;
+ // std::cout << (sigc::group(&foo, 1, 2)) () << std::endl;
result_stream << std::bind(&foo, 1, 2)();
util->check_result(result_stream, "foo(int 1, int 2) 6");
@@ -319,14 +331,14 @@ int main(int argc, char* argv[])
sigc::slot<void()> sl2;
{
book guest_book("karl");
- //sl2 = sigc::group(&egon, std::ref(guest_book));
+ // sl2 = sigc::group(&egon, std::ref(guest_book));
// sl2 = [&guest_book] () { egon(guest_book); }; // no auto-disconnect
// sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
- sl2 = sigc::track_obj([&guest_book] () { egon(guest_book); }, guest_book);
+ sl2 = sigc::track_obj([&guest_book]() { egon(guest_book); }, guest_book);
sl2();
util->check_result(result_stream, "egon(string 'karl')");
- //std::cout << static_cast<std::string&>(guest_book) << std::endl;
+ // std::cout << static_cast<std::string&>(guest_book) << std::endl;
result_stream << static_cast<std::string&>(guest_book);
util->check_result(result_stream, "egon was here");
@@ -338,15 +350,15 @@ int main(int argc, char* argv[])
// More auto-disconnect
{
book guest_book("charlie");
- //sl2 = sigc::group(&egon, std::ref(guest_book));
+ // sl2 = sigc::group(&egon, std::ref(guest_book));
// sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
auto fn2 = std::bind(&egon, std::ref(guest_book));
- //sl2 = fn2; // no auto-disconnect
+ // sl2 = fn2; // no auto-disconnect
sl2 = sigc::track_obj(fn2, guest_book);
sl2();
util->check_result(result_stream, "egon(string 'charlie')");
- //std::cout << static_cast<std::string&>(guest_book) << std::endl;
+ // std::cout << static_cast<std::string&>(guest_book) << std::endl;
result_stream << static_cast<std::string&>(guest_book);
util->check_result(result_stream, "egon was here");
@@ -356,23 +368,23 @@ int main(int argc, char* argv[])
util->check_result(result_stream, "");
// same functionality as hide
- //std::cout << (sigc::group(&foo, _1, _2)) (1,2,3) << std::endl;
- result_stream << std::bind(&foo, std::placeholders::_1, std::placeholders::_2)(1,2,3);
+ // std::cout << (sigc::group(&foo, _1, _2)) (1,2,3) << std::endl;
+ result_stream << std::bind(&foo, std::placeholders::_1, std::placeholders::_2)(1, 2, 3);
util->check_result(result_stream, "foo(int 1, int 2) 6");
//(sigc::group(sigc::ptr_fun(&foo_void), _2)) (1, 2);
- std::bind(&foo_void, std::placeholders::_2)(1, 2);
+ std::bind (&foo_void, std::placeholders::_2)(1, 2);
util->check_result(result_stream, "foo_void(int 2)");
// same functionality as compose
- //std::cout << (sigc::group(&foo, sigc::group(&foo, _1, _2), _3)) (1,2,3) << std::endl;
+ // std::cout << (sigc::group(&foo, sigc::group(&foo, _1, _2), _3)) (1,2,3) << std::endl;
result_stream << std::bind(&foo, std::bind(&foo, std::placeholders::_1, std::placeholders::_2),
- std::placeholders::_3)(1,2,3);
+ std::placeholders::_3)(1, 2, 3);
util->check_result(result_stream, "foo(int 1, int 2) foo(int 6, int 3) 27");
// same functionality as retype
- //std::cout << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234) << std::endl;
- result_stream << ([] (double x) -> int { return foo(static_cast<int>(x), 2); }(1.234));
+ // std::cout << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234) << std::endl;
+ result_stream << ([](double x) -> int { return foo(static_cast<int>(x), 2); }(1.234));
util->check_result(result_stream, "foo(int 1, int 2) 6");
// Code examples with C++11 lambda expressions and std::bind, which can replace
@@ -381,23 +393,23 @@ int main(int argc, char* argv[])
//--- sigc++/adaptors/lambda/macros/base.h.m4
- //std::cout << sigc::_1(10,20,30); // returns 10
- result_stream << ([] (int x, int, int) -> int { return x; }(10,20,30));
+ // std::cout << sigc::_1(10,20,30); // returns 10
+ result_stream << ([](int x, int, int) -> int { return x; }(10, 20, 30));
util->check_result(result_stream, "10");
- //std::cout << sigc::_2(10,20,30); // returns 20
- result_stream << ([] (int, int y, int) -> int { return y; }(10,20,30));
+ // std::cout << sigc::_2(10,20,30); // returns 20
+ result_stream << ([](int, int y, int) -> int { return y; }(10, 20, 30));
util->check_result(result_stream, "20");
- //std::cout << (sigc::_1 + 5)(3); // returns (3 + 5)
- result_stream << ([] (int x) -> int { return x + 5; }(3));
+ // std::cout << (sigc::_1 + 5)(3); // returns (3 + 5)
+ result_stream << ([](int x) -> int { return x + 5; }(3));
util->check_result(result_stream, "8");
- //std::cout << (sigc::_1 * sigc::_2)(7,10); // returns (7 * 10)
- result_stream << ([] (int x, int y) -> int { return x * y; }(7,10));
+ // std::cout << (sigc::_1 * sigc::_2)(7,10); // returns (7 * 10)
+ result_stream << ([](int x, int y) -> int { return x * y; }(7, 10));
util->check_result(result_stream, "70");
- //int main(int argc, char* argv[])
+ // int main(int argc, char* argv[])
//{
// int data;
// sigc::signal<int()> readValue;
@@ -414,7 +426,7 @@ int main(int argc, char* argv[])
int data;
sigc::signal<int()> readValue;
- readValue.connect([&data] () -> int { return data; });
+ readValue.connect([&data]() -> int { return data; });
data = 3;
result_stream << readValue();
@@ -428,65 +440,70 @@ int main(int argc, char* argv[])
//--- sigc++/adaptors/lambda/macros/group.h.m4
// argument binding ...
- //sigc::group(&foo,10,sigc::_1)(20); //fixes the first argument and calls foo(10,20)
- std::bind(&foo_group1, 10, std::placeholders::_1)(20);
+ // sigc::group(&foo,10,sigc::_1)(20); //fixes the first argument and calls foo(10,20)
+ std::bind (&foo_group1, 10, std::placeholders::_1)(20);
util->check_result(result_stream, "foo_group1(int 10, int 20)");
- //sigc::group(&foo,sigc::_1,30)(40); //fixes the second argument and calls foo(40,30)
- std::bind(&foo_group1, std::placeholders::_1, 30)(40);
+ // sigc::group(&foo,sigc::_1,30)(40); //fixes the second argument and calls foo(40,30)
+ std::bind (&foo_group1, std::placeholders::_1, 30)(40);
util->check_result(result_stream, "foo_group1(int 40, int 30)");
// argument reordering ...
- //sigc::group(&foo,sigc::_2,sigc::_1)(1,2); //calls foo(2,1)
- std::bind(&foo_group1, std::placeholders::_2, std::placeholders::_1)(1,2);
+ // sigc::group(&foo,sigc::_2,sigc::_1)(1,2); //calls foo(2,1)
+ std::bind (&foo_group1, std::placeholders::_2, std::placeholders::_1)(1, 2);
util->check_result(result_stream, "foo_group1(int 2, int 1)");
// argument hiding ...
- //sigc::group(&foo,sigc::_1,sigc::_2)(1,2,3); //calls foo(1,2)
- std::bind(&foo_group1, std::placeholders::_1, std::placeholders::_2)(1,2,3);
+ // sigc::group(&foo,sigc::_1,sigc::_2)(1,2,3); //calls foo(1,2)
+ std::bind (&foo_group1, std::placeholders::_1, std::placeholders::_2)(1, 2, 3);
util->check_result(result_stream, "foo_group1(int 1, int 2)");
// functor composition ...
- //sigc::group(&foo,sigc::_1,sigc::group(&bar,sigc::_2))(1,2); //calls foo(1,bar(2))
- std::bind(&foo_group1, std::placeholders::_1, std::bind(&bar_group1, std::placeholders::_2))(1,2);
+ // sigc::group(&foo,sigc::_1,sigc::group(&bar,sigc::_2))(1,2); //calls foo(1,bar(2))
+ std::bind (&foo_group1, std::placeholders::_1, std::bind(&bar_group1, std::placeholders::_2))(
+ 1, 2);
util->check_result(result_stream, "bar_group1(int 2) foo_group1(int 1, int 4)");
// algebraic expressions ...
// sigc::group(&foo,sigc::_1*sigc::_2,sigc::_1/sigc::_2)(6,3); //calls foo(6*3,6/3)
- [] (int x, int y) { foo_group1(x*y, x/y); }(6,3);
+ [](int x, int y) { foo_group1(x * y, x / y); }(6, 3);
util->check_result(result_stream, "foo_group1(int 18, int 2)");
{
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(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); });
- some_signal.emit(1,2);
+ some_signal.emit(1, 2);
util->check_result(result_stream, "foo_group2(int 2)");
}
{
int some_int = 0;
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
- some_signal.connect([&some_int](){ foo_group3(some_int); });
+ // 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
+ some_signal.connect([&some_int]() { foo_group3(some_int); });
some_signal.emit();
result_stream << " " << some_int;
util->check_result(result_stream, "foo_group3(int 0) 1");
}
{
- //struct bar : public sigc::trackable {} some_bar;
+ // struct bar : public sigc::trackable {} some_bar;
sigc::signal<void()> some_signal;
{
bar_group4 some_bar;
- //some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
+ // some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
// disconnected automatically if some_bar goes out of scope
- //some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
- //some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer
C++11 lambda
- some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar));
+ // some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
+ // some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but
+ // we prefer C++11 lambda
+ some_signal.connect(sigc::track_obj([&some_bar]() { foo_group4(some_bar); }, some_bar));
some_signal.emit();
util->check_result(result_stream, "foo_group4(bar_group4&)");
}
diff --git a/tests/test_custom.cc b/tests/test_custom.cc
index 8b4e0f6..a32e83c 100644
--- a/tests/test_custom.cc
+++ b/tests/test_custom.cc
@@ -13,7 +13,8 @@ std::ostringstream result_stream;
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc
index 7069a4d..0624fac 100644
--- a/tests/test_disconnect.cc
+++ b/tests/test_disconnect.cc
@@ -12,21 +12,23 @@
#include <sstream>
#include <cstdlib>
-//The Tru64 compiler seems to need this to avoid an unresolved symbol
-//See bug #161503
+// The Tru64 compiler seems to need this to avoid an unresolved symbol
+// See bug #161503
#include <new>
namespace
{
std::ostringstream result_stream;
-int foo(int i)
+int
+foo(int i)
{
result_stream << "foo(" << i << ") ";
return 1;
}
-int bar(double i)
+int
+bar(double i)
{
result_stream << "bar(" << i << ") ";
return 1;
@@ -41,7 +43,8 @@ struct A : public sigc::trackable
}
};
-void good_bye_world()
+void
+good_bye_world()
{
result_stream << "Good bye world!";
}
@@ -55,27 +58,22 @@ struct B : public sigc::trackable
sig.connect(sigc::ptr_fun(&good_bye_world));
}
- void destroy() // Calling destroy() during signal emission seems weird!
- { // However, if this works, anything will work!
- delete this; // valgrind reports a small memory leak, that's all.
+ void destroy() // Calling destroy() during signal emission seems weird!
+ { // However, if this works, anything will work!
+ delete this; // valgrind reports a small memory leak, that's all.
}
- void boom()
- {
- result_stream << "boom!";
- }
+ void boom() { result_stream << "boom!"; }
- void emit()
- {
- sig.emit();
- }
+ void emit() { sig.emit(); }
sigc::signal<void()> sig;
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -85,7 +83,7 @@ int main(int argc, char* argv[])
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.
+ sigc::connection cona; // connection objects are safe to use beyond the life time of a signal.
{
A a;
@@ -94,20 +92,20 @@ int main(int argc, char* argv[])
conbar = sig.connect(sigc::ptr_fun(&bar));
result_stream << "sig is connected to A::foo, foo, bar (size=" << sig.size() << "): ";
sig(1);
- util->check_result(result_stream,
- "sig is connected to A::foo, foo, bar (size=3): A::foo(1) foo(1) bar(1) ");
- } // auto disconnection! iterators stay valid after disconnections.
+ util->check_result(
+ result_stream, "sig is connected to A::foo, foo, bar (size=3): A::foo(1) foo(1) bar(1) ");
+ } // auto disconnection! iterators stay valid after disconnections.
result_stream << "sig is connected to foo, bar (size=" << sig.size() << "): ";
sig(2);
util->check_result(result_stream, "sig is connected to foo, bar (size=2): foo(2) bar(2) ");
- A a; // iterators stay valid after further connections.
+ A a; // iterators stay valid after further connections.
cona = sig.slots().insert(conbar, sigc::mem_fun(a, &A::foo));
result_stream << "sig is connected to foo, A::foo, bar (size=" << sig.size() << "): ";
sig(3);
- util->check_result(result_stream,
- "sig is connected to foo, A::foo, bar (size=3): foo(3) A::foo(3) bar(3) ");
+ util->check_result(
+ result_stream, "sig is connected to foo, A::foo, bar (size=3): foo(3) A::foo(3) bar(3) ");
conbar->disconnect(); // manual disconnection
result_stream << "sig is connected to foo, A::foo (size=" << sig.size() << "): ";
@@ -119,19 +117,21 @@ int main(int argc, char* argv[])
sig(5);
util->check_result(result_stream, "sig is connected to A::foo (size=1): A::foo(5) ");
- cona.disconnect(); // manual disconnection
+ cona.disconnect(); // manual disconnection
result_stream << "sig is empty (size=" << sig.size() << "): ";
sig(6);
util->check_result(result_stream, "sig is empty (size=0): ");
- cona.disconnect(); // already disconnected -> legal with connection objects, however, nothing happens
...
+ cona.disconnect(); // already disconnected -> legal with connection objects, however, nothing
+ // happens ...
{
A a2;
sig.connect(sigc::compose(sigc::mem_fun(a2, &A::foo), &foo));
result_stream << "sig is connected to compose(A::foo, foo) (size=" << sig.size() << "): ";
sig(7);
- util->check_result(result_stream, "sig is connected to compose(A::foo, foo) (size=1): foo(7) A::foo(1)
");
+ util->check_result(
+ result_stream, "sig is connected to compose(A::foo, foo) (size=1): foo(7) A::foo(1) ");
}
result_stream << "sig is empty (size=" << sig.size() << "): ";
sig(8);
@@ -141,9 +141,11 @@ int main(int argc, char* argv[])
A a2;
sigc::slot<int(int)> setter = sigc::mem_fun(a2, &A::foo);
sig.connect(sigc::compose(setter, &foo));
- result_stream << "sig is connected to compose(slot1(A::foo), foo) (size=" << sig.size() << "): ";
+ result_stream << "sig is connected to compose(slot1(A::foo), foo) (size=" << sig.size()
+ << "): ";
sig(9);
- util->check_result(result_stream, "sig is connected to compose(slot1(A::foo), foo) (size=1): foo(9)
A::foo(1) ");
+ util->check_result(
+ result_stream, "sig is connected to compose(slot1(A::foo), foo) (size=1): foo(9) A::foo(1) ");
}
result_stream << "sig is empty (size=" << sig.size() << "): ";
sig(10);
@@ -155,7 +157,8 @@ int main(int argc, char* argv[])
sig.connect(sigc::compose(setter, &foo));
result_stream << "sig is connected to compose(slot(A::foo), foo) (size=" << sig.size() << "): ";
sig(11);
- util->check_result(result_stream, "sig is connected to compose(slot(A::foo), foo) (size=1): foo(11)
A::foo(1) ");
+ util->check_result(
+ result_stream, "sig is connected to compose(slot(A::foo), foo) (size=1): foo(11) A::foo(1) ");
}
result_stream << "sig is empty (size=" << sig.size() << "): ";
sig(12);
diff --git a/tests/test_disconnect_during_emit.cc b/tests/test_disconnect_during_emit.cc
index b610936..1ea02ad 100644
--- a/tests/test_disconnect_during_emit.cc
+++ b/tests/test_disconnect_during_emit.cc
@@ -29,7 +29,8 @@ public:
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_exception_catch.cc b/tests/test_exception_catch.cc
index a2838df..b8befd8 100644
--- a/tests/test_exception_catch.cc
+++ b/tests/test_exception_catch.cc
@@ -82,7 +82,8 @@ struct my_catch_void
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_functor_trait.cc b/tests/test_functor_trait.cc
index c14a126..fe1cf6d 100644
--- a/tests/test_functor_trait.cc
+++ b/tests/test_functor_trait.cc
@@ -15,47 +15,37 @@ namespace
{
std::ostringstream result_stream;
-class trackable {};
+class trackable
+{
+};
-struct A : public trackable { A() {} };
+struct A : public trackable
+{
+ A() {}
+};
-template <class T_type, bool I_derived = std::is_base_of<trackable,T_type>::value>
+template <class T_type, bool I_derived = std::is_base_of<trackable, T_type>::value>
struct with_trackable;
template <class T_type>
-struct with_trackable<T_type,false>
+struct with_trackable<T_type, false>
{
- static void perform(const T_type&)
- {
- result_stream << "other ";
- }
+ static void perform(const T_type&) { result_stream << "other "; }
};
template <class T_type>
-struct with_trackable<T_type,true>
+struct with_trackable<T_type, true>
{
- static void perform(const T_type&)
- {
- result_stream << "trackable ";
- }
+ static void perform(const T_type&) { result_stream << "trackable "; }
- static void perform(T_type*)
- {
- result_stream << "trackable* ";
- }
+ static void perform(T_type*) { result_stream << "trackable* "; }
- static void perform(const T_type*)
- {
- result_stream << "const trackable* ";
- }
+ static void perform(const T_type*) { result_stream << "const trackable* "; }
};
struct print
{
- void operator()(int i) const
- {
- result_stream << "int: " << i << " ";
- }
+ void operator()(int i) const { result_stream << "int: " << i << " "; }
template <class T>
void operator()(const T& t) const
@@ -64,15 +54,20 @@ struct print
}
};
-void foo(int, int, int)
-{}
+void
+foo(int, int, int)
+{
+}
-void bar(int)
-{}
+void
+bar(int)
+{
+}
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -84,15 +79,18 @@ int main(int argc, char* argv[])
int k = 3;
A a;
result_stream << "hit all targets: ";
- sigc::visit_each(print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), i),
sigc::ptr_fun(&bar)));
+ sigc::visit_each(
+ print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), i), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all targets: other trackable int: 1 other ");
result_stream << "hit all ints: ";
- sigc::visit_each_type<int>(print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a),
j),sigc::ptr_fun(&bar)));
+ sigc::visit_each_type<int>(
+ print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), j), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all ints: int: 2 ");
result_stream << "hit all trackable: ";
- sigc::visit_each_type<trackable>(print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a),
k),sigc::ptr_fun(&bar)));
+ sigc::visit_each_type<trackable>(
+ print(), sigc::compose(sigc::bind(sigc::ptr_fun(&foo), std::ref(a), k), sigc::ptr_fun(&bar)));
util->check_result(result_stream, "hit all trackable: trackable ");
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/test_hide.cc b/tests/test_hide.cc
index 32a2a3a..7f67688 100644
--- a/tests/test_hide.cc
+++ b/tests/test_hide.cc
@@ -34,17 +34,18 @@ struct foo_void : public sigc::functor_base
{
using result_type = void;
- void operator()()
- {
- result_stream << "foo_void()";
- }
+ void operator()() { result_stream << "foo_void()"; }
};
} // end anonymous namespace
-namespace sigc { SIGC_FUNCTOR_TRAIT(foo,bool) }
+namespace sigc
+{
+SIGC_FUNCTOR_TRAIT(foo, bool)
+}
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_limit_reference.cc b/tests/test_limit_reference.cc
index 33d019b..5102497 100644
--- a/tests/test_limit_reference.cc
+++ b/tests/test_limit_reference.cc
@@ -8,32 +8,26 @@ namespace
{
std::ostringstream result_stream;
-class Base
- : virtual public sigc::trackable
+class Base : virtual public sigc::trackable
{
};
class Base2
{
public:
- virtual ~Base2()
- {}
+ virtual ~Base2() {}
};
-class Derived
- : virtual public Base,
- public Base2
+class Derived : virtual public Base, public Base2
{
public:
- void method()
- {
- result_stream << "method()";
- }
+ void method() { result_stream << "method()"; }
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -45,13 +39,11 @@ int main(int argc, char* argv[])
handler();
util->check_result(result_stream, "method()");
- auto param =
- sigc::bind(sigc::slot<void(Derived&)>(), std::ref(*instance));
+ auto param = sigc::bind(sigc::slot<void(Derived&)>(), std::ref(*instance));
param();
util->check_result(result_stream, "");
- auto ret =
- sigc::bind_return(sigc::slot<void()>(), std::ref(*instance));
+ auto ret = sigc::bind_return(sigc::slot<void()>(), std::ref(*instance));
ret();
util->check_result(result_stream, "");
diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc
index 2d49be3..968fe24 100644
--- a/tests/test_mem_fun.cc
+++ b/tests/test_mem_fun.cc
@@ -8,7 +8,8 @@
#include <sstream>
#include <cstdlib>
-//TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ... #endif around:
+// TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ...
+// #endif around:
#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
namespace
@@ -17,15 +18,9 @@ std::ostringstream result_stream;
struct test
{
- void foo(short i1)
- {
- result_stream << "test::foo(short " << i1 << ')';
- }
+ void foo(short i1) { result_stream << "test::foo(short " << i1 << ')'; }
- void foo_const(int i1) const
- {
- result_stream << "test::foo_const(int " << i1 << ')';
- }
+ void foo_const(int i1) const { result_stream << "test::foo_const(int " << i1 << ')'; }
void foo_volatile(float i1) volatile
{
@@ -37,10 +32,7 @@ struct test
result_stream << "test::foo_const_volatile(double " << i1 << ')';
}
- void foo_overloaded(char i1)
- {
- result_stream << "test::foo_overloaded(char " << int(i1) << ')';
- }
+ void foo_overloaded(char i1) { result_stream << "test::foo_overloaded(char " << int(i1) << ')'; }
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
void foo_overloaded(short i1)
@@ -58,7 +50,8 @@ struct test
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -67,47 +60,47 @@ int main(int argc, char* argv[])
{ /* test non-const */
test t;
- sigc::mem_fun(&test::foo)(t, 1);
+ sigc::mem_fun (&test::foo)(t, 1);
util->check_result(result_stream, "test::foo(short 1)");
}
{ /* test const */
test t;
- sigc::mem_fun(&test::foo_const)(t, 2);
+ sigc::mem_fun (&test::foo_const)(t, 2);
util->check_result(result_stream, "test::foo_const(int 2)");
}
{ /* test const with const object */
const auto t = test();
- sigc::mem_fun(&test::foo_const)(t, 3);
+ sigc::mem_fun (&test::foo_const)(t, 3);
util->check_result(result_stream, "test::foo_const(int 3)");
}
{ /* test non-const volatile */
test t;
- sigc::mem_fun(&test::foo_volatile)(t, 4);
+ sigc::mem_fun (&test::foo_volatile)(t, 4);
util->check_result(result_stream, "test::foo_volatile(float 4)");
}
{ /* test const volatile */
test t;
- sigc::mem_fun(&test::foo_const_volatile)(t, 5);
+ sigc::mem_fun (&test::foo_const_volatile)(t, 5);
util->check_result(result_stream, "test::foo_const_volatile(double 5)");
}
{ /* test const volatile with const object */
const auto t = test();
- sigc::mem_fun(&test::foo_const_volatile)(t, 6);
+ sigc::mem_fun (&test::foo_const_volatile)(t, 6);
util->check_result(result_stream, "test::foo_const_volatile(double 6)");
}
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
{ /* test overloaded */
test t;
- sigc::mem_fun<char>(&test::foo_overloaded)(t, 7);
+ sigc::mem_fun<char> (&test::foo_overloaded)(t, 7);
util->check_result(result_stream, "test::foo_overloaded(char 7)");
- sigc::mem_fun<short>(&test::foo_overloaded)(t, 7);
+ sigc::mem_fun<short> (&test::foo_overloaded)(t, 7);
util->check_result(result_stream, "test::foo_overloaded(short 7)");
- //sigc::mem_fun(&test::foo_overloaded)(t, 7);
- //util->check_result(result_stream, "test::foo_overloaded(short 7)");
+ // sigc::mem_fun(&test::foo_overloaded)(t, 7);
+ // util->check_result(result_stream, "test::foo_overloaded(short 7)");
- sigc::mem_fun(&test::foo_overloaded)(t, 7, 8);
+ sigc::mem_fun (&test::foo_overloaded)(t, 7, 8);
util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
}
#endif
diff --git a/tests/test_member_method_trait.cc b/tests/test_member_method_trait.cc
index 8c9a7ba..1e48e0c 100644
--- a/tests/test_member_method_trait.cc
+++ b/tests/test_member_method_trait.cc
@@ -9,80 +9,87 @@
namespace
{
-class Something {
+class Something
+{
public:
- void some_func(int) { }
+ void some_func(int) {}
- void some_const_func(int) const { }
+ void some_const_func(int) const {}
- void some_volatile_func(int) volatile { }
+ void some_volatile_func(int) volatile {}
- void some_const_volatile_func(int) const volatile { }
+ void some_const_volatile_func(int) const volatile {}
- int some_int_func() {
- return 1;
- }
+ int some_int_func() { return 1; }
- bool some_bool_func()
- {
- return true;
- }
+ bool some_bool_func() { return true; }
};
} // end anonymous namespace
-void test_member_method_is_const()
+void
+test_member_method_is_const()
{
static_assert(!sigc::internal::member_method_is_const<decltype(&Something::some_func)>::value,
"member_method_is_const failed to identify a non-const member method.");
- static_assert(!sigc::internal::member_method_is_const<decltype(&Something::some_volatile_func)>::value,
+ static_assert(
+ !sigc::internal::member_method_is_const<decltype(&Something::some_volatile_func)>::value,
"member_method_is_const failed to identify a non-const member method.");
- static_assert(sigc::internal::member_method_is_const<decltype(&Something::some_const_func)>::value,
+ static_assert(
+ sigc::internal::member_method_is_const<decltype(&Something::some_const_func)>::value,
"member_method_is_const failed to identify a const member method.");
-
static_assert(sigc::internal::member_method_is_const<decltype(&Something::some_const_volatile_func)>::value,
+ static_assert(
+ sigc::internal::member_method_is_const<decltype(&Something::some_const_volatile_func)>::value,
"member_method_is_const failed to identify a const member method.");
}
-void test_member_method_is_volatile()
+void
+test_member_method_is_volatile()
{
static_assert(!sigc::internal::member_method_is_volatile<decltype(&Something::some_func)>::value,
"member_method_is_const failed to identify a non-volatile member method.");
- static_assert(!sigc::internal::member_method_is_volatile<decltype(&Something::some_const_func)>::value,
+ static_assert(
+ !sigc::internal::member_method_is_volatile<decltype(&Something::some_const_func)>::value,
"member_method_is_const failed to identify a non-volatile member method.");
- static_assert(sigc::internal::member_method_is_volatile<decltype(&Something::some_volatile_func)>::value,
+ static_assert(
+ sigc::internal::member_method_is_volatile<decltype(&Something::some_volatile_func)>::value,
"member_method_is_const failed to identify a volatile member method.");
-
static_assert(sigc::internal::member_method_is_volatile<decltype(&Something::some_const_volatile_func)>::value,
+ static_assert(sigc::internal::member_method_is_volatile<decltype(
+ &Something::some_const_volatile_func)>::value,
"member_method_is_const failed to identify a volatile member method.");
}
-void test_member_method_class_type()
+void
+test_member_method_class_type()
{
- static_assert(std::is_same<
- sigc::internal::member_method_class<decltype(&Something::some_func)>::type,
- Something>::value,
+ static_assert(
+ std::is_same<sigc::internal::member_method_class<decltype(&Something::some_func)>::type,
+ Something>::value,
"member_method_class_type failed to identify the class type.");
}
-void test_member_method_result_type()
+void
+test_member_method_result_type()
{
- static_assert(std::is_same<
- sigc::internal::member_method_result<decltype(&Something::some_int_func)>::type,
- int>::value,
+ static_assert(
+ std::is_same<sigc::internal::member_method_result<decltype(&Something::some_int_func)>::type,
+ int>::value,
"member_method_result_type failed to identify the result type.");
- static_assert(std::is_same<
- sigc::internal::member_method_result<decltype(&Something::some_bool_func)>::type,
- bool>::value,
+ static_assert(
+ std::is_same<sigc::internal::member_method_result<decltype(&Something::some_bool_func)>::type,
+ bool>::value,
"member_method_result_type failed to identify the result type.");
}
-int main()
+int
+main()
{
test_member_method_is_const();
test_member_method_is_volatile();
diff --git a/tests/test_ptr_fun.cc b/tests/test_ptr_fun.cc
index 2ec9c0c..16c63d7 100644
--- a/tests/test_ptr_fun.cc
+++ b/tests/test_ptr_fun.cc
@@ -8,15 +8,15 @@
#include <sigc++/sigc++.h>
#include <cstdlib>
-//TODO: put something like #ifndef FORTE ... #else ... #endif around:
+// TODO: put something like #ifndef FORTE ... #else ... #endif around:
#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
namespace
{
std::ostringstream result_stream;
-//TODO: This works with clang++ (when we specify the return type, such as
-//int or void, but doesn't work with g++.
+// TODO: This works with clang++ (when we specify the return type, such as
+// int or void, but doesn't work with g++.
/*
int foo()
{
@@ -25,20 +25,22 @@ int foo()
}
*/
-void foo(int i1)
+void
+foo(int i1)
{
result_stream << "foo(int " << i1 << ")";
}
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
-void bar(char i1)
+void
+bar(char i1)
{
result_stream << "bar(char " << (int)i1 << ")";
}
#endif
-//TODO: This works with clang++ (when we specify the return type, such as
-//int or void, but doesn't work with g++.
+// TODO: This works with clang++ (when we specify the return type, such as
+// int or void, but doesn't work with g++.
/*
void bar(float i1)
{
@@ -46,7 +48,8 @@ void bar(float i1)
}
*/
-double bar(int i1, int i2)
+double
+bar(int i1, int i2)
{
result_stream << "bar(int " << i1 << ", int " << i2 << ")";
return 1.0f;
@@ -54,49 +57,47 @@ double bar(int i1, int i2)
struct test
{
- static void foo()
- {
- result_stream << "test::foo()";
- }
+ static void foo() { result_stream << "test::foo()"; }
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
- //Test use of overloaded functions that differ by number of parameters
- //and by return type
- //TODO: This works with clang++ (when we specify the return type, such as
- //int or void, but doesn't work with g++.
- //sigc::ptr_fun<int>(&foo)();
- //util->check_result(result_stream, "foo()");
+ // Test use of overloaded functions that differ by number of parameters
+ // and by return type
+ // TODO: This works with clang++ (when we specify the return type, such as
+ // int or void, but doesn't work with g++.
+ // sigc::ptr_fun<int>(&foo)();
+ // util->check_result(result_stream, "foo()");
- sigc::ptr_fun<void>(&foo)(1);
+ sigc::ptr_fun<void> (&foo)(1);
util->check_result(result_stream, "foo(int 1)");
- //Test use of overloaded functions that differ by parameter type:
+// Test use of overloaded functions that differ by parameter type:
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
- sigc::ptr_fun<void, char>(&bar)(2);
+ sigc::ptr_fun<void, char> (&bar)(2);
util->check_result(result_stream, "bar(char 2)");
- sigc::ptr_fun<void, float>(&bar)(2.0f);
+ sigc::ptr_fun<void, float> (&bar)(2.0f);
util->check_result(result_stream, "bar(float 2)");
#else
- //TODO: This works with clang++ (when we specify the return type, such as
- //int or void, but doesn't work with g++.
- //sigc::ptr_fun<void>(&bar)(2.0f);
- //util->check_result(result_stream, "bar(float 2)");
+// TODO: This works with clang++ (when we specify the return type, such as
+// int or void, but doesn't work with g++.
+// sigc::ptr_fun<void>(&bar)(2.0f);
+// util->check_result(result_stream, "bar(float 2)");
#endif
- sigc::ptr_fun<double>(&bar)(3, 5);
+ sigc::ptr_fun<double> (&bar)(3, 5);
util->check_result(result_stream, "bar(int 3, int 5)");
- sigc::ptr_fun(&test::foo)();
+ sigc::ptr_fun (&test::foo)();
util->check_result(result_stream, "test::foo()");
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/test_retype.cc b/tests/test_retype.cc
index 1dbb785..24f11d1 100644
--- a/tests/test_retype.cc
+++ b/tests/test_retype.cc
@@ -29,32 +29,37 @@ struct foo : public sigc::trackable
}
};
-void bar(short s)
+void
+bar(short s)
{
result_stream << "bar(short " << s << ")";
}
-void test_member_int()
+void
+test_member_int()
{
foo foo_;
result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_int))(1.234f);
util->check_result(result_stream, "foo::test_int(int 1) 1.5");
}
-void test_member_float()
+void
+test_member_float()
{
foo foo_;
result_stream << sigc::retype(sigc::mem_fun(foo_, &foo::test_float))(5);
util->check_result(result_stream, "foo::test_float(float 5) 25");
}
-void test_ptr_fun()
+void
+test_ptr_fun()
{
sigc::retype(sigc::ptr_fun(&bar))(6.789f);
util->check_result(result_stream, "bar(short 6)");
}
-void test_member_int_with_slot()
+void
+test_member_int_with_slot()
{
foo foo_;
sigc::slot<float(float)> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
@@ -62,7 +67,8 @@ void test_member_int_with_slot()
util->check_result(result_stream, "foo::test_int(int 1) 1.5");
}
-void test_member_float_with_slot()
+void
+test_member_float_with_slot()
{
foo foo_;
sigc::slot<float(int)> s2 = sigc::retype(sigc::mem_fun(foo_, &foo::test_float));
@@ -70,14 +76,16 @@ void test_member_float_with_slot()
util->check_result(result_stream, "foo::test_float(float 5) 25");
}
-void test_ptr_fun_with_slot()
+void
+test_ptr_fun_with_slot()
{
sigc::slot<void(double)> s3 = sigc::retype(sigc::ptr_fun(&bar));
s3(6.789);
util->check_result(result_stream, "bar(short 6)");
}
-void test_retype_slot()
+void
+test_retype_slot()
{
foo foo_;
sigc::slot<float(float)> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
@@ -88,7 +96,8 @@ void test_retype_slot()
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
util = TestUtilities::get_instance();
diff --git a/tests/test_retype_return.cc b/tests/test_retype_return.cc
index 2d02cac..99ddd0a 100644
--- a/tests/test_retype_return.cc
+++ b/tests/test_retype_return.cc
@@ -43,7 +43,8 @@ struct bar : public sigc::trackable, public sigc::functor_base
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_signal.cc b/tests/test_signal.cc
index e95bd6e..2ad67f6 100644
--- a/tests/test_signal.cc
+++ b/tests/test_signal.cc
@@ -17,7 +17,8 @@ namespace
TestUtilities* util = nullptr;
std::ostringstream result_stream;
-int foo(int i)
+int
+foo(int i)
{
result_stream << "foo(int " << i << ") ";
return 1;
@@ -38,7 +39,8 @@ struct A : public sigc::trackable
}
};
-void test_empty_signal()
+void
+test_empty_signal()
{
// signal
sigc::signal<int(int)> sig;
@@ -48,7 +50,8 @@ void test_empty_signal()
util->check_result(result_stream, "");
}
-void test_simple()
+void
+test_simple()
{
sigc::signal<int(int)> sig;
sig.connect(sigc::ptr_fun(&foo));
@@ -57,13 +60,15 @@ void test_simple()
util->check_result(result_stream, "foo(int 1) ");
}
-int bar(float i)
+int
+bar(float i)
{
result_stream << "bar(float " << i << ") ";
return 1;
}
-void test_auto_disconnection()
+void
+test_auto_disconnection()
{
// signal
sigc::signal<int(int)> sig;
@@ -85,7 +90,8 @@ void test_auto_disconnection()
util->check_result(result_stream, "foo(int 2) bar(float 2) 2");
}
-void test_reference()
+void
+test_reference()
{
// test reference
A a;
@@ -97,7 +103,8 @@ void test_reference()
util->check_result(result_stream, "A::foo(string 'guest book') foo was here");
}
-void test_make_slot()
+void
+test_make_slot()
{
// test make_slot()
sigc::signal<int(int)> sig;
@@ -112,7 +119,8 @@ void test_make_slot()
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
util = TestUtilities::get_instance();
diff --git a/tests/test_signal_move.cc b/tests/test_signal_move.cc
index cd9e69f..85f1199 100644
--- a/tests/test_signal_move.cc
+++ b/tests/test_signal_move.cc
@@ -14,7 +14,8 @@ namespace
{
std::ostringstream result_stream;
-int foo(int i)
+int
+foo(int i)
{
result_stream << "foo(int " << i << ")";
return 1;
@@ -22,7 +23,8 @@ int foo(int i)
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -35,13 +37,13 @@ int main(int argc, char* argv[])
sig(1);
util->check_result(result_stream, "foo(int 1)");
- //Test the move constructor:
+ // Test the move constructor:
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:
+ // Test the move assignment operator:
sigc::signal<int(int)> sig3;
sig3 = std::move(sig2);
sig2(-3);
diff --git a/tests/test_size.cc b/tests/test_size.cc
index 9aeecb0..d68cfa8 100644
--- a/tests/test_size.cc
+++ b/tests/test_size.cc
@@ -21,7 +21,8 @@ struct A
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -35,16 +36,20 @@ 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()>::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;
- std::cout << " trackable_callback: " << sizeof(sigc::internal::trackable_callback) << std::endl;
- std::cout << " trackable_callback_list: " << sizeof(sigc::internal::trackable_callback_list) <<
std::endl;
+ std::cout << " trackable_callback: " << sizeof(sigc::internal::trackable_callback)
+ << std::endl;
+ std::cout << " trackable_callback_list: " << sizeof(sigc::internal::trackable_callback_list)
+ << std::endl;
std::cout << " slot_rep: " << sizeof(sigc::internal::slot_rep) << std::endl;
std::cout << " typed_slot_rep<mem_functor<void,A> >: "
- << sizeof(sigc::internal::typed_slot_rep<sigc::mem_functor<void (A::*)()> >) << std::endl;
+ << sizeof(sigc::internal::typed_slot_rep<sigc::mem_functor<void (A::*)()>>)
+ << std::endl;
std::cout << " signal_impl: " << sizeof(sigc::internal::signal_impl) << std::endl;
}
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/test_slot.cc b/tests/test_slot.cc
index d9a5385..87080e9 100644
--- a/tests/test_slot.cc
+++ b/tests/test_slot.cc
@@ -8,8 +8,8 @@
#include <string>
#include <cstdlib>
-//The Tru64 compiler seems to need this to avoid an unresolved symbol
-//See bug #161503
+// The Tru64 compiler seems to need this to avoid an unresolved symbol
+// See bug #161503
#include <new>
namespace
@@ -21,24 +21,19 @@ std::ostringstream result_stream;
class foo
{
public:
- void operator()(int i)
- {
- result_stream << "foo(int " << i << ")";
- }
+ void operator()(int i) { result_stream << "foo(int " << i << ")"; }
void operator()(std::string& str)
{
result_stream << "foo(string '" << str << "') ";
- str="foo was here";
+ str = "foo was here";
}
- void operator()(int, int)
- {
- result_stream << "foo(int, int)";
- }
+ void operator()(int, int) { result_stream << "foo(int, int)"; }
};
-void test_simple()
+void
+test_simple()
{
// simple test
sigc::slot<void(int)> s1 = foo();
@@ -50,7 +45,8 @@ void test_simple()
util->check_result(result_stream, "foo(int 2)");
}
-void test_implicit_conversion()
+void
+test_implicit_conversion()
{
// test implicit conversion
sigc::slot<void(char)> s2 = foo();
@@ -58,7 +54,8 @@ void test_implicit_conversion()
util->check_result(result_stream, "foo(int 3)");
}
-void test_reference()
+void
+test_reference()
{
// test reference
sigc::slot<void(std::string&)> sl1 = foo();
@@ -68,7 +65,8 @@ void test_reference()
util->check_result(result_stream, "foo(string 'guest book') foo was here");
}
-void test_operator_equals()
+void
+test_operator_equals()
{
// test operator=
std::string str = "guest book";
@@ -81,7 +79,8 @@ void test_operator_equals()
util->check_result(result_stream, "foo(string 'guest book') foo was here");
}
-void test_copy_ctor()
+void
+test_copy_ctor()
{
// test copy ctor
sigc::slot<void(int)> s1 = foo();
@@ -92,7 +91,8 @@ void test_copy_ctor()
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
util = TestUtilities::get_instance();
diff --git a/tests/test_slot_disconnect.cc b/tests/test_slot_disconnect.cc
index 12171a6..e0af085 100644
--- a/tests/test_slot_disconnect.cc
+++ b/tests/test_slot_disconnect.cc
@@ -12,26 +12,29 @@ namespace
{
std::ostringstream result_stream;
-void Foo()
+void
+Foo()
{
result_stream << "Foo";
}
-void Bar()
+void
+Bar()
{
result_stream << "Bar";
}
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
- //Note that sigc::ptr_fun() creates a sig::pointer_functor.
+ // Note that sigc::ptr_fun() creates a sig::pointer_functor.
sigc::slot<void()> theSlot(sigc::ptr_fun(&Foo));
theSlot();
util->check_result(result_stream, "Foo");
diff --git a/tests/test_slot_move.cc b/tests/test_slot_move.cc
index b35853f..7785867 100644
--- a/tests/test_slot_move.cc
+++ b/tests/test_slot_move.cc
@@ -8,8 +8,8 @@
#include <string>
#include <cstdlib>
-//The Tru64 compiler seems to need this to avoid an unresolved symbol
-//See bug #161503
+// The Tru64 compiler seems to need this to avoid an unresolved symbol
+// See bug #161503
#include <new>
namespace
@@ -19,26 +19,21 @@ std::ostringstream result_stream;
class foo
{
public:
- void operator()(int i)
- {
- result_stream << "foo(int " << i << ")";
- }
+ void operator()(int i) { result_stream << "foo(int " << i << ")"; }
void operator()(std::string& str)
{
result_stream << "foo(string '" << str << "') ";
- str="foo was here";
+ str = "foo was here";
}
- void operator()(int, int)
- {
- result_stream << "foo(int, int)";
- }
+ void operator()(int, int) { result_stream << "foo(int, int)"; }
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index e305062..afe3af9 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -33,7 +33,6 @@
// echo $?
// If test_track_obj writes nothing and the return code is 0, the test has passed.
-
#include "testutilities.h"
#include <string>
#include <iostream>
@@ -42,7 +41,6 @@
#include <sigc++/adaptors/track_obj.h>
#include <sigc++/signal.h>
-
namespace
{
std::ostringstream result_stream;
@@ -50,8 +48,8 @@ std::ostringstream result_stream;
struct book : public sigc::trackable
{
explicit book(const std::string& name) : name_(name) {}
- operator std::string& () { return name_; }
- operator const std::string& () const { return name_; }
+ operator std::string&() { return name_; }
+ operator const std::string&() const { return name_; }
std::string name_;
};
@@ -64,13 +62,9 @@ class Functor1 : public sigc::functor_base
public:
using result_type = std::string;
- Functor1(const bar_group4& bar)
- : bar_(bar) {}
+ Functor1(const bar_group4& bar) : bar_(bar) {}
- std::string operator()(int i)
- {
- return (i<0) ? "negative" : ((i>0) ? "positive" : "zero");
- }
+ std::string operator()(int i) { return (i < 0) ? "negative" : ((i > 0) ? "positive" : "zero"); }
private:
const bar_group4& bar_;
@@ -81,12 +75,11 @@ class Functor2 : public sigc::functor_base
public:
using result_type = std::string;
- Functor2(const bar_group4& bar, const book& aBook)
- : bar_(bar), aBook_(aBook) {}
+ Functor2(const bar_group4& bar, const book& aBook) : bar_(bar), aBook_(aBook) {}
std::string operator()(int i, const std::string& str) const
{
- std::string result = (i<0) ? "negative, " : ((i>0) ? "positive, " : "zero, ");
+ std::string result = (i < 0) ? "negative, " : ((i > 0) ? "positive, " : "zero, ");
result += str;
result += aBook_;
return result;
@@ -97,29 +90,32 @@ private:
const book& aBook_;
};
-//C++11 lamba expressions:
+// C++11 lamba expressions:
-inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
+inline std::ostringstream&
+operator<<(std::ostringstream& s, const book& b)
{
s << b.name_;
return s;
}
-void egon(std::string& str)
+void
+egon(std::string& str)
{
result_stream << "egon(string '" << str << "')";
str = "egon was here";
}
-void foo_group4(bar_group4&)
+void
+foo_group4(bar_group4&)
{
result_stream << "foo_group4(bar_group4&)";
}
} // end anonymous namespace
-
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -156,8 +152,7 @@ int main(int argc, char* argv[])
delete pbar4;
pbar4 = nullptr;
-
-//C++11 lambda expressions:
+ // C++11 lambda expressions:
// auto-disconnect
// If you want to auto-disconnect a slot with a C++11 lambda expression
@@ -166,8 +161,10 @@ int main(int argc, char* argv[])
sigc::slot<void(std::ostringstream&)> sl10;
{
book guest_book("karl");
- // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no
auto-disconnect
- sl10 = sigc::track_obj([&guest_book](std::ostringstream& stream){ stream << guest_book; }, guest_book);
+ // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no
+ // auto-disconnect
+ sl10 = sigc::track_obj(
+ [&guest_book](std::ostringstream& stream) { stream << guest_book; }, guest_book);
sl10(result_stream);
util->check_result(result_stream, "karl");
@@ -182,7 +179,7 @@ int main(int argc, char* argv[])
book guest_book("karl");
// sl2 = [&guest_book] () { egon(guest_book); }; // no auto-disconnect
// sl2 = std::bind(&egon, std::ref(guest_book)); // does not compile (gcc 4.6.3)
- sl20 = sigc::track_obj([&guest_book] () { egon(guest_book); }, guest_book);
+ sl20 = sigc::track_obj([&guest_book]() { egon(guest_book); }, guest_book);
sl20();
util->check_result(result_stream, "egon(string 'karl')");
@@ -194,19 +191,19 @@ int main(int argc, char* argv[])
sl20();
util->check_result(result_stream, "");
-
// Code example in the documentation sigc++/adaptors/macros/track_obj.h.m4
// -----------------------------------------------------------------------
{
- //struct bar : public sigc::trackable {} some_bar;
+ // struct bar : public sigc::trackable {} some_bar;
sigc::signal<void()> some_signal;
{
bar_group4 some_bar;
- //some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
+ // some_signal.connect(sigc::group(&foo, std::ref(some_bar)));
// disconnected automatically if some_bar goes out of scope
- //some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
- //some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but we prefer
C++11 lambda
- some_signal.connect(sigc::track_obj([&some_bar](){ foo_group4(some_bar); }, some_bar));
+ // some_signal.connect([&some_bar](){ foo_group4(some_bar); }); // no auto-disconnect
+ // some_signal.connect(sigc::bind(&foo_group4, std::ref(some_bar))); // auto-disconnects, but
+ // we prefer C++11 lambda
+ some_signal.connect(sigc::track_obj([&some_bar]() { foo_group4(some_bar); }, some_bar));
some_signal.emit();
util->check_result(result_stream, "foo_group4(bar_group4&)");
@@ -216,6 +213,5 @@ int main(int argc, char* argv[])
util->check_result(result_stream, "");
}
-
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/test_trackable.cc b/tests/test_trackable.cc
index daba58b..2886a9c 100644
--- a/tests/test_trackable.cc
+++ b/tests/test_trackable.cc
@@ -14,20 +14,18 @@ namespace
{
std::ostringstream result_stream;
-class my_class: public sigc::trackable
+class my_class : public sigc::trackable
{
public:
int i;
- void foo()
- {
- result_stream << i;
- }
+ void foo() { result_stream << i; }
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/test_trackable_move.cc b/tests/test_trackable_move.cc
index 664f769..b0208b6 100644
--- a/tests/test_trackable_move.cc
+++ b/tests/test_trackable_move.cc
@@ -14,23 +14,15 @@ namespace
{
std::ostringstream result_stream;
-class my_class: public sigc::trackable
+class my_class : public sigc::trackable
{
public:
-
- my_class()
- : i(0)
- {}
+ my_class() : i(0) {}
my_class(const my_class& src) = delete;
my_class& operator=(const my_class& src) = delete;
- my_class(my_class&& src)
- : sigc::trackable(std::move(src)),
- i(std::move(src.i))
- {
- src.i = 0;
- }
+ my_class(my_class&& src) : sigc::trackable(std::move(src)), i(std::move(src.i)) { src.i = 0; }
my_class& operator=(my_class&& src)
{
@@ -40,17 +32,15 @@ public:
return *this;
}
- void foo()
- {
- result_stream << i;
- }
+ void foo() { result_stream << i; }
int i;
};
} // end anonymous namespace
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
@@ -65,7 +55,7 @@ int main(int argc, char* argv[])
sl();
util->check_result(result_stream, "10");
- //Create another trackable via a move:
+ // Create another trackable via a move:
my_class t2(std::move(t));
t2.i = 15;
result_stream.clear();
diff --git a/tests/test_tuple_cdr.cc b/tests/test_tuple_cdr.cc
index 028a15f..e6355bf 100644
--- a/tests/test_tuple_cdr.cc
+++ b/tests/test_tuple_cdr.cc
@@ -21,66 +21,67 @@
#include <functional>
void
-test_tuple_type_cdr() {
+test_tuple_type_cdr()
+{
using type_tuple_isd = std::tuple<int, short, double>;
using type_tuple_sd = std::tuple<short, double>;
using type_tuple_suffix = sigc::internal::tuple_type_cdr<type_tuple_isd>::type;
- static_assert(std::tuple_size<type_tuple_suffix>::value == 2,
- "unexpected tuple_cdr()ed tuple size.");
- static_assert(std::is_same<type_tuple_suffix, type_tuple_sd>::value,
- "unexpected tuple_cdr()ed tuple type");
+ static_assert(
+ std::tuple_size<type_tuple_suffix>::value == 2, "unexpected tuple_cdr()ed tuple size.");
+ static_assert(
+ std::is_same<type_tuple_suffix, type_tuple_sd>::value, "unexpected tuple_cdr()ed tuple type");
}
void
-test_tuple_cdr() {
- auto t_larger =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+test_tuple_cdr()
+{
+ auto t_larger = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_suffix = sigc::internal::tuple_cdr(t_larger);
assert(std::get<0>(t_suffix) == "hello");
assert(std::get<1>(t_suffix) == "world");
using type_tuple_suffix = std::tuple<std::string, std::string>;
- static_assert(std::tuple_size<decltype(t_suffix)>::value == 2,
- "unexpected cdr()ed tuple size.");
- static_assert(std::is_same<decltype(t_suffix), type_tuple_suffix>::value,
- "unexpected cdr()ed tuple type");
+ static_assert(std::tuple_size<decltype(t_suffix)>::value == 2, "unexpected cdr()ed tuple size.");
+ static_assert(
+ std::is_same<decltype(t_suffix), type_tuple_suffix>::value, "unexpected cdr()ed tuple type");
}
void
-test_tuple_cdr_stdref() {
+test_tuple_cdr_stdref()
+{
std::string b = "yadda";
std::string c = "yaddayadda";
auto t_larger = std::make_tuple(1, std::ref(b), std::ref(c));
- //std::cout << "debug: " << type(std::get<1>(t_larger)) << std::endl;
+ // std::cout << "debug: " << type(std::get<1>(t_larger)) << std::endl;
auto t_suffix = sigc::internal::tuple_cdr(t_larger);
b = "hello";
c = "world";
- //This works, but it's not what we are testing here:
- //assert(std::get<1>(t_larger) == "hello");
+ // This works, but it's not what we are testing here:
+ // assert(std::get<1>(t_larger) == "hello");
assert(std::get<0>(t_suffix) == "hello");
assert(std::get<1>(t_suffix) == "world");
}
-constexpr
-void
-test_tuple_cdr_constexpr() {
+constexpr void
+test_tuple_cdr_constexpr()
+{
constexpr auto str_hello = "hello";
constexpr auto str_world = "world";
- constexpr auto t_larger =
- std::make_tuple(nullptr, str_hello, str_world);
+ constexpr auto t_larger = std::make_tuple(nullptr, str_hello, str_world);
constexpr auto t_suffix = sigc::internal::tuple_cdr(t_larger);
assert(std::get<0>(t_suffix) == str_hello);
assert(std::get<1>(t_suffix) == str_world);
}
int
-main() {
+main()
+{
test_tuple_type_cdr();
test_tuple_cdr();
test_tuple_cdr_stdref();
diff --git a/tests/test_tuple_end.cc b/tests/test_tuple_end.cc
index 66635f3..dcd4008 100644
--- a/tests/test_tuple_end.cc
+++ b/tests/test_tuple_end.cc
@@ -20,14 +20,14 @@
#include <functional>
void
-test_tuple_end() {
+test_tuple_end()
+{
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_suffix = sigc::internal::tuple_end<3>(t_original);
- static_assert(std::tuple_size<decltype(t_suffix)>::value == 3,
- "unexpected tuple_end()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_suffix)>::value == 3, "unexpected tuple_end()ed tuple size.");
assert(std::get<0>(t_suffix) == nullptr);
assert(std::get<1>(t_suffix) == "hello");
@@ -38,39 +38,38 @@ test_tuple_end() {
}
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_suffix = sigc::internal::tuple_end<2>(t_original);
- static_assert(std::tuple_size<decltype(t_suffix)>::value == 2,
- "unexpected tuple_end()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_suffix)>::value == 2, "unexpected tuple_end()ed tuple size.");
assert(std::get<0>(t_suffix) == "hello");
assert(std::get<1>(t_suffix) == "world");
using type_tuple_suffix = std::tuple<std::string, std::string>;
- static_assert(std::is_same<decltype(t_suffix), type_tuple_suffix>::value,
- "unexpected end()ed tuple type");
+ static_assert(
+ std::is_same<decltype(t_suffix), type_tuple_suffix>::value, "unexpected end()ed tuple type");
}
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_suffix = sigc::internal::tuple_end<1>(t_original);
- static_assert(std::tuple_size<decltype(t_suffix)>::value == 1,
- "unexpected tuple_end()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_suffix)>::value == 1, "unexpected tuple_end()ed tuple size.");
assert(std::get<0>(t_suffix) == "world");
using type_tuple_suffix = std::tuple<std::string>;
- static_assert(std::is_same<decltype(t_suffix), type_tuple_suffix>::value,
- "unexpected end()ed tuple type");
+ static_assert(
+ std::is_same<decltype(t_suffix), type_tuple_suffix>::value, "unexpected end()ed tuple type");
}
}
void
-test_tuple_end_stdref() {
+test_tuple_end_stdref()
+{
std::string c = "yadda";
std::string d = "yaddayadda";
auto t_larger = std::make_tuple(1, 2, std::ref(c), std::ref(d));
@@ -78,33 +77,32 @@ test_tuple_end_stdref() {
auto t_suffix = sigc::internal::tuple_end<2>(t_larger);
c = "hello";
d = "world";
- //This works, but it's not what we are testing here:
- //assert(std::get<0>(t_larger) == "hello");
+ // This works, but it's not what we are testing here:
+ // assert(std::get<0>(t_larger) == "hello");
assert(std::get<0>(t_suffix) == "hello");
assert(std::get<1>(t_suffix) == "world");
}
-
-constexpr
-void
-test_tuple_end_constexpr() {
+constexpr void
+test_tuple_end_constexpr()
+{
constexpr auto str_hello = "hello";
constexpr auto str_world = "world";
- constexpr auto t_original =
- std::make_tuple(nullptr, str_hello, str_world);
+ constexpr auto t_original = std::make_tuple(nullptr, str_hello, str_world);
constexpr auto t_suffix = sigc::internal::tuple_end<2>(t_original);
- static_assert(std::tuple_size<decltype(t_suffix)>::value == 2,
- "unexpected tuple_end()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_suffix)>::value == 2, "unexpected tuple_end()ed tuple size.");
assert(std::get<0>(t_suffix) == str_hello);
assert(std::get<1>(t_suffix) == str_world);
}
int
-main() {
+main()
+{
test_tuple_end();
test_tuple_end_stdref();
diff --git a/tests/test_tuple_for_each.cc b/tests/test_tuple_for_each.cc
index ec5f42e..6514b57 100644
--- a/tests/test_tuple_for_each.cc
+++ b/tests/test_tuple_for_each.cc
@@ -23,16 +23,18 @@
#include <functional>
template <class T_element_from>
-class for_each_simple {
+class for_each_simple
+{
public:
- static void
- visit(const T_element_from& from) {
+ static void visit(const T_element_from& from)
+ {
std::cout << "for_each_simple(): " << std::to_string(from) << std::endl;
}
};
void
-test_tuple_for_each_same_types() {
+test_tuple_for_each_same_types()
+{
{
auto t_original = std::make_tuple(1, 2, 3);
sigc::internal::tuple_for_each<for_each_simple>(t_original);
@@ -45,35 +47,35 @@ test_tuple_for_each_same_types() {
}
template <class T_element_from>
-class for_each_simple_with_extras {
+class for_each_simple_with_extras
+{
public:
- static void
- visit(const T_element_from& from, int extra1, const std::string& extra2) {
+ static void visit(const T_element_from& from, int extra1, const std::string& extra2)
+ {
std::cout << "for_each_simple_with_extras(): from=" << std::to_string(from)
<< ", extra1: " << extra1 << ", extra2: " << extra2 << std::endl;
}
};
void
-test_tuple_for_each_same_types_with_extras() {
+test_tuple_for_each_same_types_with_extras()
+{
{
auto t_original = std::make_tuple(1, (double)2.1f, 3);
- sigc::internal::tuple_for_each<for_each_simple_with_extras>(
- t_original, 89, "eightynine");
+ sigc::internal::tuple_for_each<for_each_simple_with_extras>(t_original, 89, "eightynine");
}
}
template <class T_element_from>
-class for_each_simple_with_nonconst_extras {
+class for_each_simple_with_nonconst_extras
+{
public:
- static void
- visit(const T_element_from& from, int& extra) {
- extra += (int)from;
- }
+ static void visit(const T_element_from& from, int& extra) { extra += (int)from; }
};
void
-test_tuple_for_each_same_types_with_nonconst_extras() {
+test_tuple_for_each_same_types_with_nonconst_extras()
+{
{
auto t_original = std::make_tuple(1, (double)2.1f, 3);
int extra = 0;
@@ -92,66 +94,69 @@ class visitor_with_specializations;
// An int will be converted to a std::string:
template <>
-class visitor_with_specializations<int> {
+class visitor_with_specializations<int>
+{
public:
- static void
- visit(const int& from) {
- std::cout << "visitor_with_specializations::visit(): "
- << std::to_string(from) << std::endl;
+ static void visit(const int& from)
+ {
+ std::cout << "visitor_with_specializations::visit(): " << std::to_string(from) << std::endl;
}
};
// A double will be converted to a char:
template <>
-class visitor_with_specializations<double> {
+class visitor_with_specializations<double>
+{
public:
- static void
- visit(const double& from) {
- std::cout << "visitor_with_specializations::visit(): "
- << std::to_string(from)[0] << std::endl;
+ static void visit(const double& from)
+ {
+ std::cout << "visitor_with_specializations::visit(): " << std::to_string(from)[0] << std::endl;
}
};
// A std::string will be converted to an int:
template <>
-class visitor_with_specializations<std::string> {
+class visitor_with_specializations<std::string>
+{
public:
- static void
- visit(const std::string& from) {
- std::cout << "visitor_with_specializations::visit(): " << std::stoi(from)
- << std::endl;
+ static void visit(const std::string& from)
+ {
+ std::cout << "visitor_with_specializations::visit(): " << std::stoi(from) << std::endl;
}
};
// A const char* will be converted to an int:
template <>
-class visitor_with_specializations<const char*> {
+class visitor_with_specializations<const char*>
+{
public:
- static void
- visit(const char* from) {
- std::cout << "visitor_with_specializations::visit(): " << std::stoi(from)
- << std::endl;
+ static void visit(const char* from)
+ {
+ std::cout << "visitor_with_specializations::visit(): " << std::stoi(from) << std::endl;
}
};
void
-test_tuple_for_each_multiple_types() {
+test_tuple_for_each_multiple_types()
+{
auto t_original = std::make_tuple(1, (double)2.1f, std::string("3"));
sigc::internal::tuple_for_each<visitor_with_specializations>(t_original);
}
template <class T_element_from>
-class for_each_nonconst {
+class for_each_nonconst
+{
public:
- static void
- visit(T_element_from& from) {
+ static void visit(T_element_from& from)
+ {
from *= 2;
// Or, for instance, call a non-const method on from.
}
};
void
-test_tuple_for_each_nonconst() {
+test_tuple_for_each_nonconst()
+{
auto t = std::make_tuple(1, 2, 3);
sigc::internal::tuple_for_each<for_each_nonconst, decltype(t)&>(t);
std::cout << std::get<0>(t) << std::endl;
@@ -161,7 +166,8 @@ test_tuple_for_each_nonconst() {
}
void
-test_tuple_for_each_stdref() {
+test_tuple_for_each_stdref()
+{
{
int a = 1;
int b = 2;
@@ -185,39 +191,43 @@ test_tuple_for_each_stdref() {
static std::string correct_sequence_output;
template <class T_element_from>
-class for_each_correct_sequence {
+class for_each_correct_sequence
+{
public:
- static void
- visit(const T_element_from& from) {
- //std::cout << "from: " << from << std::endl;
+ static void visit(const T_element_from& from)
+ {
+ // std::cout << "from: " << from << std::endl;
correct_sequence_output += std::to_string(from);
}
};
void
-test_tuple_for_each_correct_sequence() {
+test_tuple_for_each_correct_sequence()
+{
correct_sequence_output.clear();
auto t = std::make_tuple(1, 2, 3);
sigc::internal::tuple_for_each<for_each_correct_sequence>(t);
- //std::cout << "correct_sequence_output: " << correct_sequence_output << std::endl;
+ // std::cout << "correct_sequence_output: " << correct_sequence_output << std::endl;
assert(correct_sequence_output == "123");
}
void
-test_tuple_for_each_empty_tuple() {
+test_tuple_for_each_empty_tuple()
+{
auto t = std::tuple<>();
sigc::internal::tuple_for_each<for_each_simple>(t);
}
-constexpr
-void
-test_tuple_for_each_constexpr() {
+constexpr void
+test_tuple_for_each_constexpr()
+{
constexpr auto t_original = std::make_tuple(1, (double)2.1f, "3");
sigc::internal::tuple_for_each<visitor_with_specializations>(t_original);
}
int
-main() {
+main()
+{
test_tuple_for_each_same_types();
test_tuple_for_each_same_types_with_extras();
test_tuple_for_each_same_types_with_nonconst_extras();
@@ -225,7 +235,7 @@ main() {
test_tuple_for_each_multiple_types();
test_tuple_for_each_nonconst();
-
+
test_tuple_for_each_stdref();
test_tuple_for_each_correct_sequence();
diff --git a/tests/test_tuple_start.cc b/tests/test_tuple_start.cc
index 3d136bf..5c9e11b 100644
--- a/tests/test_tuple_start.cc
+++ b/tests/test_tuple_start.cc
@@ -20,7 +20,8 @@
#include <functional>
void
-test_tuple_type_start() {
+test_tuple_type_start()
+{
{
using type_tuple = std::tuple<int, short, double>;
using type_tuple_start = sigc::internal::tuple_type_start<type_tuple, 1>::type;
@@ -50,14 +51,14 @@ test_tuple_type_start() {
}
void
-test_tuple_start() {
+test_tuple_start()
+{
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_prefix = sigc::internal::tuple_start<3>(t_original);
- static_assert(std::tuple_size<decltype(t_prefix)>::value == 3,
- "unexpected tuple_start()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_prefix)>::value == 3, "unexpected tuple_start()ed tuple size.");
assert(std::get<0>(t_prefix) == nullptr);
assert(std::get<1>(t_prefix) == "hello");
@@ -68,12 +69,11 @@ test_tuple_start() {
}
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_prefix = sigc::internal::tuple_start<2>(t_original);
- static_assert(std::tuple_size<decltype(t_prefix)>::value == 2,
- "unexpected tuple_start()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_prefix)>::value == 2, "unexpected tuple_start()ed tuple size.");
assert(std::get<0>(t_prefix) == nullptr);
assert(std::get<1>(t_prefix) == "hello");
@@ -84,12 +84,11 @@ test_tuple_start() {
}
{
- auto t_original =
- std::make_tuple(nullptr, std::string("hello"), std::string("world"));
+ auto t_original = std::make_tuple(nullptr, std::string("hello"), std::string("world"));
auto t_prefix = sigc::internal::tuple_start<1>(t_original);
- static_assert(std::tuple_size<decltype(t_prefix)>::value == 1,
- "unexpected tuple_start()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_prefix)>::value == 1, "unexpected tuple_start()ed tuple size.");
assert(std::get<0>(t_prefix) == nullptr);
@@ -100,7 +99,8 @@ test_tuple_start() {
}
void
-test_tuple_start_stdref() {
+test_tuple_start_stdref()
+{
std::string a = "yadda";
std::string b = "yaddayadda";
auto t_larger = std::make_tuple(std::ref(a), std::ref(b), 1);
@@ -108,32 +108,32 @@ test_tuple_start_stdref() {
auto t_prefix = sigc::internal::tuple_start<2>(t_larger);
a = "hello";
b = "world";
- //This works, but it's not what we are testing here:
- //assert(std::get<0>(t_larger) == "hello");
+ // This works, but it's not what we are testing here:
+ // assert(std::get<0>(t_larger) == "hello");
assert(std::get<0>(t_prefix) == "hello");
assert(std::get<1>(t_prefix) == "world");
}
-constexpr
-void
-test_tuple_start_constexpr() {
+constexpr void
+test_tuple_start_constexpr()
+{
constexpr auto str_hello = "hello";
constexpr auto str_world = "hello";
- constexpr auto t_original =
- std::make_tuple(nullptr, str_hello, str_world);
+ constexpr auto t_original = std::make_tuple(nullptr, str_hello, str_world);
constexpr auto t_prefix = sigc::internal::tuple_start<2>(t_original);
- static_assert(std::tuple_size<decltype(t_prefix)>::value == 2,
- "unexpected tuple_start()ed tuple size.");
+ static_assert(
+ std::tuple_size<decltype(t_prefix)>::value == 2, "unexpected tuple_start()ed tuple size.");
assert(std::get<0>(t_prefix) == nullptr);
assert(std::get<1>(t_prefix) == str_hello);
}
int
-main() {
+main()
+{
test_tuple_type_start();
test_tuple_start();
test_tuple_start_stdref();
diff --git a/tests/test_tuple_transform_each.cc b/tests/test_tuple_transform_each.cc
index 5e22e40..c9bcc90 100644
--- a/tests/test_tuple_transform_each.cc
+++ b/tests/test_tuple_transform_each.cc
@@ -21,23 +21,20 @@
#include <functional>
template <class T_element_from>
-class transform_to_string {
+class transform_to_string
+{
public:
- static decltype(auto)
- transform(T_element_from& from) {
- return std::to_string(from);
- }
+ static decltype(auto) transform(T_element_from& from) { return std::to_string(from); }
};
// In these tests, t_expected has elements all of the same type.
void
-test_tuple_transform_each_same_types() {
+test_tuple_transform_each_same_types()
+{
{
auto t_original = std::make_tuple(1, 2, 3);
- auto t_transformed =
- sigc::internal::tuple_transform_each<transform_to_string>(t_original);
- auto t_expected =
- std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
+ auto t_transformed = sigc::internal::tuple_transform_each<transform_to_string>(t_original);
+ auto t_expected = std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
static_assert(std::tuple_size<decltype(t_transformed)>::value == 3,
"unexpected tuple_transform_each()ed tuple size.");
@@ -46,17 +43,14 @@ test_tuple_transform_each_same_types() {
assert(std::get<1>(t_transformed) == "2");
assert(std::get<2>(t_transformed) == "3");
- static_assert(
- std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
+ static_assert(std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
"unexpected transform_each()ed tuple type");
}
{
auto t_original = std::make_tuple(1, (double)2.1f, 3);
- auto t_transformed =
- sigc::internal::tuple_transform_each<transform_to_string>(t_original);
- auto t_expected =
- std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
+ auto t_transformed = sigc::internal::tuple_transform_each<transform_to_string>(t_original);
+ auto t_expected = std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
static_assert(std::tuple_size<decltype(t_transformed)>::value == 3,
"unexpected tuple_transform_each()ed tuple size.");
@@ -65,8 +59,7 @@ test_tuple_transform_each_same_types() {
assert(std::get<1>(t_transformed).substr(0, 3) == "2.1");
assert(std::get<2>(t_transformed) == "3");
- static_assert(
- std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
+ static_assert(std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
"unexpected transform_each()ed tuple type");
}
}
@@ -79,40 +72,34 @@ class transform_to_something;
// An int will be converted to a std::string:
template <>
-class transform_to_something<int> {
+class transform_to_something<int>
+{
public:
- static std::string
- transform(int& from) {
- return std::to_string(from);
- }
+ static std::string transform(int& from) { return std::to_string(from); }
};
// A double will be converted to a char:
template <>
-class transform_to_something<double> {
+class transform_to_something<double>
+{
public:
- static char
- transform(double& from) {
- return std::to_string(from)[0];
- }
+ static char transform(double& from) { return std::to_string(from)[0]; }
};
// A std::string will be converted to an int:
template <>
-class transform_to_something<std::string> {
+class transform_to_something<std::string>
+{
public:
- static int
- transform(std::string& from) {
- return std::stoi(from);
- }
+ static int transform(std::string& from) { return std::stoi(from); }
};
// In these tests, t_expected has elements of different types.
void
-test_tuple_transform_each_multiple_types() {
+test_tuple_transform_each_multiple_types()
+{
auto t_original = std::make_tuple(1, (double)2.1f, std::string("3"));
- auto t_transformed =
- sigc::internal::tuple_transform_each<transform_to_something>(t_original);
+ auto t_transformed = sigc::internal::tuple_transform_each<transform_to_something>(t_original);
auto t_expected = std::make_tuple(std::string("1"), '2', 3);
static_assert(std::tuple_size<decltype(t_transformed)>::value == 3,
@@ -122,16 +109,16 @@ test_tuple_transform_each_multiple_types() {
assert(std::get<1>(t_transformed) == '2');
assert(std::get<2>(t_transformed) == 3);
- static_assert(
- std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
+ static_assert(std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
"unexpected transform_each()ed tuple type");
}
template <class T_element_from>
-class transform_each_nonconst {
+class transform_each_nonconst
+{
public:
- static int
- transform(T_element_from& from) {
+ static int transform(T_element_from& from)
+ {
from *= 2;
// Or, for instance, call a non-const method on from.
@@ -140,10 +127,10 @@ public:
};
void
-test_tuple_transform_each_nonconst() {
+test_tuple_transform_each_nonconst()
+{
auto t = std::make_tuple(1, 2, 3);
- auto t_transformed =
- sigc::internal::tuple_transform_each<transform_each_nonconst>(t);
+ auto t_transformed = sigc::internal::tuple_transform_each<transform_each_nonconst>(t);
// Check that t was changed (from * 2):
assert(std::get<0>(t) == 2);
@@ -157,15 +144,14 @@ test_tuple_transform_each_nonconst() {
}
void
-test_tuple_transform_each_stdref() {
+test_tuple_transform_each_stdref()
+{
int a = 1;
int b = 2;
int c = 3;
auto t_original = std::make_tuple(std::ref(a), std::ref(b), std::ref(c));
- auto t_transformed =
- sigc::internal::tuple_transform_each<transform_to_string>(t_original);
- auto t_expected =
- std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
+ auto t_transformed = sigc::internal::tuple_transform_each<transform_to_string>(t_original);
+ auto t_expected = std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
static_assert(std::tuple_size<decltype(t_transformed)>::value == 3,
"unexpected tuple_transform_each()ed tuple size.");
@@ -174,27 +160,22 @@ test_tuple_transform_each_stdref() {
assert(std::get<1>(t_transformed) == "2");
assert(std::get<2>(t_transformed) == "3");
- static_assert(
- std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
+ static_assert(std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
"unexpected transform_each()ed tuple type");
}
-
-//This can only be used via std::ref(), for instance.
-//Any attempt to copy or move it, should cause a compiler error.
-class NonCopyable {
+// This can only be used via std::ref(), for instance.
+// Any attempt to copy or move it, should cause a compiler error.
+class NonCopyable
+{
public:
- explicit NonCopyable(int val)
- : m_val(val)
- {}
-
- int get_val() const {
- return m_val;
- }
+ explicit NonCopyable(int val) : m_val(val) {}
+
+ int get_val() const { return m_val; }
NonCopyable(const NonCopyable& src) = delete;
NonCopyable& operator=(const NonCopyable& src) = delete;
-
+
NonCopyable(NonCopyable&& src) = delete;
NonCopyable& operator=(NonCopyable&& src) = delete;
@@ -202,26 +183,23 @@ private:
int m_val;
};
-
template <class T_element_from>
-class transform_noncopyable_to_string {
+class transform_noncopyable_to_string
+{
public:
- static decltype(auto)
- transform(T_element_from&& from) {
- return std::to_string(from.get_val());
- }
+ static decltype(auto) transform(T_element_from&& from) { return std::to_string(from.get_val()); }
};
void
-test_tuple_transform_each_stdref_non_copyable() {
+test_tuple_transform_each_stdref_non_copyable()
+{
NonCopyable a(1);
NonCopyable b(2);
NonCopyable c(3);
auto t_original = std::make_tuple(std::ref(a), std::ref(b), std::ref(c));
auto t_transformed =
sigc::internal::tuple_transform_each<transform_noncopyable_to_string>(t_original);
- auto t_expected =
- std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
+ auto t_expected = std::make_tuple(std::string("1"), std::string("2"), std::string("3"));
static_assert(std::tuple_size<decltype(t_transformed)>::value == 3,
"unexpected tuple_transform_each()ed tuple size.");
@@ -230,34 +208,36 @@ test_tuple_transform_each_stdref_non_copyable() {
assert(std::get<1>(t_transformed) == "2");
assert(std::get<2>(t_transformed) == "3");
- static_assert(
- std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
+ static_assert(std::is_same<decltype(t_transformed), decltype(t_expected)>::value,
"unexpected transform_each()ed tuple type");
}
static std::string correct_sequence_output;
template <class T_element_from>
-class transform_each_correct_sequence {
+class transform_each_correct_sequence
+{
public:
- static decltype(auto)
- transform(int from) {
+ static decltype(auto) transform(int from)
+ {
correct_sequence_output += std::to_string(from);
return std::to_string(from);
}
};
void
-test_tuple_transform_each_correct_sequence() {
+test_tuple_transform_each_correct_sequence()
+{
correct_sequence_output.clear();
auto t = std::make_tuple(1, 2, 3);
sigc::internal::tuple_transform_each<transform_each_correct_sequence>(t);
- //std::cout << "correct_sequence_output: " << correct_sequence_output << std::endl;
+ // std::cout << "correct_sequence_output: " << correct_sequence_output << std::endl;
assert(correct_sequence_output == "123");
}
void
-test_tuple_transform_each_empty_tuple() {
+test_tuple_transform_each_empty_tuple()
+{
auto t = std::tuple<>();
sigc::internal::tuple_transform_each<transform_to_string>(t);
}
@@ -270,26 +250,18 @@ class transform_as_constexpr_to_something;
// An int will be converted to a char:
template <>
-class transform_as_constexpr_to_something<int> {
+class transform_as_constexpr_to_something<int>
+{
public:
- constexpr
- static
- char
- transform(int from) {
- return 'a' + from;
- }
+ constexpr static char transform(int from) { return 'a' + from; }
};
// A double will be converted to an int:
template <>
-class transform_as_constexpr_to_something<const double> {
+class transform_as_constexpr_to_something<const double>
+{
public:
- constexpr
- static
- int
- transform(double from) {
- return (int)from;
- }
+ constexpr static int transform(double from) { return (int)from; }
};
/* TODO: See the comment in main().
@@ -314,7 +286,8 @@ test_tuple_transform_each_constexpr() {
*/
int
-main() {
+main()
+{
test_tuple_transform_each_same_types();
test_tuple_transform_each_multiple_types();
@@ -331,7 +304,7 @@ main() {
// error: accessing uninitialized member ‘std::tuple<char>::<anonymous>’
// though it works with clang++.
// TODO: Try it with a newer g++.
- //test_tuple_transform_each_constexpr();
+ // test_tuple_transform_each_constexpr();
return EXIT_SUCCESS;
}
diff --git a/tests/test_visit_each.cc b/tests/test_visit_each.cc
index bd76765..ec0a56e 100644
--- a/tests/test_visit_each.cc
+++ b/tests/test_visit_each.cc
@@ -45,7 +45,8 @@ class NsExtClass
};
template <class T_action, class T_functor>
-void visit_each(T_action&, const T_functor&)
+void
+visit_each(T_action&, const T_functor&)
{
result_stream << "ns_ext::visit_each() ";
}
@@ -59,10 +60,7 @@ class MyClass1 : public sigc::trackable
public:
MyClass1(const std::string& str) : s(str) {}
- void execute(int i)
- {
- result_stream << s << i;
- }
+ void execute(int i) { result_stream << s << i; }
private:
std::string s;
};
@@ -72,10 +70,7 @@ class MyClass2 : public ns_ext::NsExtClass, public sigc::trackable
public:
MyClass2(const std::string& str) : s(str) {}
- void execute(int i)
- {
- result_stream << s << i;
- }
+ void execute(int i) { result_stream << s << i; }
private:
std::string s;
};
@@ -90,24 +85,21 @@ struct MyAdaptor1 : public sigc::adapts<T_functor>
{
using result_type = typename sigc::functor_trait<T_functor>::result_type;
- result_type
- operator()() const
+ result_type operator()() const
{
result_stream << "MyAdaptor1()() ";
return this->functor_();
}
template <class T_arg1>
- decltype(auto)
- operator()(T_arg1 _A_arg1) const
+ decltype(auto) operator()(T_arg1 _A_arg1) const
{
result_stream << "MyAdaptor1()(_A_arg1) ";
return this->functor_(_A_arg1);
}
template <class T_arg1, class T_arg2>
- decltype(auto)
- operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const
+ decltype(auto) operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const
{
result_stream << "MyAdaptor1()(_A_arg1, _A_arg2) ";
return this->functor_(_A_arg1, _A_arg2);
@@ -115,13 +107,12 @@ struct MyAdaptor1 : public sigc::adapts<T_functor>
// Constructs a MyAdaptor1 object that wraps the passed functor.
// Initializes adapts<T_functor>::functor_, which is invoked from operator()().
- explicit MyAdaptor1(const T_functor& _A_functor)
- : sigc::adapts<T_functor>(_A_functor) {}
+ explicit MyAdaptor1(const T_functor& _A_functor) : sigc::adapts<T_functor>(_A_functor) {}
};
template <class T_action, class T_functor>
-void visit_each(const T_action& _A_action,
- const MyAdaptor1<T_functor>& _A_target)
+void
+visit_each(const T_action& _A_action, const MyAdaptor1<T_functor>& _A_target)
{
visit_each(_A_action, _A_target.functor_);
}
@@ -140,11 +131,10 @@ my_adaptor1(const T_functor& _A_func)
namespace sigc
{
template <class T_functor>
-struct visitor<ns1::MyAdaptor1<T_functor> >
+struct visitor<ns1::MyAdaptor1<T_functor>>
{
template <class T_action>
- static void do_visit_each(const T_action& _A_action,
- const ns1::MyAdaptor1<T_functor>& _A_target)
+ static void do_visit_each(const T_action& _A_action, const ns1::MyAdaptor1<T_functor>& _A_target)
{
sigc::visit_each(_A_action, _A_target.functor_);
}
@@ -152,8 +142,8 @@ struct visitor<ns1::MyAdaptor1<T_functor> >
} // end namespace sigc
#endif // SIGCTEST_CASE >= 3
-
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
auto util = TestUtilities::get_instance();
diff --git a/tests/testutilities.cc b/tests/testutilities.cc
index 4d8de22..845dcef 100644
--- a/tests/testutilities.cc
+++ b/tests/testutilities.cc
@@ -23,13 +23,13 @@
TestUtilities* TestUtilities::instance_ = nullptr;
-TestUtilities::TestUtilities()
-: verbose_(false), result_ok_(true), test_number_(0)
+TestUtilities::TestUtilities() : verbose_(false), result_ok_(true), test_number_(0)
{
}
-//static
-TestUtilities* TestUtilities::get_instance()
+// static
+TestUtilities*
+TestUtilities::get_instance()
{
if (!instance_)
instance_ = new TestUtilities;
@@ -37,7 +37,8 @@ TestUtilities* TestUtilities::get_instance()
return instance_;
}
-bool TestUtilities::check_command_args(int argc, char* argv[])
+bool
+TestUtilities::check_command_args(int argc, char* argv[])
{
bool go_on = true; // Whether the caller shall continue program execution.
bool print_help = false;
@@ -65,8 +66,8 @@ bool TestUtilities::check_command_args(int argc, char* argv[])
return go_on;
}
-void TestUtilities::check_result(std::ostringstream& result_stream,
- const std::string& expected_result)
+void
+TestUtilities::check_result(std::ostringstream& result_stream, const std::string& expected_result)
{
if (verbose_)
std::cout << result_stream.str() << std::endl;
@@ -82,8 +83,9 @@ void TestUtilities::check_result(std::ostringstream& result_stream,
result_stream.str("");
}
-//static
-bool TestUtilities::get_result_and_delete_instance()
+// static
+bool
+TestUtilities::get_result_and_delete_instance()
{
const bool result = instance_ ? instance_->result_ok_ : true;
delete instance_;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]