tests: Always check an address is valid before checking it’s supported

This gets us extra test coverage for free.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-03-15 14:22:15 +00:00
parent e458b0168e
commit 685d605832

View File

@ -44,6 +44,8 @@ assert_is_supported_address (const gchar *address)
{ {
GError *error = NULL; GError *error = NULL;
g_assert_true (g_dbus_is_address (address));
g_assert_true (g_dbus_is_supported_address (address, NULL)); g_assert_true (g_dbus_is_supported_address (address, NULL));
g_assert_true (g_dbus_is_supported_address (address, &error)); g_assert_true (g_dbus_is_supported_address (address, &error));
g_assert_no_error (error); g_assert_no_error (error);
@ -54,6 +56,8 @@ assert_not_supported_address (const gchar *address)
{ {
GError *error = NULL; GError *error = NULL;
g_assert_true (g_dbus_is_address (address));
g_assert_false (g_dbus_is_supported_address (address, NULL)); g_assert_false (g_dbus_is_supported_address (address, NULL));
g_assert_false (g_dbus_is_supported_address (address, &error)); g_assert_false (g_dbus_is_supported_address (address, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
@ -67,10 +71,8 @@ test_unix_address (void)
assert_not_supported_address ("some-imaginary-transport:foo=bar"); assert_not_supported_address ("some-imaginary-transport:foo=bar");
assert_is_supported_address ("unix:path=/tmp/dbus-test"); assert_is_supported_address ("unix:path=/tmp/dbus-test");
assert_is_supported_address ("unix:abstract=/tmp/dbus-another-test"); assert_is_supported_address ("unix:abstract=/tmp/dbus-another-test");
g_assert_true (g_dbus_is_address ("unix:foo=bar"));
assert_not_supported_address ("unix:foo=bar"); assert_not_supported_address ("unix:foo=bar");
g_assert_false (g_dbus_is_address ("unix:path=/foo;abstract=/bar")); g_assert_false (g_dbus_is_address ("unix:path=/foo;abstract=/bar"));
assert_not_supported_address ("unix:path=/foo;abstract=/bar");
assert_is_supported_address ("unix:path=/tmp/concrete;unix:abstract=/tmp/abstract"); assert_is_supported_address ("unix:path=/tmp/concrete;unix:abstract=/tmp/abstract");
g_assert_true (g_dbus_is_address ("some-imaginary-transport:foo=bar")); g_assert_true (g_dbus_is_address ("some-imaginary-transport:foo=bar"));