summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-02-26 10:46:24 +0100
committerMurray Cumming <murrayc@murrayc.com>2016-02-26 10:46:40 +0100
commit780b77a044ff7e5edda67d59088a33e06596c77b (patch)
tree9086c76e2c2d27559a7b87316e6af02665733685
parent249bdd539ab05aab98bc417f579524b4e988faef (diff)
downloadglibmm-780b77a044ff7e5edda67d59088a33e06596c77b.tar.gz
Run clang-format on tests.
-rw-r--r--tests/giomm_asyncresult_sourceobject/main.cc16
-rw-r--r--tests/giomm_ioerror/main.cc40
-rw-r--r--tests/giomm_ioerror_and_iodbuserror/main.cc46
-rw-r--r--tests/giomm_memoryinputstream/main.cc30
-rw-r--r--tests/giomm_simple/main.cc28
-rw-r--r--tests/giomm_tls_client/main.cc115
-rw-r--r--tests/glibmm_base64/main.cc15
-rw-r--r--tests/glibmm_bool_arrayhandle/main.cc50
-rw-r--r--tests/glibmm_bool_vector/main.cc20
-rw-r--r--tests/glibmm_btree/main.cc62
-rw-r--r--tests/glibmm_buildfilename/main.cc13
-rw-r--r--tests/glibmm_bytearray/main.cc20
-rw-r--r--tests/glibmm_date/main.cc20
-rw-r--r--tests/glibmm_interface_implementation/main.cc36
-rw-r--r--tests/glibmm_interface_move/main.cc161
-rw-r--r--tests/glibmm_mainloop/main.cc44
-rw-r--r--tests/glibmm_nodetree/main.cc79
-rw-r--r--tests/glibmm_null_containerhandle/main.cc4
-rw-r--r--tests/glibmm_null_vectorutils/main.cc13
-rw-r--r--tests/glibmm_object_move/main.cc68
-rw-r--r--tests/glibmm_objectbase_move/main.cc67
-rw-r--r--tests/glibmm_refptr/main.cc142
-rw-r--r--tests/glibmm_refptr_sigc_bind/main.cc28
-rw-r--r--tests/glibmm_ustring_compose/main.cc29
-rw-r--r--tests/glibmm_ustring_format/main.cc9
-rw-r--r--tests/glibmm_value/glibmm_value.cc12
-rw-r--r--tests/glibmm_value/main.cc4
-rw-r--r--tests/glibmm_valuearray/main.cc48
-rw-r--r--tests/glibmm_variant/main.cc238
-rw-r--r--tests/glibmm_vector/main.cc173
-rw-r--r--tests/glibmm_weakref/main.cc13
31 files changed, 810 insertions, 833 deletions
diff --git a/tests/giomm_asyncresult_sourceobject/main.cc b/tests/giomm_asyncresult_sourceobject/main.cc
index 12136fa8..cf2b01be 100644
--- a/tests/giomm_asyncresult_sourceobject/main.cc
+++ b/tests/giomm_asyncresult_sourceobject/main.cc
@@ -1,30 +1,32 @@
#include <giomm.h>
#include <iostream>
-void on_read_async(const Glib::RefPtr<Gio::AsyncResult>& result)
+void
+on_read_async(const Glib::RefPtr<Gio::AsyncResult>& result)
{
- if(!result)
+ if (!result)
{
std::cerr << G_STRFUNC << ": result is empty." << std::endl;
exit(EXIT_FAILURE);
}
- if(!g_async_result_get_source_object(result->gobj()))
+ if (!g_async_result_get_source_object(result->gobj()))
{
std::cerr << G_STRFUNC << ": g_async_result_get_source_object() failed." << std::endl;
exit(EXIT_FAILURE);
}
-
- if(!result->get_source_object_base())
+
+ if (!result->get_source_object_base())
{
std::cerr << G_STRFUNC << ": result->get_source_object_base() failed." << std::endl;
exit(EXIT_FAILURE);
}
-
+
exit(EXIT_SUCCESS);
}
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
Gio::init();
diff --git a/tests/giomm_ioerror/main.cc b/tests/giomm_ioerror/main.cc
index 797ed22e..8aaa4298 100644
--- a/tests/giomm_ioerror/main.cc
+++ b/tests/giomm_ioerror/main.cc
@@ -6,10 +6,10 @@
#include <iostream>
#include <string.h>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
@@ -27,7 +27,8 @@ std::ostream& ostr = debug;
#define TEST_FILE "/etc/fstab"
#endif
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
Gio::init();
@@ -35,49 +36,48 @@ int main(int, char**)
try
{
auto file = Gio::File::create_for_path(TEST_FILE);
- if(!file)
+ if (!file)
{
std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
auto stream = file->read();
- if(!stream)
+ if (!stream)
{
std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
- gchar buffer[1000]; //TODO: This is unpleasant.
+ gchar buffer[1000]; // TODO: This is unpleasant.
memset(buffer, 0, sizeof buffer);
const gsize bytes_read = stream->read(buffer, sizeof buffer - 1);
- if(bytes_read)
+ if (bytes_read)
ostr << "File contents read: " << buffer << std::endl;
else
{
std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
}
- catch(const Gio::Error& ex)
+ catch (const Gio::Error& ex)
{
- //This is just here to check that HOST_WAS_NOT_FOUND is still in our API,
- //because we hack it into our gio_enums.defs file and there is a risk of
- //losing it when we regenerate that file. murrayc.
- if(ex.code() == Gio::Error::HOST_WAS_NOT_FOUND)
+ // This is just here to check that HOST_WAS_NOT_FOUND is still in our API,
+ // because we hack it into our gio_enums.defs file and there is a risk of
+ // losing it when we regenerate that file. murrayc.
+ if (ex.code() == Gio::Error::HOST_WAS_NOT_FOUND)
{
std::cerr << "Host was not found." << std::endl;
}
else
- std::cerr << "Gio::Error exception caught: " << ex.what() << std::endl;
+ std::cerr << "Gio::Error exception caught: " << ex.what() << std::endl;
}
- catch(const Glib::Exception& ex)
+ catch (const Glib::Exception& ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-
diff --git a/tests/giomm_ioerror_and_iodbuserror/main.cc b/tests/giomm_ioerror_and_iodbuserror/main.cc
index 1e7dbc6f..f7d2717d 100644
--- a/tests/giomm_ioerror_and_iodbuserror/main.cc
+++ b/tests/giomm_ioerror_and_iodbuserror/main.cc
@@ -1,76 +1,76 @@
-#include <giomm.h>
#include <gio/gio.h> //For the C enum values.
+#include <giomm.h>
#include <iostream>
#include <string.h>
-// This tests that both Gio::Error and Gio::DBus::Error are registered in
+// This tests that both Gio::Error and Gio::DBus::Error are registered in
// Gio::wrap_init(), and that they are properly registered.
-// This was previously a problem, but is now fixed, and we want to make sure
+// This was previously a problem, but is now fixed, and we want to make sure
// that we don't regress.
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
Gio::init();
- //Check that Gio::Error is thrown:
+ // Check that Gio::Error is thrown:
bool gio_error_thrown = false;
try
{
- GError* gerror = g_error_new_literal (G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT, "Arbitrary test error text.");
+ GError* gerror =
+ g_error_new_literal(G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Arbitrary test error text.");
::Glib::Error::throw_exception(gerror);
}
- catch(const Gio::Error& /* ex */)
+ catch (const Gio::Error& /* ex */)
{
gio_error_thrown = true;
}
- catch(const Gio::DBus::Error& ex)
+ catch (const Gio::DBus::Error& ex)
{
std::cerr << "Gio::DBus::Error caught when a Gio::Error was expected." << std::endl;
return EXIT_FAILURE;
}
- catch(const Glib::Error& ex)
+ catch (const Glib::Error& ex)
{
std::cerr << "Glib::Error caught when a Gio::Error was expected." << std::endl;
return EXIT_FAILURE;
}
- if(!gio_error_thrown)
+ if (!gio_error_thrown)
{
- std::cerr << "Gio::Error was not thrown, but should have been thrown." << std::endl;
+ std::cerr << "Gio::Error was not thrown, but should have been thrown." << std::endl;
return EXIT_FAILURE;
}
-
- //Check that Gio::DBus::Error is thrown:
+
+ // Check that Gio::DBus::Error is thrown:
bool gio_dbus_error_thrown = false;
try
{
- GError* gerror = g_error_new_literal (G_DBUS_ERROR,
- G_DBUS_ERROR_FAILED, "Arbitrary test error text.");
+ GError* gerror =
+ g_error_new_literal(G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Arbitrary test error text.");
::Glib::Error::throw_exception(gerror);
}
- catch(const Gio::DBus::Error& /* ex */)
+ catch (const Gio::DBus::Error& /* ex */)
{
gio_dbus_error_thrown = true;
}
- catch(const Gio::Error& ex)
+ catch (const Gio::Error& ex)
{
std::cerr << "Gio::Error caught when a Gio::Dbus::Error was expected." << std::endl;
return EXIT_FAILURE;
}
- catch(const Glib::Error& ex)
+ catch (const Glib::Error& ex)
{
std::cerr << "Glib::Error caught when a Gio::DBus::Error was expected." << std::endl;
return EXIT_FAILURE;
}
- if(!gio_dbus_error_thrown)
+ if (!gio_dbus_error_thrown)
{
- std::cerr << "Gio::DBus::Error was not thrown, but should have been thrown." << std::endl;
+ std::cerr << "Gio::DBus::Error was not thrown, but should have been thrown." << std::endl;
return EXIT_FAILURE;
}
-
+
return EXIT_SUCCESS;
}
-
diff --git a/tests/giomm_memoryinputstream/main.cc b/tests/giomm_memoryinputstream/main.cc
index 0fcc6b0f..2c35d1a1 100644
--- a/tests/giomm_memoryinputstream/main.cc
+++ b/tests/giomm_memoryinputstream/main.cc
@@ -1,23 +1,24 @@
+#include <cstdlib>
+#include <cstring>
#include <giomm.h>
#include <iostream>
#include <sstream>
#include <string>
-#include <cstring>
-#include <cstdlib>
namespace
{
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::ostringstream debug;
std::ostream& ostr = debug;
std::string func1_output;
std::string func2_output;
-void destroy_func1(void* data)
+void
+destroy_func1(void* data)
{
char* cdata = static_cast<char*>(data);
func1_output += "Deleting ";
@@ -25,7 +26,8 @@ void destroy_func1(void* data)
delete[] cdata;
}
-void destroy_func2(void* data, const Glib::ustring& intro)
+void
+destroy_func2(void* data, const Glib::ustring& intro)
{
char* cdata = static_cast<char*>(data);
func2_output += intro + cdata;
@@ -34,7 +36,8 @@ void destroy_func2(void* data, const Glib::ustring& intro)
} // anonymous namespace
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
Gio::init();
@@ -47,7 +50,7 @@ int main(int, char**)
if (!stream)
{
std::cerr << "Could not create a MemoryInputStream." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
// Add data that shall not be deleted by stream.
@@ -71,25 +74,24 @@ int main(int, char**)
else
{
std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
}
catch (const Glib::Exception& ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
ostr << func1_output << std::endl;
ostr << func2_output << std::endl;
if (std::strcmp(buffer, "Data not owned by stream.\ndata2\ndata3\n") == 0 &&
- func1_output == "Deleting data2\n" &&
- func2_output == "Now deleting data3\n")
+ func1_output == "Deleting data2\n" && func2_output == "Now deleting data3\n")
return EXIT_SUCCESS;
std::cerr << "buffer: \"" << buffer << "\"" << std::endl;
std::cerr << "func1_output: \"" << func1_output << "\"" << std::endl;
std::cerr << "func2_output: \"" << func2_output << "\"" << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
diff --git a/tests/giomm_simple/main.cc b/tests/giomm_simple/main.cc
index 175cadf3..7b1e8767 100644
--- a/tests/giomm_simple/main.cc
+++ b/tests/giomm_simple/main.cc
@@ -2,10 +2,10 @@
#include <iostream>
#include <string.h>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
@@ -15,7 +15,8 @@ std::ostream& ostr = debug;
#define TEST_FILE "/etc/fstab"
#endif
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
Gio::init();
@@ -23,37 +24,36 @@ int main(int, char**)
try
{
auto file = Gio::File::create_for_path(TEST_FILE);
- if(!file)
+ if (!file)
{
std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
auto stream = file->read();
- if(!stream)
+ if (!stream)
{
std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
- gchar buffer[1000]; //TODO: This is unpleasant.
+ gchar buffer[1000]; // TODO: This is unpleasant.
memset(buffer, 0, sizeof buffer);
const gsize bytes_read = stream->read(buffer, sizeof buffer - 1);
- if(bytes_read)
+ if (bytes_read)
ostr << "File contents read: " << buffer << std::endl;
else
{
std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
}
- catch(const Glib::Exception& ex)
+ catch (const Glib::Exception& ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-
diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc
index 2eb0eaf0..5f133253 100644
--- a/tests/giomm_tls_client/main.cc
+++ b/tests/giomm_tls_client/main.cc
@@ -16,145 +16,130 @@
// https://developer.gnome.org/gio/stable/gio-Extension-Points.html
// https://developer.gnome.org/gio/stable/gio-querymodules.html
+#include <cstdlib>
#include <giomm.h>
#include <iostream>
-#include <cstdlib>
-bool on_accept_certificate(const Glib::RefPtr<const Gio::TlsCertificate>& cert, Gio::TlsCertificateFlags)
+bool
+on_accept_certificate(const Glib::RefPtr<const Gio::TlsCertificate>& cert, Gio::TlsCertificateFlags)
{
std::cout << "Handshake is ocurring." << std::endl
- << "The server is requesting that its certificate be accepted." <<
- std::endl;
+ << "The server is requesting that its certificate be accepted." << std::endl;
- std::cout << "Outputing certificate data:" << std::endl <<
- cert->property_certificate_pem().get_value();
+ std::cout << "Outputing certificate data:" << std::endl
+ << cert->property_certificate_pem().get_value();
auto issuer = cert->get_issuer();
- std::cout << "Outputing the issuer's certificate data:" << std::endl <<
- issuer->property_certificate_pem().get_value();
+ std::cout << "Outputing the issuer's certificate data:" << std::endl
+ << issuer->property_certificate_pem().get_value();
- std::cout << "Accepting the certificate (completing the handshake)." <<
- std::endl;
+ std::cout << "Accepting the certificate (completing the handshake)." << std::endl;
return true;
}
-int main(int, char**)
+int
+main(int, char**)
{
Gio::init();
const Glib::ustring test_host = "www.gnome.org";
- std::vector< Glib::RefPtr<Gio::InetAddress> > inet_addresses;
+ std::vector<Glib::RefPtr<Gio::InetAddress>> inet_addresses;
try
{
- inet_addresses =
- Gio::Resolver::get_default()->lookup_by_name(test_host);
+ inet_addresses = Gio::Resolver::get_default()->lookup_by_name(test_host);
}
- catch(const Gio::ResolverError& ex)
+ catch (const Gio::ResolverError& ex)
{
- //This happens if it could not resolve the name,
- //for instance if we are not connected to the internet.
- //TODO: Change this test so it can do something useful and succeed even
- //if the testing computer is not connected to the internet.
+ // This happens if it could not resolve the name,
+ // for instance if we are not connected to the internet.
+ // TODO: Change this test so it can do something useful and succeed even
+ // if the testing computer is not connected to the internet.
std::cerr << "Gio::Resolver::lookup_by_name() threw exception: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
- //Actually, it would throw an exception instead of reaching here with 0 addresses resolved.
- if(inet_addresses.size() == 0)
+ // Actually, it would throw an exception instead of reaching here with 0 addresses resolved.
+ if (inet_addresses.size() == 0)
{
- std::cerr << "Could not resolve test host '" << test_host << "'." <<
- std::endl;
+ std::cerr << "Could not resolve test host '" << test_host << "'." << std::endl;
return EXIT_FAILURE;
}
- std::cout << "Successfully resolved address of test host '" << test_host <<
- "'." << std::endl;
+ std::cout << "Successfully resolved address of test host '" << test_host << "'." << std::endl;
auto first_inet_address = inet_addresses[0];
- std::cout << "First address of test host is " <<
- first_inet_address->to_string() << "." << std::endl;
+ std::cout << "First address of test host is " << first_inet_address->to_string() << "."
+ << std::endl;
- auto socket =
- Gio::Socket::create(first_inet_address->get_family(),
- Gio::SOCKET_TYPE_STREAM, Gio::SOCKET_PROTOCOL_TCP);
+ auto socket = Gio::Socket::create(
+ first_inet_address->get_family(), Gio::SOCKET_TYPE_STREAM, Gio::SOCKET_PROTOCOL_TCP);
- auto address =
- Gio::InetSocketAddress::create(first_inet_address, 443);
+ auto address = Gio::InetSocketAddress::create(first_inet_address, 443);
try
{
socket->connect(address);
}
- catch(const Gio::Error& ex)
+ catch (const Gio::Error& ex)
{
- std::cout << "Could not connect socket to " <<
- address->get_address()->to_string() << ":" << address->get_port() <<
- ". Exception: " << ex.what() << std::endl;
+ std::cout << "Could not connect socket to " << address->get_address()->to_string() << ":"
+ << address->get_port() << ". Exception: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
- if(!socket->is_connected())
+ if (!socket->is_connected())
{
- std::cout << "Could not connect socket to " <<
- address->get_address()->to_string() << ":" << address->get_port() <<
- "." << std::endl;
+ std::cout << "Could not connect socket to " << address->get_address()->to_string() << ":"
+ << address->get_port() << "." << std::endl;
}
auto conn = Glib::RefPtr<Gio::TcpConnection>::cast_dynamic(Gio::SocketConnection::create(socket));
- if(!conn || !conn->is_connected())
+ if (!conn || !conn->is_connected())
{
- std::cout << "Could not establish connection to " <<
- address->get_address()->to_string() << ":" << address->get_port() <<
- "." << std::endl;
+ std::cout << "Could not establish connection to " << address->get_address()->to_string() << ":"
+ << address->get_port() << "." << std::endl;
socket->close();
return EXIT_FAILURE;
}
- std::cout << "Successfully established connection to " <<
- address->get_address()->to_string() << ":" << address->get_port() <<
- "." << std::endl;
+ std::cout << "Successfully established connection to " << address->get_address()->to_string()
+ << ":" << address->get_port() << "." << std::endl;
try
{
- auto tls_connection =
- Gio::TlsClientConnection::create(conn, address);
+ auto tls_connection = Gio::TlsClientConnection::create(conn, address);
- tls_connection->signal_accept_certificate().connect(
- sigc::ptr_fun(&on_accept_certificate));
+ tls_connection->signal_accept_certificate().connect(sigc::ptr_fun(&on_accept_certificate));
- tls_connection->handshake();
+ tls_connection->handshake();
std::cout << "Attempting to get the issuer's certificate from the "
- "connection." << std::endl;
+ "connection."
+ << std::endl;
- auto issuer_certificate =
- tls_connection->get_peer_certificate()->get_issuer();
+ auto issuer_certificate = tls_connection->get_peer_certificate()->get_issuer();
- if(!issuer_certificate)
+ if (!issuer_certificate)
{
- std::cout << "Could not get the issuer's certificate of the peer." <<
- std::endl;
+ std::cout << "Could not get the issuer's certificate of the peer." << std::endl;
return EXIT_FAILURE;
}
- std::cout << "Successfully retrieved the issuer's certificate." <<
- std::endl;
+ std::cout << "Successfully retrieved the issuer's certificate." << std::endl;
std::cout << "Attempting to use the connection's database." << std::endl;
auto database = tls_connection->get_database();
- std::cout << "Looking up the certificate's issuer in the database." <<
- std::endl;
+ std::cout << "Looking up the certificate's issuer in the database." << std::endl;
- auto db_certificate =
- database->lookup_certificate_issuer(issuer_certificate);
+ auto db_certificate = database->lookup_certificate_issuer(issuer_certificate);
- if(!db_certificate)
+ if (!db_certificate)
{
std::cout << "The issuer's certificate was not found in the database." << std::endl;
}
diff --git a/tests/glibmm_base64/main.cc b/tests/glibmm_base64/main.cc
index dc4dd626..500f89e6 100644
--- a/tests/glibmm_base64/main.cc
+++ b/tests/glibmm_base64/main.cc
@@ -7,7 +7,8 @@ main()
{
std::string glib_base64 = "R2xpYg==";
std::string glibmm_base64 = "R2xpYm1t";
- std::string stallman_quote_base64 = "VmFsdWUgeW91ciBmcmVlZG9tIG9yIHlvdSB3aWxsIGxvc2UgaXQsIHRlYWNoZXMgaGlzdG9yeS4K\n"
+ std::string stallman_quote_base64 =
+ "VmFsdWUgeW91ciBmcmVlZG9tIG9yIHlvdSB3aWxsIGxvc2UgaXQsIHRlYWNoZXMgaGlzdG9yeS4K\n"
"J0Rvbid0IGJvdGhlciB1cyB3aXRoIHBvbGl0aWNzJywgcmVzcG9uZCB0aG9zZSB3aG8gZG9uJ3Qg\n"
"d2FudCB0byBsZWFybi4KCi0tIFJpY2hhcmQgU3RhbGxtYW4=\n";
@@ -15,12 +16,18 @@ main()
std::cerr << Glib::Base64::encode("Glib") << std::endl;
g_assert(Glib::Base64::encode("Glib") == glib_base64);
- // test that encodes the quote by Richard Stallman into base64 with linebreaks (the output has line breaks)
+ // test that encodes the quote by Richard Stallman into base64 with linebreaks (the output has
+ // line breaks)
std::cerr << Glib::Base64::encode("Value your freedom or you will lose it, teaches history.\n"
- "'Don't bother us with politics', respond those who don't want to learn.\n\n-- Richard Stallman", true) << std::endl;
+ "'Don't bother us with politics', respond those who don't want "
+ "to learn.\n\n-- Richard Stallman",
+ true)
+ << std::endl;
std::cerr << stallman_quote_base64 << std::endl;
g_assert(Glib::Base64::encode("Value your freedom or you will lose it, teaches history.\n"
- "'Don't bother us with politics', respond those who don't want to learn.\n\n-- Richard Stallman", true) == stallman_quote_base64);
+ "'Don't bother us with politics', respond those who don't want to "
+ "learn.\n\n-- Richard Stallman",
+ true) == stallman_quote_base64);
// test that decodes the string "Glibmm" from base64
std::cerr << Glib::Base64::decode(glibmm_base64) << std::endl;
diff --git a/tests/glibmm_bool_arrayhandle/main.cc b/tests/glibmm_bool_arrayhandle/main.cc
index e4247cf7..788559e9 100644
--- a/tests/glibmm_bool_arrayhandle/main.cc
+++ b/tests/glibmm_bool_arrayhandle/main.cc
@@ -21,35 +21,34 @@
#include <glibmm.h>
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
-
-//This seems nicer and more useful than putting an ifdef around the use of std::cout:
+// This seems nicer and more useful than putting an ifdef around the use of std::cout:
std::stringstream debug;
std::ostream& ostr = debug;
-const unsigned int magic_limit (5);
+const unsigned int magic_limit(5);
void
-setup_rand ()
+setup_rand()
{
- static bool setup (false);
+ static bool setup(false);
if (!setup)
{
- std::srand (std::time (nullptr));
+ std::srand(std::time(nullptr));
setup = true;
}
}
gboolean*
-c_get_bool_array ()
+c_get_bool_array()
{
- gboolean* array (static_cast<gboolean*> (g_malloc ((magic_limit + 1) * sizeof (gboolean))));
+ gboolean* array(static_cast<gboolean*>(g_malloc((magic_limit + 1) * sizeof(gboolean))));
- setup_rand ();
- for (unsigned int iter (0); iter < magic_limit; ++iter)
+ setup_rand();
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
array[iter] = std::rand() % 2 ? TRUE : FALSE;
}
@@ -58,40 +57,41 @@ c_get_bool_array ()
}
void
-c_print_bool_array (gboolean* array)
+c_print_bool_array(gboolean* array)
{
- for (unsigned int iter (0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
ostr << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n";
}
}
Glib::ArrayHandle<bool>
-cxx_get_bool_array ()
+cxx_get_bool_array()
{
- return Glib::ArrayHandle<bool> (c_get_bool_array (), magic_limit, Glib::OWNERSHIP_SHALLOW);
+ return Glib::ArrayHandle<bool>(c_get_bool_array(), magic_limit, Glib::OWNERSHIP_SHALLOW);
}
void
-cxx_print_bool_array (const Glib::ArrayHandle<bool>& array)
+cxx_print_bool_array(const Glib::ArrayHandle<bool>& array)
{
- c_print_bool_array (const_cast<gboolean*> (array.data ()));
+ c_print_bool_array(const_cast<gboolean*>(array.data()));
}
-int main()
+int
+main()
{
Glib::init();
- std::vector<bool> v (cxx_get_bool_array ());
- std::list<bool> l (cxx_get_bool_array ());
- std::deque<bool> d (cxx_get_bool_array ());
+ std::vector<bool> v(cxx_get_bool_array());
+ std::list<bool> l(cxx_get_bool_array());
+ std::deque<bool> d(cxx_get_bool_array());
ostr << "vector:\n";
- cxx_print_bool_array (v);
+ cxx_print_bool_array(v);
ostr << "list:\n";
- cxx_print_bool_array (l);
+ cxx_print_bool_array(l);
ostr << "deque:\n";
- cxx_print_bool_array (d);
+ cxx_print_bool_array(d);
return EXIT_SUCCESS;
}
diff --git a/tests/glibmm_bool_vector/main.cc b/tests/glibmm_bool_vector/main.cc
index 1e7c32ae..79b286c4 100644
--- a/tests/glibmm_bool_vector/main.cc
+++ b/tests/glibmm_bool_vector/main.cc
@@ -21,10 +21,10 @@
#include <glibmm.h>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
@@ -35,7 +35,7 @@ setup_rand()
{
static bool setup(false);
- if(!setup)
+ if (!setup)
{
setup = true;
std::srand(std::time(nullptr));
@@ -48,7 +48,7 @@ c_get_bool_array()
gboolean* array(static_cast<gboolean*>(g_malloc((magic_limit + 1) * sizeof(gboolean))));
setup_rand();
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
array[iter] = std::rand() % 2 ? TRUE : FALSE;
}
@@ -59,16 +59,17 @@ c_get_bool_array()
void
c_print_bool_array(gboolean* array)
{
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
- ostr << iter << ": " <<(array[iter] ? "TRUE" : "FALSE") << "\n";
+ ostr << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n";
}
}
std::vector<bool>
cxx_get_bool_array()
{
- return Glib::ArrayHandler<bool>::array_to_vector(c_get_bool_array(), magic_limit, Glib::OWNERSHIP_SHALLOW);
+ return Glib::ArrayHandler<bool>::array_to_vector(
+ c_get_bool_array(), magic_limit, Glib::OWNERSHIP_SHALLOW);
}
void
@@ -77,7 +78,8 @@ cxx_print_bool_array(const std::vector<bool>& v)
c_print_bool_array(const_cast<gboolean*>(Glib::ArrayHandler<bool>::vector_to_array(v).data()));
}
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
diff --git a/tests/glibmm_btree/main.cc b/tests/glibmm_btree/main.cc
index 69566ccf..647542b8 100644
--- a/tests/glibmm_btree/main.cc
+++ b/tests/glibmm_btree/main.cc
@@ -14,21 +14,18 @@ my_traverse(const type_key_value& /*key*/, const type_key_value& value)
{
g_assert(value.size() == 1 && value[0] > 0);
return false;
-}
+}
-const type_key_value str(
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz");
+const type_key_value str("0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz");
-const type_key_value str2(
- "0123456789"
- "abcdefghijklmnopqrstuvwxyz");
+const type_key_value str2("0123456789"
+ "abcdefghijklmnopqrstuvwxyz");
static bool
-check_order(const type_key_value& key,
- const type_key_value& /*value*/,
- type_key_value::const_iterator& i)
+check_order(
+ const type_key_value& key, const type_key_value& /*value*/, type_key_value::const_iterator& i)
{
g_assert(key == type_key_value(1, *(i++)));
return false;
@@ -44,16 +41,14 @@ static bool
my_p_traverse(const type_p_key_value& key, const type_p_key_value& value)
{
return my_traverse(*key, *value);
-}
-
+}
std::vector<type_p_key_value> pstr;
std::vector<type_p_key_value> pstr2;
static bool
-check_p_order(const type_p_key_value& key,
- const type_p_key_value& /*value*/,
- std::vector<type_p_key_value>::const_iterator& i)
+check_p_order(const type_p_key_value& key, const type_p_key_value& /*value*/,
+ std::vector<type_p_key_value>::const_iterator& i)
{
g_assert(*key == **(i++));
return false;
@@ -62,14 +57,14 @@ check_p_order(const type_p_key_value& key,
static int
my_p_key_compare(const type_p_key_value& key_a, const type_p_key_value& key_b)
{
- if(*key_a < *key_b)
+ if (*key_a < *key_b)
return -1;
- if(*key_a > *key_b)
+ if (*key_a > *key_b)
return 1;
return EXIT_SUCCESS;
-}
+}
int
main()
@@ -79,31 +74,31 @@ main()
for (type_key_value::size_type i = 0; i < str.size(); ++i)
tree->insert(str.substr(i, 1), str.substr(i, 1));
- tree->foreach(sigc::ptr_fun(my_traverse));
+ tree->foreach (sigc::ptr_fun(my_traverse));
g_assert(tree->nnodes() == gint(str.size()));
g_assert(tree->height() == 6);
- tree->foreach(sigc::bind(sigc::ptr_fun(check_order), str.begin()));
-
+ tree->foreach (sigc::bind(sigc::ptr_fun(check_order), str.begin()));
+
for (type_key_value::size_type i = 0; i < 26; i++)
g_assert(tree->remove(str.substr(i + 10, 1)));
g_assert(!tree->remove(""));
- tree->foreach(sigc::ptr_fun(my_traverse));
+ tree->foreach (sigc::ptr_fun(my_traverse));
g_assert(tree->nnodes() == gint(str2.size()));
g_assert(tree->height() == 6);
- tree->foreach(sigc::bind(sigc::ptr_fun(check_order), str2.begin()));
+ tree->foreach (sigc::bind(sigc::ptr_fun(check_order), str2.begin()));
for (int i = 25; i >= 0; i--)
tree->insert(str.substr(i + 10, 1), str.substr(i + 10, 1));
- tree->foreach(sigc::bind(sigc::ptr_fun(check_order), str.begin()));
+ tree->foreach (sigc::bind(sigc::ptr_fun(check_order), str.begin()));
- type_key_value *value;
+ type_key_value* value;
value = tree->lookup("0");
g_assert(value && *value == "0");
@@ -137,7 +132,8 @@ main()
value = tree->search(sigc::ptr_fun(my_search), "|");
g_assert(value == NULL);
- auto ptree = Glib::BalancedTree<type_p_key_value, type_p_key_value>::create(sigc::ptr_fun(my_p_key_compare));
+ auto ptree =
+ Glib::BalancedTree<type_p_key_value, type_p_key_value>::create(sigc::ptr_fun(my_p_key_compare));
for (type_key_value::size_type i = 0; i < str.size(); ++i)
pstr.emplace_back(new type_key_value(str.substr(i, 1)));
@@ -147,13 +143,13 @@ main()
for (type_key_value::size_type i = 0; i < str.size(); ++i)
ptree->insert(pstr[i], pstr[i]);
- ptree->foreach(sigc::ptr_fun(my_p_traverse));
+ ptree->foreach (sigc::ptr_fun(my_p_traverse));
g_assert(ptree->nnodes() == gint(pstr.size()));
g_assert(ptree->height() == 6);
std::vector<type_p_key_value>::const_iterator j = pstr.begin();
- ptree->foreach(sigc::bind(sigc::ptr_fun(check_p_order), j));
+ ptree->foreach (sigc::bind(sigc::ptr_fun(check_p_order), j));
g_assert(ptree->lookup(new Glib::ustring("l")));
@@ -163,21 +159,21 @@ main()
Glib::ustring pstr3("");
g_assert(!ptree->remove(&pstr3));
- ptree->foreach(sigc::ptr_fun(my_p_traverse));
+ ptree->foreach (sigc::ptr_fun(my_p_traverse));
g_assert(ptree->nnodes() == gint(str2.size()));
g_assert(ptree->height() == 6);
j = pstr2.begin();
- ptree->foreach(sigc::bind(sigc::ptr_fun(check_p_order), j));
+ ptree->foreach (sigc::bind(sigc::ptr_fun(check_p_order), j));
for (int i = 25; i >= 0; i--)
ptree->insert(pstr[i + 10], pstr[i + 10]);
j = pstr.begin();
- ptree->foreach(sigc::bind(sigc::ptr_fun(check_p_order), j));
+ ptree->foreach (sigc::bind(sigc::ptr_fun(check_p_order), j));
- type_p_key_value *pvalue;
+ type_p_key_value* pvalue;
pstr3 = "0";
pvalue = ptree->lookup(&pstr3);
diff --git a/tests/glibmm_buildfilename/main.cc b/tests/glibmm_buildfilename/main.cc
index 42fb7982..2460622b 100644
--- a/tests/glibmm_buildfilename/main.cc
+++ b/tests/glibmm_buildfilename/main.cc
@@ -2,17 +2,18 @@
#include <iostream>
#include <string.h>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
#define DIR "/dir1/dir_2/dir-3"
#define FILE "dir/file.ext"
-int main(int, char**)
+int
+main(int, char**)
{
gchar* dir_1 = g_strdup(DIR);
std::string dir_2(DIR);
@@ -35,10 +36,8 @@ int main(int, char**)
path = Glib::build_filename(dir_1, dir_2, dir_3, file_1);
ostr << "Path 4: " << path << std::endl;
- path = Glib::build_filename(dir_1, dir_2, dir_1, dir_3, dir_2, dir_3,
- dir_1, dir_2, file_2);
+ path = Glib::build_filename(dir_1, dir_2, dir_1, dir_3, dir_2, dir_3, dir_1, dir_2, file_2);
ostr << "Path 5: " << path << std::endl;
return EXIT_SUCCESS;
}
-
diff --git a/tests/glibmm_bytearray/main.cc b/tests/glibmm_bytearray/main.cc
index ff05f3ce..aa62d1a8 100644
--- a/tests/glibmm_bytearray/main.cc
+++ b/tests/glibmm_bytearray/main.cc
@@ -5,34 +5,34 @@
int
main()
{
- Glib::RefPtr< Glib::ByteArray > array(Glib::ByteArray::create());
- guint8 data[] = {1, 2, 3, 4, 5, 6};
+ Glib::RefPtr<Glib::ByteArray> array(Glib::ByteArray::create());
+ guint8 data[] = { 1, 2, 3, 4, 5, 6 };
array->append(data, sizeof(data));
// |1, 2, 3, 4, 5, 6| = 6
- g_assert (array->size() == 6);
+ g_assert(array->size() == 6);
array->prepend(data, sizeof(data));
// |1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6| = 12
- g_assert (array->size() == 12);
+ g_assert(array->size() == 12);
array->remove_index(0);
// |2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6| = 11
- g_assert (array->size() == 11);
+ g_assert(array->size() == 11);
array->remove_index_fast(0);
// |6, 3, 4, 5, 6, 1, 2, 3, 4, 5| = 10
- g_assert (array->size() == 10);
+ g_assert(array->size() == 10);
array->remove_range(0, 4);
// |6, 1, 2, 3, 4, 5,| = 6
- g_assert (array->size() == 6);
+ g_assert(array->size() == 6);
array->set_size(2);
// |6, 1| = 2
- g_assert (array->size() == 2);
+ g_assert(array->size() == 2);
guint8* array_data = array->get_data();
- g_assert (array_data[0] == 6);
- g_assert (array_data[1] == 1);
+ g_assert(array_data[0] == 6);
+ g_assert(array_data[1] == 1);
}
diff --git a/tests/glibmm_date/main.cc b/tests/glibmm_date/main.cc
index db31cb60..1e6411d7 100644
--- a/tests/glibmm_date/main.cc
+++ b/tests/glibmm_date/main.cc
@@ -1,14 +1,15 @@
#include <glibmm.h>
#include <iostream>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
-int main(int, char**)
+int
+main(int, char**)
{
Glib::Date date;
date.set_time_current();
@@ -16,19 +17,16 @@ int main(int, char**)
date.subtract_days(1);
date.add_years(1);
- ostr << "The date a year and a month from yesterday will be: " <<
- date.get_month() << "/" << (int) date.get_day() << "/" << date.get_year() <<
- "." << std::endl;
-
+ ostr << "The date a year and a month from yesterday will be: " << date.get_month() << "/"
+ << (int)date.get_day() << "/" << date.get_year() << "." << std::endl;
Glib::Date copy_date(date);
Glib::Date assigned_date;
assigned_date = copy_date;
- ostr << "The copied date is: " << copy_date.get_month() << "/" <<
- (int) copy_date.get_day() << "/" << copy_date.get_year() << "." <<
- std::endl;
+ ostr << "The copied date is: " << copy_date.get_month() << "/" << (int)copy_date.get_day() << "/"
+ << copy_date.get_year() << "." << std::endl;
return EXIT_SUCCESS;
}
diff --git a/tests/glibmm_interface_implementation/main.cc b/tests/glibmm_interface_implementation/main.cc
index 40da2787..780d0c13 100644
--- a/tests/glibmm_interface_implementation/main.cc
+++ b/tests/glibmm_interface_implementation/main.cc
@@ -3,14 +3,12 @@
// or printed unjustified critical messages in glibmm before version 2.44.
// See https://bugzilla.gnome.org/show_bug.cgi?id=705124.
-#include <glibmm.h>
+#include <cstring>
#include <giomm.h> //There are no Interfaces in glibmm, but there are in giomm.
+#include <glibmm.h>
#include <iostream>
-#include <cstring>
-class CustomAction :
- public Gio::Action,
- public Glib::Object
+class CustomAction : public Gio::Action, public Glib::Object
{
public:
CustomAction();
@@ -19,14 +17,14 @@ public:
Glib::Property<Glib::ustring> property;
protected:
- //Implement vfuncs:
+ // Implement vfuncs:
Glib::ustring get_name_vfunc() const override;
Glib::VariantType get_state_type_vfunc() const override;
Glib::VariantBase get_state_hint_vfunc() const override;
};
CustomAction::CustomAction()
-: Glib::ObjectBase( typeid(CustomAction) ),
+: Glib::ObjectBase(typeid(CustomAction)),
Glib::Object(),
property(*this, "custom_property", "Initial value.")
{
@@ -34,23 +32,27 @@ CustomAction::CustomAction()
static bool get_name_called = false;
-Glib::ustring CustomAction::get_name_vfunc() const
+Glib::ustring
+CustomAction::get_name_vfunc() const
{
get_name_called = true;
return "custom-name";
}
-Glib::VariantType CustomAction::get_state_type_vfunc() const
+Glib::VariantType
+CustomAction::get_state_type_vfunc() const
{
return Glib::VariantType(G_VARIANT_TYPE_INT16);
}
-Glib::VariantBase CustomAction::get_state_hint_vfunc() const
+Glib::VariantBase
+CustomAction::get_state_hint_vfunc() const
{
return Glib::Variant<gint16>::create(42);
}
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
@@ -65,20 +67,20 @@ int main(int, char**)
<< action.property_name().get_value() << "'." << std::endl;
success &= action.property_name().get_value() == "";
- std::cout << "The custom string property is '"
- << action.property.get_value() << "'." << std::endl;
+ std::cout << "The custom string property is '" << action.property.get_value() << "'."
+ << std::endl;
success &= action.property.get_value() == "Initial value.";
action.property = "A new value.";
- std::cout << "The custom string property (after changing it) is '"
- << action.property.get_value() << "'." << std::endl;
+ std::cout << "The custom string property (after changing it) is '" << action.property.get_value()
+ << "'." << std::endl;
success &= action.property.get_value() == "A new value.";
gchar* prop_value = nullptr;
g_object_set(action.gobj(), "custom_property", "Another value", NULL);
g_object_get(action.gobj(), "custom_property", &prop_value, NULL);
- std::cout << "The custom property after g_object_set/get() is '"
- << prop_value << "'." << std::endl;
+ std::cout << "The custom property after g_object_set/get() is '" << prop_value << "'."
+ << std::endl;
success &= std::strcmp(prop_value, "Another value") == 0;
g_free(prop_value);
prop_value = nullptr;
diff --git a/tests/glibmm_interface_move/main.cc b/tests/glibmm_interface_move/main.cc
index 31d3f85d..45b81de4 100644
--- a/tests/glibmm_interface_move/main.cc
+++ b/tests/glibmm_interface_move/main.cc
@@ -4,72 +4,76 @@
#include <iostream>
#include <stdlib.h>
-//A basic derived GInterface, just to test Glib::Interface
+// A basic derived GInterface, just to test Glib::Interface
-G_DECLARE_INTERFACE (TestIface, test_Iface, TEST, IFACE, GObject)
+G_DECLARE_INTERFACE(TestIface, test_Iface, TEST, IFACE, GObject)
struct _TestIface
{
GTypeInterface g_iface;
};
-static void
-test_Iface_init (gpointer)
-{}
+static void test_Iface_init(gpointer)
+{
+}
GType
-test_Iface_get_type (void)
+test_Iface_get_type(void)
{
static GType type = 0;
if (!type)
- {
- const GTypeInfo info =
- {
- sizeof (TestIface), // class_size
- test_Iface_init, // base_init
- nullptr, // base_finalize
- nullptr, // class_init
- nullptr, // class_finalize
- nullptr, // class_data
- 0, // instance_size
- 0, // n_preallocs
- nullptr, // instance_init
- nullptr // value_table
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE, "TestIface",
- &info, GTypeFlags(0));
- }
+ {
+ const GTypeInfo info = {
+ sizeof(TestIface), // class_size
+ test_Iface_init, // base_init
+ nullptr, // base_finalize
+ nullptr, // class_init
+ nullptr, // class_finalize
+ nullptr, // class_data
+ 0, // instance_size
+ 0, // n_preallocs
+ nullptr, // instance_init
+ nullptr // value_table
+ };
+
+ type = g_type_register_static(G_TYPE_INTERFACE, "TestIface", &info, GTypeFlags(0));
+ }
return type;
}
-#define TEST_TYPE_IFACE (test_Iface_get_type ())
+#define TEST_TYPE_IFACE (test_Iface_get_type())
-
-//A basic derived GObject, just to test Glib::Object.
-typedef struct {
- GObject parent;
+// A basic derived GObject, just to test Glib::Object.
+typedef struct
+{
+ GObject parent;
} TestDerived;
-typedef struct {
- GObjectClass parent;
+typedef struct
+{
+ GObjectClass parent;
} TestDerivedClass;
-#define TEST_TYPE_DERIVED (test_derived_get_type ())
-#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DERIVED, TestDerived))
-#define TEST_DERIVED_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST ((cls), TEST_TYPE_DERIVED, TestDerivedClass))
-#define TEST_DERIVED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_TYPE_DERIVED (test_derived_get_type())
+#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_DERIVED, TestDerived))
+#define TEST_DERIVED_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST((cls), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_DERIVED_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), TEST_TYPE_DERIVED, TestDerivedClass))
-static void test_derived_class_init (TestDerivedClass *)
-{}
-static void test_derived_init (TestDerived *)
-{}
+static void
+test_derived_class_init(TestDerivedClass*)
+{
+}
+static void
+test_derived_init(TestDerived*)
+{
+}
-G_DEFINE_TYPE_EXTENDED(TestDerived, test_derived, G_TYPE_OBJECT,
- 0, G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE,
- test_Iface_init))
+G_DEFINE_TYPE_EXTENDED(TestDerived, test_derived, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE(TEST_TYPE_IFACE, test_Iface_init))
class TestInterface;
@@ -82,7 +86,7 @@ public:
const Glib::Interface_Class& init()
{
- if(!gtype_) // create the GType if necessary
+ if (!gtype_) // create the GType if necessary
{
// Glib::Interface_Class has to know the interface init function
// in order to add interfaces to implementing types.
@@ -90,16 +94,14 @@ public:
// We can not derive from another interface, and it is not necessary anyway.
gtype_ = test_Iface_get_type();
- }
+ }
- return *this;
+ return *this;
}
- static void iface_init_function(void* /* g_iface */, void* /* iface_data */)
- {
- }
+ static void iface_init_function(void* /* g_iface */, void* /* iface_data */) {}
- //static Glib::ObjectBase* wrap_new(GObject*);
+ // static Glib::ObjectBase* wrap_new(GObject*);
};
class TestInterface : public Glib::Interface
@@ -107,18 +109,12 @@ class TestInterface : public Glib::Interface
protected:
typedef TestInterface_Class CppClassType;
- TestInterface()
- : Glib::Interface(derived_interface_class_.init())
- {}
+ TestInterface() : Glib::Interface(derived_interface_class_.init()) {}
public:
- //A real application would never make the constructor public.
- //It would instead have a protected constructor and a public create() method.
- TestInterface(GObject* gobject, int i)
- : Glib::Interface(gobject),
- i_(i)
- {
- }
+ // A real application would never make the constructor public.
+ // It would instead have a protected constructor and a public create() method.
+ TestInterface(GObject* gobject, int i) : Glib::Interface(gobject), i_(i) {}
static void add_interface(GType gtype_implementer)
{
@@ -128,10 +124,10 @@ public:
TestInterface(const TestInterface& src) = delete;
TestInterface& operator=(const TestInterface& src) = delete;
- TestInterface(TestInterface&& src) noexcept
- : Glib::Interface(std::move(src)),
- i_(std::move(src.i_))
- {}
+ TestInterface(TestInterface&& src) noexcept : Glib::Interface(std::move(src)),
+ i_(std::move(src.i_))
+ {
+ }
TestInterface& operator=(TestInterface&& src) noexcept
{
@@ -162,14 +158,14 @@ public:
const Glib::Class& init()
{
- if(!gtype_) // create the GType if necessary
+ if (!gtype_) // create the GType if necessary
{
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &DerivedObject_Class::class_init_function;
// This is actually just optimized away, apparently with no harm.
// Make sure that the parent type has been created.
- //CppClassParent::CppObjectType::get_type();
+ // CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
register_derived_type(test_derived_get_type());
@@ -184,15 +180,13 @@ public:
TestInterface::CppClassType TestInterface::derived_interface_class_; // initialize static member
-class DerivedObject
-: public Glib::Object,
- public TestInterface
+class DerivedObject : public Glib::Object, public TestInterface
{
public:
typedef DerivedObject_Class CppClassType;
- //A real application would never make the constructor public.
- //It would instead have a protected constructor and a public create() method.
+ // A real application would never make the constructor public.
+ // It would instead have a protected constructor and a public create() method.
DerivedObject(int i)
: Glib::ObjectBase(nullptr),
Glib::Object(Glib::ConstructParams(derived_object_class_.init())),
@@ -203,11 +197,11 @@ public:
DerivedObject(const DerivedObject& src) = delete;
DerivedObject& operator=(const DerivedObject& src) = delete;
- DerivedObject(DerivedObject&& src) noexcept
- : Glib::Object(std::move(src)),
- TestInterface(std::move(src)),
- i_(std::move(src.i_))
- {}
+ DerivedObject(DerivedObject&& src) noexcept : Glib::Object(std::move(src)),
+ TestInterface(std::move(src)),
+ i_(std::move(src.i_))
+ {
+ }
DerivedObject& operator=(DerivedObject&& src) noexcept
{
@@ -262,9 +256,8 @@ void test_interface_move_assignment_operator()
}
*/
-
-static
-void test_object_with_interface_move_constructor()
+static void
+test_object_with_interface_move_constructor()
{
DerivedObject derived(5);
g_assert_cmpint(derived.i_, ==, 5);
@@ -277,8 +270,8 @@ void test_object_with_interface_move_constructor()
g_assert(derived.gobj() == nullptr);
}
-static
-void test_object_with_interface_move_assignment_operator()
+static void
+test_object_with_interface_move_assignment_operator()
{
DerivedObject derived(5);
g_assert_cmpint(derived.i_, ==, 5);
@@ -292,13 +285,13 @@ void test_object_with_interface_move_assignment_operator()
g_assert(derived.gobj() == nullptr);
}
-
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
- //test_interface_move_constructor();
- //test_interface_move_assignment_operator();
+ // test_interface_move_constructor();
+ // test_interface_move_assignment_operator();
test_object_with_interface_move_constructor();
test_object_with_interface_move_assignment_operator();
diff --git a/tests/glibmm_mainloop/main.cc b/tests/glibmm_mainloop/main.cc
index de1a7514..9a9cf291 100644
--- a/tests/glibmm_mainloop/main.cc
+++ b/tests/glibmm_mainloop/main.cc
@@ -16,10 +16,10 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <cstdlib> // EXIT_SUCCESS, EXIT_FAILURE
#include <glibmm.h>
-#include <thread>
#include <iostream>
-#include <cstdlib> // EXIT_SUCCESS, EXIT_FAILURE
+#include <thread>
namespace
{
@@ -32,37 +32,40 @@ enum InvokeStatus
InvokeStatus invoked_in_thread[2] = { NOT_INVOKED, NOT_INVOKED };
-void quit_loop(const Glib::RefPtr<Glib::MainLoop>& mainloop)
+void
+quit_loop(const Glib::RefPtr<Glib::MainLoop>& mainloop)
{
mainloop->quit();
}
-bool mark_and_quit(const std::thread::id& expected_thread_id,
- int thread_nr, const Glib::RefPtr<Glib::MainLoop>& mainloop)
+bool
+mark_and_quit(const std::thread::id& expected_thread_id, int thread_nr,
+ const Glib::RefPtr<Glib::MainLoop>& mainloop)
{
- invoked_in_thread[thread_nr] =
- (std::this_thread::get_id() == expected_thread_id) ?
- INVOKED_IN_RIGHT_THREAD : INVOKED_IN_WRONG_THREAD;
+ invoked_in_thread[thread_nr] = (std::this_thread::get_id() == expected_thread_id)
+ ? INVOKED_IN_RIGHT_THREAD
+ : INVOKED_IN_WRONG_THREAD;
mainloop->get_context()->signal_idle().connect_once(
sigc::bind(sigc::ptr_fun(quit_loop), mainloop));
return false;
}
-void thread_function(const std::thread::id& first_thread_id,
- const Glib::RefPtr<Glib::MainLoop>& first_mainloop)
+void
+thread_function(
+ const std::thread::id& first_thread_id, const Glib::RefPtr<Glib::MainLoop>& first_mainloop)
{
auto second_context = Glib::MainContext::create();
auto second_mainloop = Glib::MainLoop::create(second_context);
// Show how Glib::MainContext::invoke() can be used for calling a function,
// possibly executed in another thread.
- Glib::MainContext::get_default()->invoke(sigc::bind(sigc::ptr_fun(mark_and_quit),
- first_thread_id, 0, first_mainloop));
+ Glib::MainContext::get_default()->invoke(
+ sigc::bind(sigc::ptr_fun(mark_and_quit), first_thread_id, 0, first_mainloop));
// If this thread owns second_context, invoke() will call mark_and_quit() directly.
bool is_owner = second_context->acquire();
- second_context->invoke(sigc::bind(sigc::ptr_fun(mark_and_quit),
- std::this_thread::get_id(), 1, second_mainloop));
+ second_context->invoke(
+ sigc::bind(sigc::ptr_fun(mark_and_quit), std::this_thread::get_id(), 1, second_mainloop));
if (is_owner)
second_context->release();
@@ -72,7 +75,8 @@ void thread_function(const std::thread::id& first_thread_id,
} // anonymous namespace
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
@@ -109,16 +113,16 @@ int main(int, char**)
case INVOKED_IN_RIGHT_THREAD:
break;
case NOT_INVOKED:
- std::cout << "Function that should be invoked in " << N[i]
- << " thread was not called." << std::endl;
+ std::cout << "Function that should be invoked in " << N[i] << " thread was not called."
+ << std::endl;
break;
case INVOKED_IN_WRONG_THREAD:
std::cout << "Function that should be invoked in " << N[i]
- << " thread was called in another thread." << std::endl;
+ << " thread was called in another thread." << std::endl;
break;
default:
- std::cout << "Unknown value: invoked_in_thread[" << i << "]="
- << invoked_in_thread[i] << std::endl;
+ std::cout << "Unknown value: invoked_in_thread[" << i << "]=" << invoked_in_thread[i]
+ << std::endl;
break;
}
}
diff --git a/tests/glibmm_nodetree/main.cc b/tests/glibmm_nodetree/main.cc
index 61fb8698..d5bdc825 100644
--- a/tests/glibmm_nodetree/main.cc
+++ b/tests/glibmm_nodetree/main.cc
@@ -1,16 +1,18 @@
-#include <iostream>
#include <glibmm.h>
+#include <iostream>
typedef Glib::NodeTree<const std::string> type_nodetree_string;
-static bool node_build_string(type_nodetree_string& node, std::string& string)
+static bool
+node_build_string(type_nodetree_string& node, std::string& string)
{
string += node.data();
return false;
}
-int main()
+int
+main()
{
std::list<std::string> alma;
std::string tstring, cstring;
@@ -31,7 +33,7 @@ int main()
node_B->append_data("E");
node_B->prepend_data("C");
- /* node_D = & */node_B->insert(1, *(new type_nodetree_string("D")));
+ /* node_D = & */ node_B->insert(1, *(new type_nodetree_string("D")));
node_F = new type_nodetree_string("F");
root->append(*node_F);
@@ -54,16 +56,18 @@ int main()
g_assert(node_F->get_max_height() == 3);
g_assert(node_G->child_count() == 4);
g_assert(root->find_child("F", type_nodetree_string::TRAVERSE_ALL) == node_F);
- g_assert(root->find("I", Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES) == NULL);
- g_assert(root->find("J", Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_LEAVES) == node_J);
-
- for(guint i = 0; i < node_B->child_count(); i++)
- {
- node = node_B->nth_child(i);
- g_assert(node->data() == std::string(1, ('C' + i)));
- }
-
- for(guint i = 0; i < node_G->child_count(); i++)
+ g_assert(
+ root->find("I", Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES) == NULL);
+ g_assert(
+ root->find("J", Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_LEAVES) == node_J);
+
+ for (guint i = 0; i < node_B->child_count(); i++)
+ {
+ node = node_B->nth_child(i);
+ g_assert(node->data() == std::string(1, ('C' + i)));
+ }
+
+ for (guint i = 0; i < node_G->child_count(); i++)
g_assert(node_G->child_position(*node_G->nth_child(i)) == (int)i);
/* we have built: A
@@ -79,39 +83,48 @@ int main()
*/
tstring.clear();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_PRE_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_PRE_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == "ABCDEFGHIJK");
tstring.clear();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_POST_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_POST_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == "CDEBHIJKGFA");
tstring.clear();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == "CBDEAHGIJKF");
tstring.clear();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == "ABFCDEGHIJK");
tstring.clear();
-
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_LEAVES, -1);
+
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_LEAVES, -1);
g_assert(tstring == "CDEHIJK");
tstring.clear();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_PRE_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_PRE_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES, -1);
g_assert(tstring == "ABFG");
tstring.clear();
node_B->reverse_children();
node_G->reverse_children();
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == "ABFEDCGKJIH");
tstring.clear();
-
- node = new type_nodetree_string(*root); //A deep copy.
- g_assert(root->node_count(type_nodetree_string::TRAVERSE_ALL) == node->node_count(type_nodetree_string::TRAVERSE_ALL));
+ node = new type_nodetree_string(*root); // A deep copy.
+ g_assert(root->node_count(type_nodetree_string::TRAVERSE_ALL) ==
+ node->node_count(type_nodetree_string::TRAVERSE_ALL));
g_assert(root->get_max_height() == node->get_max_height());
- root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)), Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
- node->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(cstring)), Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ root->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(tstring)),
+ Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
+ node->traverse(sigc::bind(sigc::ptr_fun(node_build_string), sigc::ref(cstring)),
+ Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_ALL, -1);
g_assert(tstring == cstring);
delete node;
@@ -123,12 +136,12 @@ int main()
root = new type_nodetree_string();
node = root;
- for(guint i = 0; i < 2048; i++)
- {
- node->append(*(new type_nodetree_string()));
- if((i % 5) == 4)
- node = node->first_child()->next_sibling();
- }
+ for (guint i = 0; i < 2048; i++)
+ {
+ node->append(*(new type_nodetree_string()));
+ if ((i % 5) == 4)
+ node = node->first_child()->next_sibling();
+ }
g_assert(root->get_max_height() > 100);
g_assert(root->node_count(type_nodetree_string::TRAVERSE_ALL) == 1 + 2048);
diff --git a/tests/glibmm_null_containerhandle/main.cc b/tests/glibmm_null_containerhandle/main.cc
index 52a95e61..33533706 100644
--- a/tests/glibmm_null_containerhandle/main.cc
+++ b/tests/glibmm_null_containerhandle/main.cc
@@ -32,8 +32,8 @@ main()
std::vector<CrePtr> v2(Glib::ArrayHandle<CrePtr>(nullptr, 5, Glib::OWNERSHIP_DEEP));
std::vector<CrePtr> v3(Glib::ListHandle<CrePtr>(nullptr, Glib::OWNERSHIP_DEEP));
std::vector<CrePtr> v4(Glib::SListHandle<CrePtr>(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<bool> v5(Glib::ArrayHandle<bool>(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<bool> v6(Glib::ArrayHandle<bool>(nullptr, 5, Glib::OWNERSHIP_DEEP));
+ std::vector<bool> v5(Glib::ArrayHandle<bool>(nullptr, Glib::OWNERSHIP_DEEP));
+ std::vector<bool> v6(Glib::ArrayHandle<bool>(nullptr, 5, Glib::OWNERSHIP_DEEP));
if (v1.empty() && v2.empty() && v3.empty() && v4.empty() && v5.empty() && v6.empty())
{
diff --git a/tests/glibmm_null_vectorutils/main.cc b/tests/glibmm_null_vectorutils/main.cc
index 711b74db..a686adee 100644
--- a/tests/glibmm_null_vectorutils/main.cc
+++ b/tests/glibmm_null_vectorutils/main.cc
@@ -26,12 +26,15 @@ main()
Gio::init();
typedef Glib::RefPtr<Gio::Credentials> CrePtr;
- std::vector<CrePtr> v1(Glib::ArrayHandler<CrePtr>::array_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<CrePtr> v2(Glib::ArrayHandler<CrePtr>::array_to_vector(nullptr, 5, Glib::OWNERSHIP_DEEP));
+ std::vector<CrePtr> v1(
+ Glib::ArrayHandler<CrePtr>::array_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
+ std::vector<CrePtr> v2(
+ Glib::ArrayHandler<CrePtr>::array_to_vector(nullptr, 5, Glib::OWNERSHIP_DEEP));
std::vector<CrePtr> v3(Glib::ListHandler<CrePtr>::list_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<CrePtr> v4(Glib::SListHandler<CrePtr>::slist_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<bool> v5(Glib::ArrayHandler<bool>::array_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
- std::vector<bool> v6(Glib::ArrayHandler<bool>::array_to_vector(nullptr, 5, Glib::OWNERSHIP_DEEP));
+ std::vector<CrePtr> v4(
+ Glib::SListHandler<CrePtr>::slist_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
+ std::vector<bool> v5(Glib::ArrayHandler<bool>::array_to_vector(nullptr, Glib::OWNERSHIP_DEEP));
+ std::vector<bool> v6(Glib::ArrayHandler<bool>::array_to_vector(nullptr, 5, Glib::OWNERSHIP_DEEP));
if (v1.empty() && v2.empty() && v3.empty() && v4.empty() && v5.empty() && v6.empty())
{
diff --git a/tests/glibmm_object_move/main.cc b/tests/glibmm_object_move/main.cc
index 7868b176..4f34cb73 100644
--- a/tests/glibmm_object_move/main.cc
+++ b/tests/glibmm_object_move/main.cc
@@ -2,45 +2,48 @@
#include <iostream>
#include <stdlib.h>
-//A basic derived GObject, just to test Glib::Object.
-typedef struct {
- GObject parent;
+// A basic derived GObject, just to test Glib::Object.
+typedef struct
+{
+ GObject parent;
} TestDerived;
-typedef struct {
- GObjectClass parent;
+typedef struct
+{
+ GObjectClass parent;
} TestDerivedClass;
-#define TEST_TYPE_DERIVED (test_derived_get_type ())
-#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DERIVED, TestDerived))
-#define TEST_DERIVED_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST ((cls), TEST_TYPE_DERIVED, TestDerivedClass))
-#define TEST_DERIVED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_TYPE_DERIVED (test_derived_get_type())
+#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_DERIVED, TestDerived))
+#define TEST_DERIVED_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST((cls), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_DERIVED_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), TEST_TYPE_DERIVED, TestDerivedClass))
-static void test_derived_class_init (TestDerivedClass *)
-{}
-static void test_derived_init (TestDerived *)
-{}
+static void
+test_derived_class_init(TestDerivedClass*)
+{
+}
+static void
+test_derived_init(TestDerived*)
+{
+}
G_DEFINE_TYPE(TestDerived, test_derived, G_TYPE_OBJECT)
class DerivedObject : public Glib::Object
{
public:
- //A real application would never make the constructor public.
- //It would instead have a protected constructor and a public create() method.
- DerivedObject(GObject* gobject, int i)
- : Glib::Object(gobject),
- i_(i)
- {
- }
+ // A real application would never make the constructor public.
+ // It would instead have a protected constructor and a public create() method.
+ DerivedObject(GObject* gobject, int i) : Glib::Object(gobject), i_(i) {}
DerivedObject(const DerivedObject& src) = delete;
DerivedObject& operator=(const DerivedObject& src) = delete;
- DerivedObject(DerivedObject&& src) noexcept
- : Glib::Object(std::move(src)),
- i_(std::move(src.i_))
- {}
+ DerivedObject(DerivedObject&& src) noexcept : Glib::Object(std::move(src)), i_(std::move(src.i_))
+ {
+ }
DerivedObject& operator=(DerivedObject&& src) noexcept
{
@@ -53,8 +56,8 @@ public:
int i_;
};
-static
-void test_object_move_constructor()
+static void
+test_object_move_constructor()
{
GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObject derived(gobject, 5);
@@ -68,26 +71,25 @@ void test_object_move_constructor()
g_assert(derived.gobj() == nullptr);
}
-
-static
-void test_object_move_assignment_operator()
+static void
+test_object_move_assignment_operator()
{
GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObject derived(gobject, 5);
- //std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
g_assert(derived.gobj() == gobject);
GObject* gobject2 = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObject derived2(gobject2, 6);
derived2 = std::move(derived);
g_assert_cmpint(derived2.i_, ==, 5);
- //std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
g_assert(derived2.gobj() == gobject);
g_assert(derived.gobj() == nullptr);
}
-
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
diff --git a/tests/glibmm_objectbase_move/main.cc b/tests/glibmm_objectbase_move/main.cc
index e70ff3bb..697f3cf5 100644
--- a/tests/glibmm_objectbase_move/main.cc
+++ b/tests/glibmm_objectbase_move/main.cc
@@ -2,36 +2,41 @@
#include <iostream>
#include <stdlib.h>
-//A basic derived GObject, just to test Glib::ObjectBase.
-typedef struct {
- GObject parent;
+// A basic derived GObject, just to test Glib::ObjectBase.
+typedef struct
+{
+ GObject parent;
} TestDerived;
-typedef struct {
- GObjectClass parent;
+typedef struct
+{
+ GObjectClass parent;
} TestDerivedClass;
-#define TEST_TYPE_DERIVED (test_derived_get_type ())
-#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DERIVED, TestDerived))
-#define TEST_DERIVED_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST ((cls), TEST_TYPE_DERIVED, TestDerivedClass))
-#define TEST_DERIVED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_TYPE_DERIVED (test_derived_get_type())
+#define TEST_DERIVED(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_DERIVED, TestDerived))
+#define TEST_DERIVED_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST((cls), TEST_TYPE_DERIVED, TestDerivedClass))
+#define TEST_DERIVED_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), TEST_TYPE_DERIVED, TestDerivedClass))
-static void test_derived_class_init (TestDerivedClass *)
-{}
-static void test_derived_init (TestDerived *)
-{}
+static void
+test_derived_class_init(TestDerivedClass*)
+{
+}
+static void
+test_derived_init(TestDerived*)
+{
+}
G_DEFINE_TYPE(TestDerived, test_derived, G_TYPE_OBJECT)
-
class DerivedObjectBase : public Glib::ObjectBase
{
public:
- //A real application would never make the constructor public.
- //It would instead have a protected constructor and a public create() method.
- DerivedObjectBase(GObject* gobject, int i)
- : Glib::ObjectBase(nullptr),
- i_(i)
+ // A real application would never make the constructor public.
+ // It would instead have a protected constructor and a public create() method.
+ DerivedObjectBase(GObject* gobject, int i) : Glib::ObjectBase(nullptr), i_(i)
{
Glib::ObjectBase::initialize(gobject);
}
@@ -39,9 +44,8 @@ public:
DerivedObjectBase(const DerivedObjectBase& src) = delete;
DerivedObjectBase& operator=(const DerivedObjectBase& src) = delete;
- DerivedObjectBase(DerivedObjectBase&& src) noexcept
- : Glib::ObjectBase(std::move(src)),
- i_(std::move(src.i_))
+ DerivedObjectBase(DerivedObjectBase&& src) noexcept : Glib::ObjectBase(std::move(src)),
+ i_(std::move(src.i_))
{
ObjectBase::initialize_move(src.gobject_, &src);
}
@@ -57,39 +61,40 @@ public:
int i_;
};
-static
-void test_objectbase_move_constructor()
+static void
+test_objectbase_move_constructor()
{
GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObjectBase derived(gobject, 5);
- //std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
g_assert(derived.gobj() == gobject);
DerivedObjectBase derived2(std::move(derived));
g_assert_cmpint(derived2.i_, ==, 5);
- //std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
g_assert(derived2.gobj() == gobject);
g_assert(derived.gobj() == nullptr);
}
-static
-void test_objectbase_move_assignment_operator()
+static void
+test_objectbase_move_assignment_operator()
{
GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObjectBase derived(gobject, 5);
- //std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived.gobj() << std::endl;
g_assert(derived.gobj() == gobject);
GObject* gobject2 = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
DerivedObjectBase derived2(gobject2, 6);
derived2 = std::move(derived);
g_assert_cmpint(derived2.i_, ==, 5);
- //std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
+ // std::cout << "debug: gobj(): " << derived2.gobj() << std::endl;
g_assert(derived2.gobj() == gobject);
g_assert(derived.gobj() == nullptr);
}
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
diff --git a/tests/glibmm_refptr/main.cc b/tests/glibmm_refptr/main.cc
index d03b2249..53a74492 100644
--- a/tests/glibmm_refptr/main.cc
+++ b/tests/glibmm_refptr/main.cc
@@ -1,10 +1,9 @@
// Bug 564005 - Valgrind errors and crash on exit with Gtk::UIManager
// Bug 154498 - Unnecessary warning on console: signalproxy_connectionnode.cc
-
#include <glibmm.h>
-#include <sigc++/sigc++.h>
#include <iostream>
+#include <sigc++/sigc++.h>
#include <stdlib.h>
#define ACTIVATE_BUG 1
@@ -13,17 +12,14 @@
class Something
{
public:
- Something()
- : ref_count_(1),
- max_ref_count_(ref_count_)
- {}
+ Something() : ref_count_(1), max_ref_count_(ref_count_) {}
void reference()
{
++ref_count_;
- //Track the highest-ever max count.
- if(max_ref_count_ < ref_count_)
+ // Track the highest-ever max count.
+ if (max_ref_count_ < ref_count_)
max_ref_count_ = ref_count_;
}
@@ -33,18 +29,11 @@ public:
delete this;
}
- //Just so we can check it in our test.
- int ref_count()
- {
- return ref_count_;
- }
-
- //Just so we can check it in our test.
- int max_ref_count()
- {
- return max_ref_count_;
- }
+ // Just so we can check it in our test.
+ int ref_count() { return ref_count_; }
+ // Just so we can check it in our test.
+ int max_ref_count() { return max_ref_count_; }
private:
int ref_count_;
@@ -72,7 +61,7 @@ public:
{
}
- //Non copyable
+ // Non copyable
Parent(const Parent& src) = delete;
Parent& operator=(const Parent& src) = delete;
@@ -86,35 +75,28 @@ public:
return was_constructed_via_move_constructor_;
}
- int something_ref_count() const
- {
- return something_->ref_count();
- }
+ int something_ref_count() const { return something_->ref_count(); }
- int something_max_ref_count() const
- {
- return something_->max_ref_count();
- }
+ int something_max_ref_count() const { return something_->max_ref_count(); }
private:
Glib::RefPtr<Something> something_;
bool was_constructed_via_copy_constructor_;
bool was_constructed_via_move_constructor_;
-
};
-static
-void test_initial_refcount()
+static void
+test_initial_refcount()
{
- Glib::RefPtr<Something> refSomething (new Something());
+ Glib::RefPtr<Something> refSomething(new Something());
g_assert_cmpint(refSomething->ref_count(), ==, 1);
g_assert_cmpint(refSomething->max_ref_count(), ==, 1);
}
-static
-void test_refptr_copy_constructor()
+static void
+test_refptr_copy_constructor()
{
- Glib::RefPtr<Something> refSomething (new Something());
+ Glib::RefPtr<Something> refSomething(new Something());
g_assert_cmpint(refSomething->ref_count(), ==, 1);
g_assert_cmpint(refSomething->max_ref_count(), ==, 1);
@@ -125,16 +107,16 @@ void test_refptr_copy_constructor()
g_assert_cmpint(refSomething->max_ref_count(), ==, 2);
}
- //Test the refcount after other references should have been released
- //when other RefPtrs went out of scope:
+ // Test the refcount after other references should have been released
+ // when other RefPtrs went out of scope:
g_assert_cmpint(refSomething->ref_count(), ==, 1);
g_assert_cmpint(refSomething->max_ref_count(), ==, 2);
}
-static
-void test_refptr_assignment_operator()
+static void
+test_refptr_assignment_operator()
{
- Glib::RefPtr<Something> refSomething (new Something());
+ Glib::RefPtr<Something> refSomething(new Something());
g_assert_cmpint(refSomething->ref_count(), ==, 1);
g_assert_cmpint(refSomething->max_ref_count(), ==, 1);
@@ -145,59 +127,58 @@ void test_refptr_assignment_operator()
g_assert_cmpint(refSomething->max_ref_count(), ==, 2);
}
- //Test the refcount after other references should have been released
- //when other RefPtrs went out of scope:
+ // Test the refcount after other references should have been released
+ // when other RefPtrs went out of scope:
g_assert_cmpint(refSomething->ref_count(), ==, 1);
g_assert_cmpint(refSomething->max_ref_count(), ==, 2);
}
-
-
-static
-Glib::RefPtr<Something> get_something()
+static Glib::RefPtr<Something>
+get_something()
{
static Glib::RefPtr<Something> something_to_get;
- //Reinitialize it each time:
+ // Reinitialize it each time:
something_to_get = Glib::RefPtr<Something>(new Something());
return something_to_get;
}
-static
-void test_refptr_with_parent_copy_constructor()
+static void
+test_refptr_with_parent_copy_constructor()
{
- //We use get_something() because test_refptr_with_parent_move_constructor() does.
+ // We use get_something() because test_refptr_with_parent_move_constructor() does.
Glib::RefPtr<Something> refSomething = get_something();
- g_assert_cmpint(refSomething->ref_count(), ==, 2); //1 here and 1 inside get_something()
+ g_assert_cmpint(refSomething->ref_count(), ==, 2); // 1 here and 1 inside get_something()
g_assert_cmpint(refSomething->max_ref_count(), ==, 2);
{
Parent parent(refSomething);
g_assert(!parent.was_constructed_via_move_constructor());
g_assert(parent.was_constructed_via_copy_constructor());
- g_assert_cmpint(parent.something_ref_count(), ==, 3); //1 here, 1 in parent, and 1 inside get_something()
+ g_assert_cmpint(
+ parent.something_ref_count(), ==, 3); // 1 here, 1 in parent, and 1 inside get_something()
g_assert_cmpint(parent.something_max_ref_count(), ==, 3);
}
- //Test the refcount after other references should have been released
- //when other RefPtrs went out of scope:
- g_assert_cmpint(refSomething->ref_count(), ==, 2); //1 here and 1 inside get_something()
+ // Test the refcount after other references should have been released
+ // when other RefPtrs went out of scope:
+ g_assert_cmpint(refSomething->ref_count(), ==, 2); // 1 here and 1 inside get_something()
g_assert_cmpint(refSomething->max_ref_count(), ==, 3);
}
-static
-void test_refptr_with_parent_move_constructor()
+static void
+test_refptr_with_parent_move_constructor()
{
Parent parent(get_something());
g_assert(parent.was_constructed_via_move_constructor());
g_assert(!parent.was_constructed_via_copy_constructor());
- g_assert_cmpint(parent.something_ref_count(), ==, 2); //1 in parent and 1 inside get_something()
+ g_assert_cmpint(parent.something_ref_count(), ==, 2); // 1 in parent and 1 inside get_something()
g_assert_cmpint(parent.something_max_ref_count(), ==, 2);
}
-static
-void test_refptr_move_constructor()
+static void
+test_refptr_move_constructor()
{
Glib::RefPtr<Something> refSomething(new Something());
Glib::RefPtr<Something> refSomething2(std::move(refSomething));
@@ -206,8 +187,8 @@ void test_refptr_move_constructor()
g_assert_cmpint(refSomething2->max_ref_count(), ==, 1);
}
-static
-void test_refptr_move_assignment_operator()
+static void
+test_refptr_move_assignment_operator()
{
Glib::RefPtr<Something> refSomething(new Something());
Glib::RefPtr<Something> refSomething2;
@@ -217,8 +198,8 @@ void test_refptr_move_assignment_operator()
g_assert_cmpint(refSomething2->max_ref_count(), ==, 1);
}
-static
-void test_refptr_universal_reference_move_constructor()
+static void
+test_refptr_universal_reference_move_constructor()
{
Glib::RefPtr<SomethingDerived> refSomethingDerived(new SomethingDerived());
Glib::RefPtr<Something> refSomething(std::move(refSomethingDerived));
@@ -227,8 +208,8 @@ void test_refptr_universal_reference_move_constructor()
g_assert_cmpint(refSomething->max_ref_count(), ==, 1);
}
-static
-void test_refptr_universal_reference_asignment_operator()
+static void
+test_refptr_universal_reference_asignment_operator()
{
Glib::RefPtr<SomethingDerived> refSomethingDerived(new SomethingDerived());
Glib::RefPtr<Something> refSomething;
@@ -238,37 +219,38 @@ void test_refptr_universal_reference_asignment_operator()
g_assert_cmpint(refSomething->max_ref_count(), ==, 1);
}
-int main(int, char**)
+int
+main(int, char**)
{
- //Test initial refcount:
+ // Test initial refcount:
test_initial_refcount();
- //Test refcount when using the RefPtr copy constructor:
+ // Test refcount when using the RefPtr copy constructor:
test_refptr_copy_constructor();
- //Test refcount when using the RefPtr assignment operator (operator=):
+ // Test refcount when using the RefPtr assignment operator (operator=):
test_refptr_assignment_operator();
- //Test the refcount when using the RefPtr move constuctor:
+ // Test the refcount when using the RefPtr move constuctor:
test_refptr_move_constructor();
- //Test the refcount when using the RefPtr move asignment operator (operator=):
+ // Test the refcount when using the RefPtr move asignment operator (operator=):
test_refptr_move_assignment_operator();
- //Test the refcount when another class makes a copy via its constructor:
+ // Test the refcount when another class makes a copy via its constructor:
test_refptr_with_parent_copy_constructor();
- //Test the refcount when another class makes a copy via its
+ // Test the refcount when another class makes a copy via its
//(perfect-forwarding) move constructor, which should not involve a temporary
- //instance:
- test_refptr_with_parent_move_constructor();
+ // instance:
+ test_refptr_with_parent_move_constructor();
- //Test the refcount when using the RefPtr move constructor with derived class
- //as an argument.
+ // Test the refcount when using the RefPtr move constructor with derived class
+ // as an argument.
test_refptr_universal_reference_move_constructor();
- //Test the refcount when using the RefPtr assignment operator (operator=)
- //with derived class as an argument.
+ // Test the refcount when using the RefPtr assignment operator (operator=)
+ // with derived class as an argument.
test_refptr_universal_reference_asignment_operator();
return EXIT_SUCCESS;
diff --git a/tests/glibmm_refptr_sigc_bind/main.cc b/tests/glibmm_refptr_sigc_bind/main.cc
index 38fe93b1..7d3546a0 100644
--- a/tests/glibmm_refptr_sigc_bind/main.cc
+++ b/tests/glibmm_refptr_sigc_bind/main.cc
@@ -1,10 +1,9 @@
// Bug 564005 - Valgrind errors and crash on exit with Gtk::UIManager
// Bug 154498 - Unnecessary warning on console: signalproxy_connectionnode.cc
-
#include <glibmm/refptr.h>
-#include <sigc++/sigc++.h>
#include <iostream>
+#include <sigc++/sigc++.h>
#include <stdlib.h>
#define ACTIVATE_BUG 1
@@ -12,10 +11,14 @@
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); }
@@ -24,17 +27,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)
{
- //std::cout << "new Test" << std::endl;
-#ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c15s
+// std::cout << "new Test" << std::endl;
+#ifdef ACTIVATE_BUG // See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c15s
action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action));
#else
Glib::RefPtr<Action> action2(new Action);
@@ -44,19 +45,20 @@ public:
~Test()
{
- //std::cout << "delete Test" << std::endl;
+ // std::cout << "delete Test" << std::endl;
}
void on_sig1(int /* n */, Glib::RefPtr<Action> /* action */)
{
- //std::cout << "Test::on_sig1, n=" << n << std::endl;
+ // std::cout << "Test::on_sig1, n=" << n << std::endl;
}
-
+
Glib::RefPtr<Action> action;
}; // end Test
-int main(int, char**)
+int
+main(int, char**)
{
Test* test = new Test;
diff --git a/tests/glibmm_ustring_compose/main.cc b/tests/glibmm_ustring_compose/main.cc
index 7248c891..5457e8ea 100644
--- a/tests/glibmm_ustring_compose/main.cc
+++ b/tests/glibmm_ustring_compose/main.cc
@@ -2,35 +2,40 @@
#include <iostream>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
- //TODO: Check the output?
- const char *constant_string = "constant string";
+ // TODO: Check the output?
+ const char* constant_string = "constant string";
ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal")
+ << std::endl;
ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567)
+ << std::endl;
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
+ ostr << Glib::ustring::compose(
+ "Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo"))
+ << std::endl;
int i = 1;
ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
- ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
+ ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16))
+ << std::endl;
- //TODO: More tests.
+ // TODO: More tests.
return EXIT_SUCCESS;
}
-
diff --git a/tests/glibmm_ustring_format/main.cc b/tests/glibmm_ustring_format/main.cc
index 3f44a531..0925f84c 100644
--- a/tests/glibmm_ustring_format/main.cc
+++ b/tests/glibmm_ustring_format/main.cc
@@ -2,12 +2,13 @@
#include <iostream>
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
char carr[10] = "Užduotys";
- char * const cptr = carr;
+ char* const cptr = carr;
/*
std::wostringstream wsout;
@@ -20,10 +21,10 @@ int main(int, char**)
std::cout << data[i] << std::endl;
*/
- //Check both the const char* and char* versions.
+ // Check both the const char* and char* versions.
Glib::ustring::format(carr);
- //This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
+ // This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
Glib::ustring::format(cptr);
return EXIT_SUCCESS;
diff --git a/tests/glibmm_value/glibmm_value.cc b/tests/glibmm_value/glibmm_value.cc
index b3bf759a..1f598a3e 100644
--- a/tests/glibmm_value/glibmm_value.cc
+++ b/tests/glibmm_value/glibmm_value.cc
@@ -11,22 +11,22 @@ namespace Gtk
class Widget;
}
-void some_method()
+void
+some_method()
{
-// custom copyable
+ // custom copyable
Glib::Value<Foo> value_foo;
// custom pointer
Glib::Value<Foo*> value_foo_pointer;
Glib::Value<const Foo*> value_foo_const_pointer;
-// Glib::Object pointer
+ // Glib::Object pointer
Glib::Value<Gtk::Widget*> value_widget_pointer;
Glib::Value<const Gtk::Widget*> value_widget_const_pointer;
}
// Glib::Object RefPtr<>
-//template Glib::Value< Glib::RefPtr<Gdk::Pixbuf> >;
-//template Glib::Value< Glib::RefPtr<const Gdk::Pixbuf> >;
-
+// template Glib::Value< Glib::RefPtr<Gdk::Pixbuf> >;
+// template Glib::Value< Glib::RefPtr<const Gdk::Pixbuf> >;
diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc
index cc2b374f..7682ffd0 100644
--- a/tests/glibmm_value/main.cc
+++ b/tests/glibmm_value/main.cc
@@ -1,8 +1,8 @@
#include <glibmm.h>
-int main(int, char**)
+int
+main(int, char**)
{
return EXIT_SUCCESS;
}
-
diff --git a/tests/glibmm_valuearray/main.cc b/tests/glibmm_valuearray/main.cc
index ca111432..b9fc12a6 100644
--- a/tests/glibmm_valuearray/main.cc
+++ b/tests/glibmm_valuearray/main.cc
@@ -6,7 +6,8 @@
#include <iostream>
#ifdef GLIBMM_DISABLE_DEPRECATED
-int main(int, char**)
+int
+main(int, char**)
{
// If glibmm is configured with --disable-deprecated-api, GLIBMM_DISABLE_DEPRECATED
// is defined in glibmm.h (actually in glibmmconfig.h). The undef at the start of
@@ -16,30 +17,32 @@ int main(int, char**)
#else
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
-int on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2)
+int
+on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2)
{
- const Glib::Value<int>& intVal1 = static_cast< const Glib::Value<int>& >(v1);
- const Glib::Value<int>& intVal2 = static_cast< const Glib::Value<int>& >(v2);
+ const Glib::Value<int>& intVal1 = static_cast<const Glib::Value<int>&>(v1);
+ const Glib::Value<int>& intVal2 = static_cast<const Glib::Value<int>&>(v2);
int int1 = intVal1.get();
int int2 = intVal2.get();
- if(int1 < int2)
+ if (int1 < int2)
return -1;
- else if(int1 == int2)
+ else if (int1 == int2)
return EXIT_SUCCESS;
else
return 1;
}
-int main(int, char**)
+int
+main(int, char**)
{
const int VALUES_COUNT = 10;
@@ -48,7 +51,7 @@ int main(int, char**)
Glib::Value<int> values[VALUES_COUNT];
Glib::ValueArray array;
- for(int i = 0; i < VALUES_COUNT; i++)
+ for (int i = 0; i < VALUES_COUNT; i++)
{
values[i].init(Glib::Value<int>::value_type());
values[i].set(i + 1); // (i + 1) ==> Set to natural counting numbers.
@@ -57,19 +60,18 @@ int main(int, char**)
ostr << "Array members before sorting:" << std::endl;
- for(int i = 0; i < VALUES_COUNT; i++)
+ for (int i = 0; i < VALUES_COUNT; i++)
{
Glib::ValueBase value;
- if(!array.get_nth(i, value))
+ if (!array.get_nth(i, value))
{
- std::cerr << "Error getting element " << i << " of value array." <<
- std::endl;
+ std::cerr << "Error getting element " << i << " of value array." << std::endl;
return EXIT_FAILURE;
break;
}
- auto int_val = static_cast< Glib::Value<int>& >(value);
+ auto int_val = static_cast<Glib::Value<int>&>(value);
ostr << int_val.get() << " ";
}
ostr << std::endl; // End of line for list of array elements.
@@ -77,26 +79,24 @@ int main(int, char**)
// Sort array and remove last element:
array.sort(sigc::ptr_fun(&on_compare)).remove(VALUES_COUNT - 1);
- ostr << "Array members after sorting without last element:" <<
- std::endl;
+ ostr << "Array members after sorting without last element:" << std::endl;
- for(int i = 0; i < VALUES_COUNT - 1; i++)
+ for (int i = 0; i < VALUES_COUNT - 1; i++)
{
Glib::ValueBase value;
- if(!array.get_nth(i, value))
+ if (!array.get_nth(i, value))
{
- std::cerr << "Error getting element " << i << " of value array." <<
- std::endl;
+ std::cerr << "Error getting element " << i << " of value array." << std::endl;
return EXIT_FAILURE;
break;
}
- auto int_val = static_cast< Glib::Value<int>& >(value);
+ auto int_val = static_cast<Glib::Value<int>&>(value);
ostr << int_val.get() << " ";
}
ostr << std::endl; // End of line for list of array elements.
return EXIT_SUCCESS;
}
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc
index bf17d143..e5877a87 100644
--- a/tests/glibmm_variant/main.cc
+++ b/tests/glibmm_variant/main.cc
@@ -1,76 +1,70 @@
#include <glibmm.h>
#include <iostream>
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
+// This seems nicer and more useful than putting an ifdef around the use of ostr:
std::stringstream debug;
std::ostream& ostr = debug;
static void test_variant_floating();
static void test_dynamic_cast();
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
- //vector<int>:
- const int int_list[] = {1, 2, 3, 4, 5, 6, 7, 8};
+ // vector<int>:
+ const int int_list[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
- std::vector<int> int_vector(int_list,
- int_list + sizeof(int_list) / sizeof(int));
+ std::vector<int> int_vector(int_list, int_list + sizeof(int_list) / sizeof(int));
ostr << "The elements of the original vector are:" << std::endl;
- for(guint i = 0; i < int_vector.size(); i++)
+ for (guint i = 0; i < int_vector.size(); i++)
ostr << int_vector[i] << std::endl;
- auto integers_variant =
- Glib::Variant< std::vector<int> >::create(int_vector);
+ auto integers_variant = Glib::Variant<std::vector<int>>::create(int_vector);
auto int_vector2 = integers_variant.get();
- ostr << "The size of the copied vector is " << int_vector2.size() <<
- '.' << std::endl;
+ ostr << "The size of the copied vector is " << int_vector2.size() << '.' << std::endl;
ostr << "The elements of the copied vector are:" << std::endl;
- for(guint i = 0; i < int_vector2.size(); i++)
+ for (guint i = 0; i < int_vector2.size(); i++)
ostr << int_vector2[i] << std::endl;
- ostr << "The number of children in the iterator of the " <<
- "variant are " << integers_variant.get_iter().get_n_children() <<
- '.' << std::endl;
+ ostr << "The number of children in the iterator of the "
+ << "variant are " << integers_variant.get_iter().get_n_children() << '.' << std::endl;
unsigned index = 4;
- ostr << "Element number " << index + 1 << " in the copy is " <<
- integers_variant.get_child(index) << '.' << std::endl;
+ ostr << "Element number " << index + 1 << " in the copy is " << integers_variant.get_child(index)
+ << '.' << std::endl;
ostr << std::endl;
-
-
- //vector<std::string>:
- std::vector<std::string> vec_strings = {"a"};
- auto variant_vec_strings =
- Glib::Variant<std::vector<std::string> >::create(vec_strings);
- //Dict:
+ // vector<std::string>:
+ std::vector<std::string> vec_strings = { "a" };
+ auto variant_vec_strings = Glib::Variant<std::vector<std::string>>::create(vec_strings);
+
+ // Dict:
typedef std::pair<Glib::ustring, Glib::ustring> TypeDictEntry;
TypeDictEntry dict_entry("A key", "A value");
- ostr << "The original dictionary entry is (" << dict_entry.first <<
- ", " << dict_entry.second << ")." << std::endl;
+ ostr << "The original dictionary entry is (" << dict_entry.first << ", " << dict_entry.second
+ << ")." << std::endl;
- auto dict_entry_variant =
- Glib::Variant<TypeDictEntry>::create(dict_entry);
+ auto dict_entry_variant = Glib::Variant<TypeDictEntry>::create(dict_entry);
TypeDictEntry copy_entry = dict_entry_variant.get();
- ostr << "The copy dictionary entry is (" << copy_entry.first <<
- ", " << copy_entry.second << ")." << std::endl;
+ ostr << "The copy dictionary entry is (" << copy_entry.first << ", " << copy_entry.second << ")."
+ << std::endl;
ostr << std::endl;
@@ -78,7 +72,7 @@ int main(int, char**)
TypeDict orig_dict;
- for(unsigned i = 0; i < 10; i++)
+ for (unsigned i = 0; i < 10; i++)
{
std::string x_repeated(i, 'x');
orig_dict.insert(std::pair<unsigned, Glib::ustring>(i, x_repeated));
@@ -86,19 +80,18 @@ int main(int, char**)
ostr << "The original dictionary:" << std::endl;
- for(unsigned i = 0; i < orig_dict.size(); i++)
+ for (unsigned i = 0; i < orig_dict.size(); i++)
{
ostr << "(" << i << ", " << orig_dict[i] << ")." << std::endl;
}
- auto orig_dict_variant =
- Glib::Variant<TypeDict>::create(orig_dict);
+ auto orig_dict_variant = Glib::Variant<TypeDict>::create(orig_dict);
TypeDict dict_copy = orig_dict_variant.get();
ostr << "The copy of the dictionary:" << std::endl;
- for(unsigned i = 0; i < dict_copy.size(); i++)
+ for (unsigned i = 0; i < dict_copy.size(); i++)
{
ostr << "(" << i << ", " << dict_copy[i] << ")." << std::endl;
}
@@ -107,25 +100,24 @@ int main(int, char**)
auto a_pair = orig_dict_variant.get_child(index);
- ostr << "Element number " << index + 1 << " in the variant is: (" <<
- a_pair.first << ", " << a_pair.second << ")." << std::endl;
-
+ ostr << "Element number " << index + 1 << " in the variant is: (" << a_pair.first << ", "
+ << a_pair.second << ")." << std::endl;
Glib::ustring value;
- if(orig_dict_variant.lookup(index, value))
+ if (orig_dict_variant.lookup(index, value))
{
- ostr << "The x's of element number " << index + 1 <<
- " in the variant are: " << value << '.' << std::endl;
+ ostr << "The x's of element number " << index + 1 << " in the variant are: " << value << '.'
+ << std::endl;
}
- //std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
- typedef std::map< Glib::ustring, Glib::Variant<int> > ComplexDictType;
+ // std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
+ typedef std::map<Glib::ustring, Glib::Variant<int>> ComplexDictType;
ComplexDictType complex_dict1;
ComplexDictType complex_dict2;
- for(int i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
// Convert integer i to string.
std::stringstream ss;
@@ -135,144 +127,130 @@ int main(int, char**)
auto v = Glib::Variant<int>::create(i);
- complex_dict1.insert(
- std::pair< Glib::ustring, Glib::Variant<int> >("Map 1 " + s, v));
+ complex_dict1.insert(std::pair<Glib::ustring, Glib::Variant<int>>("Map 1 " + s, v));
- complex_dict2.insert(
- std::pair< Glib::ustring, Glib::Variant<int> >("Map 2 " + s, v));
+ complex_dict2.insert(std::pair<Glib::ustring, Glib::Variant<int>>("Map 2 " + s, v));
}
- typedef std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
- ComplexVecType;
+ typedef std::vector<std::map<Glib::ustring, Glib::Variant<int>>> ComplexVecType;
- ComplexVecType complex_vector = {complex_dict1, complex_dict2};
+ ComplexVecType complex_vector = { complex_dict1, complex_dict2 };
- auto complex_variant =
- Glib::Variant<ComplexVecType>::create(complex_vector);
+ auto complex_variant = Glib::Variant<ComplexVecType>::create(complex_vector);
// This will output the type string aa{sv}.
ostr << "The type string of the variant containing a vector of "
- "dictionaries is: " << std::endl << complex_variant.get_type_string() <<
- "." << std::endl << std::endl;
+ "dictionaries is: "
+ << std::endl
+ << complex_variant.get_type_string() << "." << std::endl
+ << std::endl;
ComplexVecType copy_complex_vector = complex_variant.get();
- for(guint i = 0; i < copy_complex_vector.size(); i++)
+ for (guint i = 0; i < copy_complex_vector.size(); i++)
{
ostr << "Printing dictionary # " << i + 1 << ":" << std::endl;
ComplexDictType map = copy_complex_vector[i];
- for(const auto& entry : map)
+ for (const auto& entry : map)
{
ostr << entry.first << " -> " << entry.second.get() << "." << std::endl;
}
ostr << std::endl;
}
-
+
test_variant_floating();
test_dynamic_cast();
return EXIT_SUCCESS;
}
-//Test casting of multiple types to a ustring:
-static void test_dynamic_cast_ustring_types()
+// Test casting of multiple types to a ustring:
+static void
+test_dynamic_cast_ustring_types()
{
- Glib::VariantBase vbase_string = Glib::wrap(
- g_variant_new("s", "somestring"));
+ Glib::VariantBase vbase_string = Glib::wrap(g_variant_new("s", "somestring"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_string);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(vbase_string);
ostr << "Casted string Glib::Variant<Glib::ustring>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
-
- Glib::VariantBase vbase_objectpath = Glib::wrap(
- g_variant_new_object_path("/remote/object/path"));
+ Glib::VariantBase vbase_objectpath = Glib::wrap(g_variant_new_object_path("/remote/object/path"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_objectpath);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(vbase_objectpath);
ostr << "Casted object path Glib::Variant<Glib::ustring>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
- Glib::VariantBase vbase_signature = Glib::wrap(
- g_variant_new_signature("aas"));
+ Glib::VariantBase vbase_signature = Glib::wrap(g_variant_new_signature("aas"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_signature);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(vbase_signature);
ostr << "Casted signature Glib::Variant<Glib::ustring>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
}
-
-//Test casting of multiple types to a std::string:
-static void test_dynamic_cast_string_types()
+// Test casting of multiple types to a std::string:
+static void
+test_dynamic_cast_string_types()
{
- Glib::VariantBase vbase_string = Glib::wrap(
- g_variant_new("s", "somestring"));
+ Glib::VariantBase vbase_string = Glib::wrap(g_variant_new("s", "somestring"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_string);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<std::string>>(vbase_string);
ostr << "Casted string Glib::Variant<std::string>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
-
- Glib::VariantBase vbase_objectpath = Glib::wrap(
- g_variant_new_object_path("/remote/object/path"));
+ Glib::VariantBase vbase_objectpath = Glib::wrap(g_variant_new_object_path("/remote/object/path"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_objectpath);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<std::string>>(vbase_objectpath);
ostr << "Casted object path Glib::Variant<std::string>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
- Glib::VariantBase vbase_signature = Glib::wrap(
- g_variant_new_signature("aas"));
+ Glib::VariantBase vbase_signature = Glib::wrap(g_variant_new_signature("aas"));
try
{
- auto derived =
- Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_signature);
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<std::string>>(vbase_signature);
ostr << "Casted signature Glib::Variant<std::string>: " << derived.get() << std::endl;
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
g_assert_not_reached();
}
}
// Test casting a complicated type, containing an object path and a DBus type signature.
-void test_dynamic_cast_composite_types()
+void
+test_dynamic_cast_composite_types()
{
// Build a GVaraint of type a{oag}, and cast it to
// Glib::Variant<std::map<Glib::ustring, std::vector<std::string>>>.
@@ -283,23 +261,22 @@ void test_dynamic_cast_composite_types()
g_variant_builder_init(&dict_builder, G_VARIANT_TYPE("a{oag}"));
g_variant_builder_init(&array_builder, G_VARIANT_TYPE("ag"));
- g_variant_builder_add(&array_builder, "g","id");
- g_variant_builder_add(&array_builder, "g","isi");
- g_variant_builder_add(&array_builder, "g","ia{si}");
+ g_variant_builder_add(&array_builder, "g", "id");
+ g_variant_builder_add(&array_builder, "g", "isi");
+ g_variant_builder_add(&array_builder, "g", "ia{si}");
g_variant_builder_add(&dict_builder, "{oag}", "/remote/object/path1", &array_builder);
g_variant_builder_init(&array_builder, G_VARIANT_TYPE("ag"));
- g_variant_builder_add(&array_builder, "g","i(d)");
- g_variant_builder_add(&array_builder, "g","i(si)");
+ g_variant_builder_add(&array_builder, "g", "i(d)");
+ g_variant_builder_add(&array_builder, "g", "i(si)");
g_variant_builder_add(&dict_builder, "{oag}", "/remote/object/path2", &array_builder);
Glib::VariantBase cppdict(g_variant_builder_end(&dict_builder));
try
{
- typedef std::map<Glib::ustring, std::vector<std::string> > composite_type;
- auto derived =
- Glib::VariantBase::cast_dynamic<Glib::Variant<composite_type> >(cppdict);
+ typedef std::map<Glib::ustring, std::vector<std::string>> composite_type;
+ auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<composite_type>>(cppdict);
ostr << "Cast composite type (get_type_string()=" << derived.get_type_string()
<< ", variant_type().get_string()=" << derived.variant_type().get_string() << "): ";
@@ -321,7 +298,7 @@ void test_dynamic_cast_composite_types()
try
{
auto derived =
- Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, std::string> > >(cppdict);
+ Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, std::string>>>(cppdict);
g_assert_not_reached();
}
catch (const std::bad_cast& e)
@@ -329,28 +306,29 @@ void test_dynamic_cast_composite_types()
}
}
-static void test_dynamic_cast()
+static void
+test_dynamic_cast()
{
auto v1 = Glib::Variant<int>::create(10);
Glib::VariantBase& v2 = v1;
- auto v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v2);
+ auto v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(v2);
g_assert(v3.get() == 10);
Glib::VariantBase v5 = v1;
- v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v5);
+ v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(v5);
g_assert(v3.get() == 10);
Glib::Variant<double> v4;
// v4 contain a NULL GVariant: The cast succeed
- v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v4);
+ v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(v4);
v4 = Glib::Variant<double>::create(1.0);
try
{
- v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v4);
+ v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(v4);
g_assert_not_reached();
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
}
@@ -362,14 +340,14 @@ static void test_dynamic_cast()
g_assert(var_tuple.get_type_string() == "(is)");
v5 = var_tuple;
- Glib::VariantContainerBase v6 = Glib::VariantBase::cast_dynamic<Glib::VariantContainerBase >(v5);
+ Glib::VariantContainerBase v6 = Glib::VariantBase::cast_dynamic<Glib::VariantContainerBase>(v5);
try
{
- v6 = Glib::VariantBase::cast_dynamic<Glib::VariantContainerBase >(v1);
+ v6 = Glib::VariantBase::cast_dynamic<Glib::VariantContainerBase>(v1);
g_assert_not_reached();
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
}
@@ -380,8 +358,7 @@ static void test_dynamic_cast()
type_dict_sv var_map;
type_map_sv map;
- auto var_string =
- Glib::Variant<Glib::ustring>::create("test variant");
+ auto var_string = Glib::Variant<Glib::ustring>::create("test variant");
map["test key"] = var_string;
var_map = type_dict_sv::create(map);
g_assert(var_map.get_type_string() == "a{sv}");
@@ -392,22 +369,22 @@ static void test_dynamic_cast()
try
{
auto var_wrong_map =
- Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, Glib::ustring> > >(ref_var_base);
+ Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, Glib::ustring>>>(
+ ref_var_base);
g_assert_not_reached();
}
- catch(const std::bad_cast& e)
+ catch (const std::bad_cast& e)
{
}
type_map_sv get_map = var_map_cast.get();
- var_string = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring> >(get_map["test key"]);
+ var_string = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(get_map["test key"]);
g_assert(var_string.get() == "test variant");
// A variant of type v
auto var_v = Glib::Variant<Glib::VariantBase>::create(var_string);
g_assert(var_v.get_type_string() == "v");
- auto var_s2 =
- Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring> >(var_v.get());
+ auto var_s2 = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(var_v.get());
g_assert(var_s2.get() == "test variant");
test_dynamic_cast_ustring_types();
@@ -418,26 +395,25 @@ static void test_dynamic_cast()
static GLogLevelFlags
get_log_flags()
{
- return static_cast<GLogLevelFlags>(static_cast<unsigned>(G_LOG_LEVEL_CRITICAL) | static_cast<unsigned>(G_LOG_LEVEL_WARNING));
+ return static_cast<GLogLevelFlags>(
+ static_cast<unsigned>(G_LOG_LEVEL_CRITICAL) | static_cast<unsigned>(G_LOG_LEVEL_WARNING));
}
struct WarnCatcher
{
WarnCatcher(const std::string& domain)
- : m_domain(domain)
- , m_old_flags(g_log_set_fatal_mask(m_domain.c_str(), get_log_flags()))
- {}
-
- ~WarnCatcher()
+ : m_domain(domain), m_old_flags(g_log_set_fatal_mask(m_domain.c_str(), get_log_flags()))
{
- g_log_set_fatal_mask(m_domain.c_str(), m_old_flags);
}
+ ~WarnCatcher() { g_log_set_fatal_mask(m_domain.c_str(), m_old_flags); }
+
std::string m_domain;
GLogLevelFlags m_old_flags;
};
-static void test_variant_floating()
+static void
+test_variant_floating()
{
WarnCatcher warn_catcher("GLib");
diff --git a/tests/glibmm_vector/main.cc b/tests/glibmm_vector/main.cc
index 9d78c8c8..e4e779c8 100644
--- a/tests/glibmm_vector/main.cc
+++ b/tests/glibmm_vector/main.cc
@@ -28,10 +28,10 @@
// utilities
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
+// Use this line if you want debug output:
+// std::ostream& ostr = std::cout;
-//This seems nicer and more useful than putting an ifdef around the use of std::cout:
+// This seems nicer and more useful than putting an ifdef around the use of std::cout:
std::stringstream debug;
std::ostream& ostr = debug;
@@ -42,7 +42,7 @@ create_list()
{
GList* head = nullptr;
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
head = g_list_prepend(head, g_credentials_new());
}
@@ -55,12 +55,12 @@ print_list(GList* list)
{
unsigned int counter(1);
- for(GList* node(list); node; node = node->next, ++counter)
+ for (GList *node(list); node; node = node->next, ++counter)
{
ostr << counter << ": ";
- if(G_IS_CREDENTIALS(node->data))
+ if (G_IS_CREDENTIALS(node->data))
{
- ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
+ ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count << "\n";
}
else
{
@@ -74,7 +74,7 @@ create_slist()
{
GSList* head = nullptr;
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
head = g_slist_prepend(head, g_credentials_new());
}
@@ -87,12 +87,12 @@ print_slist(GSList* slist)
{
unsigned int counter(1);
- for(GSList* node(slist); node; node = node->next, ++counter)
+ for (GSList *node(slist); node; node = node->next, ++counter)
{
ostr << counter << ": ";
- if(G_IS_CREDENTIALS(node->data))
+ if (G_IS_CREDENTIALS(node->data))
{
- ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count <<"\n";
+ ostr << node->data << ", ref: " << G_OBJECT(node->data)->ref_count << "\n";
}
else
{
@@ -106,7 +106,7 @@ create_array()
{
GCredentials** array = g_new0(GCredentials*, magic_limit + 1);
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
array[iter] = g_credentials_new();
}
@@ -116,14 +116,15 @@ create_array()
void
print_array(GCredentials** array)
{
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
GCredentials* credentials(array[iter]);
ostr << iter + 1 << ": ";
- if(G_IS_CREDENTIALS(credentials))
+ if (G_IS_CREDENTIALS(credentials))
{
- ostr << reinterpret_cast<gpointer>(credentials) << ", ref: " << G_OBJECT(credentials)->ref_count << "\n";
+ ostr << reinterpret_cast<gpointer>(credentials)
+ << ", ref: " << G_OBJECT(credentials)->ref_count << "\n";
}
else
{
@@ -138,7 +139,7 @@ copy_array(GCredentials** array)
{
GCredentials** dup = g_new0(GCredentials*, magic_limit + 1);
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
dup[iter] = array[iter];
}
@@ -149,31 +150,31 @@ copy_array(GCredentials** array)
void
free_array(GCredentials** array, bool container_too = true)
{
- for(unsigned int iter(0); iter < magic_limit; ++iter)
+ for (unsigned int iter(0); iter < magic_limit; ++iter)
{
g_object_unref(array[iter]);
}
- if(container_too)
+ if (container_too)
{
g_free(array);
}
}
void
-print_vector(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
+print_vector(const std::vector<Glib::RefPtr<Gio::Credentials>>& v)
{
const unsigned int size(v.size());
- for(unsigned int iter(0); iter < size; ++iter)
+ for (unsigned int iter(0); iter < size; ++iter)
{
const Glib::RefPtr<Gio::Credentials>& obj_ptr(v[iter]);
ostr << iter + 1 << ": ";
- if(obj_ptr)
+ if (obj_ptr)
{
GCredentials* gobj(obj_ptr->gobj());
- if(G_IS_CREDENTIALS(gobj))
+ if (G_IS_CREDENTIALS(gobj))
{
ostr << static_cast<gpointer>(gobj) << ", ref: " << G_OBJECT(gobj)->ref_count << "\n";
}
@@ -192,47 +193,31 @@ print_vector(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
struct Cache
{
public:
- Cache()
- : glist_(create_list()),
- gslist_(create_slist()),
- garray_(create_array())
- {}
+ Cache() : glist_(create_list()), gslist_(create_slist()), garray_(create_array()) {}
~Cache()
{
- if(glist_)
+ if (glist_)
{
g_list_foreach(glist_, reinterpret_cast<GFunc>(g_object_unref), nullptr);
g_list_free(glist_);
}
- if(gslist_)
+ if (gslist_)
{
g_slist_foreach(gslist_, reinterpret_cast<GFunc>(g_object_unref), nullptr);
g_slist_free(gslist_);
}
- if(garray_)
+ if (garray_)
{
free_array(garray_);
}
}
- GList*
- get_list() const
- {
- return glist_;
- }
+ GList* get_list() const { return glist_; }
- GSList*
- get_slist() const
- {
- return gslist_;
- }
+ GSList* get_slist() const { return gslist_; }
- GCredentials**
- get_array() const
- {
- return garray_;
- }
+ GCredentials** get_array() const { return garray_; }
private:
// just in case
@@ -334,7 +319,7 @@ c_take_list_members(GList* list)
void
c_take_list_nothing(GList* list)
{
- if(list)
+ if (list)
{
print_list(list);
}
@@ -366,7 +351,7 @@ c_take_list_members(GSList* slist)
void
c_take_slist_nothing(GSList* slist)
{
- if(slist)
+ if (slist)
{
print_slist(slist);
}
@@ -397,7 +382,7 @@ c_take_array_members(GCredentials** array)
void
c_take_array_nothing(GCredentials** array)
{
- if(array)
+ if (array)
{
print_array(array);
}
@@ -405,58 +390,67 @@ c_take_array_nothing(GCredentials** array)
// C++ wrappers.
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_deep_owned_list()
{
- return Glib::ListHandler<Glib::RefPtr<Gio::Credentials> >::list_to_vector(c_get_deep_owned_list(), Glib::OWNERSHIP_NONE);
+ return Glib::ListHandler<Glib::RefPtr<Gio::Credentials>>::list_to_vector(
+ c_get_deep_owned_list(), Glib::OWNERSHIP_NONE);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_shallow_owned_list()
{
- return Glib::ListHandler<Glib::RefPtr<Gio::Credentials> >::list_to_vector(c_get_shallow_owned_list(), Glib::OWNERSHIP_SHALLOW);
+ return Glib::ListHandler<Glib::RefPtr<Gio::Credentials>>::list_to_vector(
+ c_get_shallow_owned_list(), Glib::OWNERSHIP_SHALLOW);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_unowned_list()
{
- return Glib::ListHandler<Glib::RefPtr<Gio::Credentials> >::list_to_vector(c_get_unowned_list(), Glib::OWNERSHIP_DEEP);
+ return Glib::ListHandler<Glib::RefPtr<Gio::Credentials>>::list_to_vector(
+ c_get_unowned_list(), Glib::OWNERSHIP_DEEP);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_deep_owned_slist()
{
- return Glib::SListHandler<Glib::RefPtr<Gio::Credentials> >::slist_to_vector(c_get_deep_owned_slist(), Glib::OWNERSHIP_NONE);
+ return Glib::SListHandler<Glib::RefPtr<Gio::Credentials>>::slist_to_vector(
+ c_get_deep_owned_slist(), Glib::OWNERSHIP_NONE);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_shallow_owned_slist()
{
- return Glib::SListHandler<Glib::RefPtr<Gio::Credentials> >::slist_to_vector(c_get_shallow_owned_slist(), Glib::OWNERSHIP_SHALLOW);
+ return Glib::SListHandler<Glib::RefPtr<Gio::Credentials>>::slist_to_vector(
+ c_get_shallow_owned_slist(), Glib::OWNERSHIP_SHALLOW);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_unowned_slist()
{
- return Glib::SListHandler<Glib::RefPtr<Gio::Credentials> >::slist_to_vector(c_get_unowned_slist(), Glib::OWNERSHIP_DEEP);
+ return Glib::SListHandler<Glib::RefPtr<Gio::Credentials>>::slist_to_vector(
+ c_get_unowned_slist(), Glib::OWNERSHIP_DEEP);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_deep_owned_array()
{
- return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials> >::array_to_vector(c_get_deep_owned_array(), Glib::OWNERSHIP_NONE);
+ return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials>>::array_to_vector(
+ c_get_deep_owned_array(), Glib::OWNERSHIP_NONE);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_shallow_owned_array()
{
- return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials> >::array_to_vector(c_get_shallow_owned_array(), Glib::OWNERSHIP_SHALLOW);
+ return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials>>::array_to_vector(
+ c_get_shallow_owned_array(), Glib::OWNERSHIP_SHALLOW);
}
-std::vector<Glib::RefPtr<Gio::Credentials> >
+std::vector<Glib::RefPtr<Gio::Credentials>>
cxx_get_unowned_array()
{
- return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials> >::array_to_vector(c_get_unowned_array(), Glib::OWNERSHIP_DEEP);
+ return Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials>>::array_to_vector(
+ c_get_unowned_array(), Glib::OWNERSHIP_DEEP);
}
/* they are probably buggy by design...
@@ -474,9 +468,9 @@ cxx_list_take_members(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
*/
void
-cxx_list_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
+cxx_list_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials>>& v)
{
- c_take_list_nothing(Glib::ListHandler<Glib::RefPtr<Gio::Credentials> >::vector_to_list(v).data());
+ c_take_list_nothing(Glib::ListHandler<Glib::RefPtr<Gio::Credentials>>::vector_to_list(v).data());
}
/* they are probably buggy by design...
@@ -489,14 +483,16 @@ cxx_slist_take_all(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
void
cxx_slist_take_members(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
{
- c_take_slist_members(Glib::SListHandler<Glib::RefPtr<Gio::Credentials> >::vector_to_slist(v).data());
+ c_take_slist_members(Glib::SListHandler<Glib::RefPtr<Gio::Credentials>
+>::vector_to_slist(v).data());
}
*/
void
-cxx_slist_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
+cxx_slist_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials>>& v)
{
- c_take_slist_nothing(Glib::SListHandler<Glib::RefPtr<Gio::Credentials> >::vector_to_slist(v).data());
+ c_take_slist_nothing(
+ Glib::SListHandler<Glib::RefPtr<Gio::Credentials>>::vector_to_slist(v).data());
}
/* they are probably buggy by design...
@@ -509,17 +505,18 @@ cxx_array_take_all(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
void
cxx_array_take_members(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
{
- c_take_array_members(Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials> >::vector_to_array(v).data());
+ c_take_array_members(Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials>
+>::vector_to_array(v).data());
}
*/
void
-cxx_array_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials> >& v)
+cxx_array_take_nothing(const std::vector<Glib::RefPtr<Gio::Credentials>>& v)
{
- c_take_array_nothing(Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials> >::vector_to_array(v).data());
+ c_take_array_nothing(
+ Glib::ArrayHandler<Glib::RefPtr<Gio::Credentials>>::vector_to_array(v).data());
}
-
int
main()
{
@@ -558,30 +555,30 @@ main()
ostr << "Cache array after:\n";
print_array(cache.get_array());
- std::vector<Glib::RefPtr<Gio::Credentials> > v(cxx_get_unowned_list());
+ std::vector<Glib::RefPtr<Gio::Credentials>> v(cxx_get_unowned_list());
ostr << "Gotten vector before:\n";
print_vector(v);
// I am wondering if C functions wrapped by the ones below are not buggy by
// design. Anyway - it segfaults. Maybe the test case is just wrong.
- //ostr << "Take list all:\n";
- //cxx_list_take_all(v);
- //ostr << "Take list members:\n";
- //cxx_list_take_members(v);
+ // ostr << "Take list all:\n";
+ // cxx_list_take_all(v);
+ // ostr << "Take list members:\n";
+ // cxx_list_take_members(v);
ostr << "Take list nothing:\n";
cxx_list_take_nothing(v);
// Ditto.
- //ostr << "Take slist all:\n";
- //cxx_slist_take_all(v);
- //ostr << "Take slist members:\n";
- //cxx_slist_take_members(v);
+ // ostr << "Take slist all:\n";
+ // cxx_slist_take_all(v);
+ // ostr << "Take slist members:\n";
+ // cxx_slist_take_members(v);
ostr << "Take slist nothing:\n";
cxx_slist_take_nothing(v);
// Ditto.
- //ostr << "Take array all:\n";
- //cxx_array_take_all(v);
- //ostr << "Take array members:\n";
- //cxx_array_take_members(v);
+ // ostr << "Take array all:\n";
+ // cxx_array_take_all(v);
+ // ostr << "Take array members:\n";
+ // cxx_array_take_members(v);
ostr << "Take array nothing:\n";
cxx_array_take_nothing(v);
ostr << "Gotten vector after:\n";
diff --git a/tests/glibmm_weakref/main.cc b/tests/glibmm_weakref/main.cc
index fdf935cc..20a80310 100644
--- a/tests/glibmm_weakref/main.cc
+++ b/tests/glibmm_weakref/main.cc
@@ -14,22 +14,23 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <glibmm.h>
+#include <cstring>
#include <giomm.h> //There is no class derived from Glib::Object in glibmm
+#include <glibmm.h>
#include <iostream>
-#include <cstring>
#include <utility> // std::move
-int main(int, char**)
+int
+main(int, char**)
{
Glib::init();
bool success = true;
// A Glib::WeakRef cannot be created from a Glib::RefPtr<Glib::Bytes>,
// because Glib::Bytes is not derived from Glib::ObjectBase.
- //const int bdata = 1234;
- //Glib::RefPtr<Glib::Bytes> bytes = Glib::Bytes::create(&bdata, sizeof bdata);
- //Glib::WeakRef<Glib::Bytes> weakbytes = bytes; // does not compile
+ // const int bdata = 1234;
+ // Glib::RefPtr<Glib::Bytes> bytes = Glib::Bytes::create(&bdata, sizeof bdata);
+ // Glib::WeakRef<Glib::Bytes> weakbytes = bytes; // does not compile
// Gio::MemoryInputStream
Glib::RefPtr<Gio::MemoryInputStream> memstream1 = Gio::MemoryInputStream::create();