mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-11 11:44:03 +02:00
Merge branch 'gir-disable-asserts' into 'main'
girepository: Ignore set-but-not-used warnings with G_DISABLE_ASSERT See merge request GNOME/glib!3707
This commit is contained in:
@@ -40,7 +40,7 @@ build (void)
|
|||||||
|
|
||||||
c = cmph_new (config);
|
c = cmph_new (config);
|
||||||
size = cmph_size (c);
|
size = cmph_size (c);
|
||||||
g_assert (size == g_strv_length (strings));
|
g_assert_cmpuint (size, ==, g_strv_length (strings));
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ assert_hashes_unique (guint n_hashes,
|
|||||||
for (j = 0; j < n_hashes; j++)
|
for (j = 0; j < n_hashes; j++)
|
||||||
{
|
{
|
||||||
if (j != i)
|
if (j != i)
|
||||||
g_assert (hashes[i] != hashes[j]);
|
g_assert_cmpuint (hashes[i], !=, hashes[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,15 +75,18 @@ test_search (void)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
hash = cmph_search (c, "foo", 3);
|
hash = cmph_search (c, "foo", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
hash = cmph_search (c, "bar", 3);
|
hash = cmph_search (c, "bar", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
hash = cmph_search (c, "baz", 3);
|
hash = cmph_search (c, "baz", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]);
|
assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]);
|
||||||
@@ -111,15 +114,18 @@ test_search_packed (void)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
hash = cmph_search_packed (buf, "foo", 3);
|
hash = cmph_search_packed (buf, "foo", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
hash = cmph_search_packed (buf, "bar", 3);
|
hash = cmph_search_packed (buf, "bar", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
hash = cmph_search_packed (buf, "baz", 3);
|
hash = cmph_search_packed (buf, "baz", 3);
|
||||||
g_assert (hash >= 0 && hash < size);
|
g_assert_cmpuint (hash, >=, 0);
|
||||||
|
g_assert_cmpuint (hash, <, size);
|
||||||
hashes[i++] = hash;
|
hashes[i++] = hash;
|
||||||
|
|
||||||
assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]);
|
assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]);
|
||||||
|
@@ -1314,6 +1314,9 @@ compare_version (const char *v1,
|
|||||||
success = parse_version (v2, &v2_major, &v2_minor);
|
success = parse_version (v2, &v2_major, &v2_minor);
|
||||||
g_assert (success);
|
g_assert (success);
|
||||||
|
|
||||||
|
/* Avoid a compiler warning about `success` being unused with G_DISABLE_ASSERT */
|
||||||
|
(void) success;
|
||||||
|
|
||||||
if (v1_major > v2_major)
|
if (v1_major > v2_major)
|
||||||
return 1;
|
return 1;
|
||||||
else if (v2_major > v1_major)
|
else if (v2_major > v1_major)
|
||||||
|
@@ -413,6 +413,7 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib,
|
|||||||
void
|
void
|
||||||
gi_typelib_check_sanity (void)
|
gi_typelib_check_sanity (void)
|
||||||
{
|
{
|
||||||
|
#ifndef G_DISABLE_ASSERT
|
||||||
/* Check that struct layout is as we expect */
|
/* Check that struct layout is as we expect */
|
||||||
|
|
||||||
gboolean size_check_ok = TRUE;
|
gboolean size_check_ok = TRUE;
|
||||||
@@ -461,6 +462,7 @@ gi_typelib_check_sanity (void)
|
|||||||
#undef CHECK_SIZE
|
#undef CHECK_SIZE
|
||||||
|
|
||||||
g_assert (size_check_ok);
|
g_assert (size_check_ok);
|
||||||
|
#endif /* !G_DISABLE_ASSERT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -152,7 +152,9 @@ gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint3
|
|||||||
guint16 *table;
|
guint16 *table;
|
||||||
GHashTableIter hashiter;
|
GHashTableIter hashiter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
#ifndef G_DISABLE_ASSERT
|
||||||
guint32 num_elts;
|
guint32 num_elts;
|
||||||
|
#endif
|
||||||
guint8 *packed_mem;
|
guint8 *packed_mem;
|
||||||
|
|
||||||
g_return_if_fail (builder != NULL);
|
g_return_if_fail (builder != NULL);
|
||||||
@@ -170,7 +172,9 @@ gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint3
|
|||||||
|
|
||||||
table = (guint16*) (mem + builder->dirmap_offset);
|
table = (guint16*) (mem + builder->dirmap_offset);
|
||||||
|
|
||||||
|
#ifndef G_DISABLE_ASSERT
|
||||||
num_elts = g_hash_table_size (builder->strings);
|
num_elts = g_hash_table_size (builder->strings);
|
||||||
|
#endif
|
||||||
g_hash_table_iter_init (&hashiter, builder->strings);
|
g_hash_table_iter_init (&hashiter, builder->strings);
|
||||||
while (g_hash_table_iter_next (&hashiter, &key, &value))
|
while (g_hash_table_iter_next (&hashiter, &key, &value))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user