[glib: 6/13] tests: Convert g_assert() to g_assert_*() in glib/tests/mappedfile.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/13] tests: Convert g_assert() to g_assert_*() in glib/tests/mappedfile.c
- Date: Fri, 8 Mar 2019 20:00:23 +0000 (UTC)
commit ba84f45f9640e037cf132e4e0b4fe0b7ecf17507
Author: Philip Withnall <withnall endlessm com>
Date: Tue Mar 5 10:58:09 2019 +0000
tests: Convert g_assert() to g_assert_*() in glib/tests/mappedfile.c
g_assert_*() give more informative failure messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.
Signed-off-by: Philip Withnall <withnall endlessm com>
glib/tests/mappedfile.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/glib/tests/mappedfile.c b/glib/tests/mappedfile.c
index 828a4f38a..b263143ec 100644
--- a/glib/tests/mappedfile.c
+++ b/glib/tests/mappedfile.c
@@ -40,7 +40,7 @@ test_empty (void)
file = g_mapped_file_new (g_test_get_filename (G_TEST_DIST, "empty", NULL), FALSE, &error);
g_assert_no_error (error);
- g_assert (g_mapped_file_get_contents (file) == NULL);
+ g_assert_null (g_mapped_file_get_contents (file));
g_mapped_file_free (file);
}
@@ -53,10 +53,10 @@ test_device (void)
GMappedFile *file;
file = g_mapped_file_new ("/dev/null", FALSE, &error);
- g_assert (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_INVAL) ||
- g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NODEV) ||
- g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM));
- g_assert (file == NULL);
+ g_assert_true (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_INVAL) ||
+ g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NODEV) ||
+ g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM));
+ g_assert_null (file);
g_error_free (error);
}
#endif
@@ -71,7 +71,7 @@ test_nonexisting (void)
file = g_mapped_file_new ("no-such-file", FALSE, &error);
g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
g_clear_error (&error);
- g_assert (file == NULL);
+ g_assert_null (file);
}
static void
@@ -98,10 +98,10 @@ test_writable (void)
g_assert_no_error (error);
contents = g_mapped_file_get_contents (file);
- g_assert (strncmp (contents, old, strlen (old)) == 0);
+ g_assert_cmpuint (strncmp (contents, old, strlen (old)), ==, 0);
memcpy (contents, new, strlen (new));
- g_assert (strncmp (contents, new, strlen (new)) == 0);
+ g_assert_cmpuint (strncmp (contents, new, strlen (new)), ==, 0);
g_mapped_file_free (file);
@@ -110,7 +110,7 @@ test_writable (void)
g_assert_no_error (error);
contents = g_mapped_file_get_contents (file);
- g_assert (strncmp (contents, old, strlen (old)) == 0);
+ g_assert_cmpuint (strncmp (contents, old, strlen (old)), ==, 0);
g_mapped_file_free (file);
@@ -139,27 +139,27 @@ test_writable_fd (void)
g_free (contents);
fd = g_open (tmp_copy_path, O_RDWR, 0);
- g_assert (fd != -1);
+ g_assert_cmpint (fd, !=, -1);
file = g_mapped_file_new_from_fd (fd, TRUE, &error);
g_assert_no_error (error);
contents = g_mapped_file_get_contents (file);
- g_assert (strncmp (contents, old, strlen (old)) == 0);
+ g_assert_cmpuint (strncmp (contents, old, strlen (old)), ==, 0);
memcpy (contents, new, strlen (new));
- g_assert (strncmp (contents, new, strlen (new)) == 0);
+ g_assert_cmpuint (strncmp (contents, new, strlen (new)), ==, 0);
g_mapped_file_free (file);
close (fd);
error = NULL;
fd = g_open (tmp_copy_path, O_RDWR, 0);
- g_assert (fd != -1);
+ g_assert_cmpint (fd, !=, -1);
file = g_mapped_file_new_from_fd (fd, TRUE, &error);
g_assert_no_error (error);
contents = g_mapped_file_get_contents (file);
- g_assert (strncmp (contents, old, strlen (old)) == 0);
+ g_assert_cmpuint (strncmp (contents, old, strlen (old)), ==, 0);
g_mapped_file_free (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]