From 24776cb5bdb3d4c14a05609e76ca7e8bc9a9c2a2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 Nov 2023 10:36:06 +0000 Subject: [PATCH] tests: Use g_assert_*() rather than g_assert() in girepository tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It won’t get compiled out with `G_DISABLE_ASSERT`. Signed-off-by: Philip Withnall --- girepository/cmph-bdz-test.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/girepository/cmph-bdz-test.c b/girepository/cmph-bdz-test.c index cf74f1a52..64e664688 100644 --- a/girepository/cmph-bdz-test.c +++ b/girepository/cmph-bdz-test.c @@ -40,7 +40,7 @@ build (void) c = cmph_new (config); size = cmph_size (c); - g_assert (size == g_strv_length (strings)); + g_assert_cmpuint (size, ==, g_strv_length (strings)); return c; } @@ -57,7 +57,7 @@ assert_hashes_unique (guint n_hashes, for (j = 0; j < n_hashes; j++) { 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; 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; 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; 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; assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]); @@ -111,15 +114,18 @@ test_search_packed (void) i = 0; 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; 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; 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; assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]);