Commit 97590d60 authored by Simon McVittie's avatar Simon McVittie
Browse files

test: Compare integers using g_assert_cmpint(), g_assert_cmpuint()



Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 6f9838a8
......@@ -3333,67 +3333,67 @@ _dbus_gobject_test (const char *test_data_dir)
/* DoNothing */
arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
&(dbus_glib_internal_test_methods[0]));
g_assert (*arg == '\0');
g_assert_cmpint (*arg, ==, '\0');
/* Increment */
arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
&(dbus_glib_internal_test_methods[1]));
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert_cmpstr (arg_name, ==, "x");
g_assert (arg_in == TRUE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert (arg_in == FALSE);
g_assert (retval == RETVAL_NONE);
g_assert_cmpint (retval, ==, RETVAL_NONE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg == '\0');
g_assert_cmpint (*arg, ==, '\0');
/* IncrementRetval */
arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
&(dbus_glib_internal_test_methods[2]));
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert_cmpstr (arg_name, ==, "x");
g_assert (arg_in == TRUE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert (retval == RETVAL_NOERROR);
g_assert_cmpint (retval, ==, RETVAL_NOERROR);
g_assert (arg_in == FALSE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg == '\0');
g_assert_cmpint (*arg, ==, '\0');
/* IncrementRetvalError */
arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
&(dbus_glib_internal_test_methods[3]));
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert_cmpstr (arg_name, ==, "x");
g_assert (arg_in == TRUE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert (retval == RETVAL_ERROR);
g_assert_cmpint (retval, ==, RETVAL_ERROR);
g_assert (arg_in == FALSE);
g_assert_cmpstr (arg_signature, ==, "u");
g_assert (*arg == '\0');
g_assert_cmpint (*arg, ==, '\0');
/* Stringify */
arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
&(dbus_glib_internal_test_methods[8]));
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert_cmpstr (arg_name, ==, "val");
g_assert (arg_in == TRUE);
g_assert_cmpstr (arg_signature, ==, "v");
g_assert (*arg != '\0');
g_assert_cmpint (*arg, !=, '\0');
arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
g_assert (retval == RETVAL_NONE);
g_assert_cmpint (retval, ==, RETVAL_NONE);
g_assert (arg_in == FALSE);
g_assert_cmpstr (arg_signature, ==, "s");
g_assert (*arg == '\0');
g_assert_cmpint (*arg, ==, '\0');
sigdata = dbus_glib_internal_test_object_info.exported_signals;
g_assert (*sigdata != '\0');
......
......@@ -2036,7 +2036,7 @@ assert_type_maps_to (GType gtype, const char *expected_sig)
static void
assert_signature_maps_to (const char *sig, GType expected_gtype)
{
g_assert (_dbus_gtype_from_signature (sig, TRUE) == expected_gtype);
g_assert_cmpuint (_dbus_gtype_from_signature (sig, TRUE), ==, expected_gtype);
}
static void
......@@ -2074,26 +2074,26 @@ _dbus_gvalue_test (const char *test_data_dir)
DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_TYPE_INT32_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING );
rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
g_assert (rectype != G_TYPE_INVALID);
g_assert_cmpuint (rectype, !=, G_TYPE_INVALID);
g_assert_cmpstr (g_type_name (rectype), ==, "GArray_guint_");
type = _dbus_gtype_from_signature ("au", TRUE);
g_assert (type == rectype);
g_assert_cmpuint (type, ==, rectype);
rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING);
g_assert (rectype != G_TYPE_INVALID);
g_assert_cmpuint (rectype, !=, G_TYPE_INVALID);
g_assert_cmpstr (g_type_name (rectype), ==, "GHashTable_gchararray+gchararray_");
type = _dbus_gtype_from_signature ("a{ss}", TRUE);
g_assert (type == rectype);
g_assert_cmpuint (type, ==, rectype);
type = _dbus_gtype_from_signature ("o", FALSE);
g_assert (type == DBUS_TYPE_G_OBJECT_PATH);
g_assert_cmpuint (type, ==, DBUS_TYPE_G_OBJECT_PATH);
type = _dbus_gtype_from_signature ("o", TRUE);
g_assert (type == DBUS_TYPE_G_OBJECT_PATH);
g_assert_cmpuint (type, ==, DBUS_TYPE_G_OBJECT_PATH);
type = _dbus_gtype_from_signature ("g", TRUE);
g_assert (type == DBUS_TYPE_G_SIGNATURE);
g_assert_cmpuint (type, ==, DBUS_TYPE_G_SIGNATURE);
return TRUE;
}
......
......@@ -50,7 +50,7 @@ frobnicate_signal_handler (DBusGProxy *proxy, int val, void *user_data)
{
n_times_frobnicate_received += 1;
g_assert (val == 42);
g_assert_cmpint (val, ==, 42);
g_main_loop_quit (loop);
g_source_remove (exit_timeout);
......
......@@ -169,7 +169,7 @@ frobnicate_signal_handler (DBusGProxy *proxy,
{
n_times_frobnicate_received += 1;
g_assert (val == 42);
g_assert_cmpint (val, ==, 42);
g_print ("Got Frobnicate signal\n");
g_main_loop_quit (loop);
......@@ -183,7 +183,7 @@ frobnicate_signal_handler_2 (DBusGProxy *proxy,
{
n_times_frobnicate_received_2 += 1;
g_assert (val == 42);
g_assert_cmpint (val, ==, 42);
g_print ("Got Frobnicate signal (again)\n");
}
......@@ -194,7 +194,7 @@ frobnicate_signal_handler_compat (DBusGProxy *proxy,
{
n_times_compat_frobnicate_received += 1;
g_assert (val == 42);
g_assert_cmpint (val, ==, 42);
g_print ("Got Frobnicate signal (compat)\n");
g_main_loop_quit (loop);
......@@ -212,7 +212,7 @@ sig0_signal_handler (DBusGProxy *proxy,
g_assert_cmpstr (str0, ==, "foo");
g_assert (val == 22);
g_assert_cmpint (val, ==, 22);
g_assert_cmpstr (str1, ==, "moo");
......@@ -249,7 +249,7 @@ sig2_signal_handler (DBusGProxy *proxy,
{
n_times_sig2_received += 1;
g_assert (g_hash_table_size (table) == 2);
g_assert_cmpuint (g_hash_table_size (table), ==, 2);
g_assert_nonnull (g_hash_table_lookup (table, "baz"));
g_assert_cmpstr (g_hash_table_lookup (table, "baz"), ==, "cow");
......@@ -1200,10 +1200,10 @@ main (int argc, char **argv)
lose_gerror ("Failed to complete SendCar call", error);
g_assert_nonnull (vals_ret);
g_assert (vals_ret->n_values == 2);
g_assert_cmpuint (vals_ret->n_values, ==, 2);
g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0)));
g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)), ==, 43);
g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH);
g_assert_cmpstr ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ==,
......@@ -1261,7 +1261,7 @@ main (int argc, char **argv)
lose_gerror ("Failed to complete ManyStringify call", error);
g_assert_nonnull (ret_table);
g_assert (g_hash_table_size (ret_table) == 2);
g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2);
val = g_hash_table_lookup (ret_table, "foo");
g_assert_nonnull (val);
......@@ -1313,18 +1313,18 @@ main (int argc, char **argv)
g_ptr_array_free (in_array, TRUE);
g_assert_nonnull (out_array);
g_assert (out_array->len == 2);
g_assert_cmpuint (out_array->len, ==, 2);
uints = g_ptr_array_index (out_array, 0);
g_assert_nonnull (uints);
g_assert (uints->len == 3);
g_assert (g_array_index (uints, guint, 0) == 10);
g_assert (g_array_index (uints, guint, 1) == 42);
g_assert (g_array_index (uints, guint, 2) == 27);
g_assert_cmpuint (uints->len, ==, 3);
g_assert_cmpuint (g_array_index (uints, guint, 0), ==, 10);
g_assert_cmpuint (g_array_index (uints, guint, 1), ==, 42);
g_assert_cmpuint (g_array_index (uints, guint, 2), ==, 27);
g_array_free (uints, TRUE);
uints = g_ptr_array_index (out_array, 1);
g_assert_nonnull (uints);
g_assert (uints->len == 1);
g_assert (g_array_index (uints, guint, 0) == 30);
g_assert_cmpuint (uints->len, ==, 1);
g_assert_cmpuint (g_array_index (uints, guint, 0), ==, 30);
g_array_free (uints, TRUE);
g_ptr_array_free (out_array, TRUE);
}
......@@ -1521,11 +1521,11 @@ main (int argc, char **argv)
lose_gerror ("Failed to complete DictOfDicts call", error);
g_assert_nonnull (ret_table);
g_assert (g_hash_table_size (ret_table) == 2);
g_assert_cmpuint (g_hash_table_size (ret_table), ==, 2);
subtable = g_hash_table_lookup (ret_table, "dict1");
g_assert_nonnull (subtable);
g_assert (g_hash_table_size (subtable) == 3);
g_assert_cmpuint (g_hash_table_size (subtable), ==, 3);
val = g_hash_table_lookup (subtable, "foo");
g_assert_nonnull (val);
......@@ -1541,7 +1541,7 @@ main (int argc, char **argv)
subtable = g_hash_table_lookup (ret_table, "dict2");
g_assert_nonnull (subtable);
g_assert (g_hash_table_size (subtable) == 3);
g_assert_cmpuint (g_hash_table_size (subtable), ==, 3);
val = g_hash_table_lookup (subtable, "foo");
g_assert_nonnull (val);
......@@ -2102,7 +2102,7 @@ main (int argc, char **argv)
G_TYPE_VALUE, &value, G_TYPE_INVALID))
lose_gerror ("Failed to complete GetProperty no-touching call", error);
g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT));
g_assert (g_value_get_uint (&value) == 42);
g_assert_cmpuint (g_value_get_uint (&value), ==, 42);
g_value_unset (&value);
}
......@@ -2130,7 +2130,7 @@ main (int argc, char **argv)
G_TYPE_VALUE, &value, G_TYPE_INVALID))
lose_gerror ("Failed to complete GetProperty call", error);
g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT));
g_assert (g_value_get_uint (&value) == 42);
g_assert_cmpuint (g_value_get_uint (&value), ==, 42);
g_value_unset (&value);
}
......
......@@ -613,7 +613,7 @@ read_and_drop_on_floor (int fd,
char *allocated;
char not_allocated[512+PAYLOAD_SIZE];
g_assert (count < (int) sizeof(not_allocated));
g_assert_cmpint (count, <, (int) sizeof (not_allocated));
if (fake_malloc_overhead)
{
......@@ -671,7 +671,7 @@ write_junk (int fd,
char *allocated;
char not_allocated[512+PAYLOAD_SIZE] = { '\0', };
g_assert (count < (int) sizeof(not_allocated));
g_assert_cmpint (count, <, (int) sizeof (not_allocated));
if (fake_malloc_overhead)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment