diff options
author | Christian Persch <chpe@gnome.org> | 2012-02-15 18:37:06 +0100 |
---|---|---|
committer | Christian Persch <chpe@gnome.org> | 2012-02-15 18:44:24 +0100 |
commit | 6c7d121caf0fc19804670b8e98ae5e1c9abf6a76 (patch) | |
tree | 707c7e1c12abd41f68d542f9f49bbc9e2e312167 /glib/tests/mappedfile.c | |
parent | 4471d09cd4628eacd46d5bd299a4c7aa8e8fec77 (diff) | |
download | glib-wip/mapped-bytes.tar.gz |
gbytes: Replace GMappedFile with GBytes in glibwip/mapped-bytes
Don't use deprecated APIs inside glib!
Diffstat (limited to 'glib/tests/mappedfile.c')
-rw-r--r-- | glib/tests/mappedfile.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/glib/tests/mappedfile.c b/glib/tests/mappedfile.c index 5387a643f..1c979c3fb 100644 --- a/glib/tests/mappedfile.c +++ b/glib/tests/mappedfile.c @@ -13,30 +13,30 @@ static void test_basic (void) { - GMappedFile *file; + GBytes *file; GError *error; error = NULL; file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error); g_assert_no_error (error); - g_mapped_file_ref (file); - g_mapped_file_unref (file); + g_bytes_ref (file); + g_bytes_unref (file); - g_mapped_file_unref (file); + g_bytes_unref (file); } static void test_empty (void) { - GMappedFile *file; + GBytes *file; GError *error; error = NULL; file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error); g_assert_no_error (error); - g_assert (g_mapped_file_get_contents (file) == NULL); + g_assert (g_bytes_get_data (file, NULL) == NULL); g_mapped_file_free (file); } @@ -45,7 +45,7 @@ static void test_device (void) { GError *error = NULL; - GMappedFile *file; + GBytes *file; file = g_mapped_file_new ("/dev/null", FALSE, &error); g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_INVAL); @@ -56,7 +56,7 @@ test_device (void) static void test_nonexisting (void) { - GMappedFile *file; + GBytes *file; GError *error; error = NULL; @@ -69,9 +69,10 @@ test_nonexisting (void) static void test_writable (void) { - GMappedFile *file; + GBytes *file; GError *error; gchar *contents; + gsize size; const gchar *old = "MMMMMMMMMMMMMMMMMMMMMMMMM"; const gchar *new = "abcdefghijklmnopqrstuvxyz"; @@ -85,7 +86,8 @@ test_writable (void) file = g_mapped_file_new (SRCDIR "/4096-random-bytes", TRUE, &error); g_assert_no_error (error); - contents = g_mapped_file_get_contents (file); + contents = (gchar *) g_bytes_get_data (file, &size); + g_assert_cmpint (size, ==, 4096); g_assert (strncmp (contents, old, strlen (old)) == 0); memcpy (contents, new, strlen (new)); @@ -97,7 +99,8 @@ test_writable (void) file = g_mapped_file_new (SRCDIR "/4096-random-bytes", TRUE, &error); g_assert_no_error (error); - contents = g_mapped_file_get_contents (file); + contents = (gchar *) g_bytes_get_data (file, &size); + g_assert_cmpint (size, ==, 4096); g_assert (strncmp (contents, old, strlen (old)) == 0); g_mapped_file_free (file); @@ -106,9 +109,10 @@ test_writable (void) static void test_writable_fd (void) { - GMappedFile *file; + GBytes *file; GError *error; gchar *contents; + gsize size; const gchar *old = "MMMMMMMMMMMMMMMMMMMMMMMMM"; const gchar *new = "abcdefghijklmnopqrstuvxyz"; int fd; @@ -125,7 +129,8 @@ test_writable_fd (void) file = g_mapped_file_new_from_fd (fd, TRUE, &error); g_assert_no_error (error); - contents = g_mapped_file_get_contents (file); + contents = (gchar *) g_bytes_get_data (file, &size); + g_assert_cmpint (size, ==, 4096); g_assert (strncmp (contents, old, strlen (old)) == 0); memcpy (contents, new, strlen (new)); @@ -140,11 +145,11 @@ test_writable_fd (void) file = g_mapped_file_new_from_fd (fd, TRUE, &error); g_assert_no_error (error); - contents = g_mapped_file_get_contents (file); + contents = (gchar *) g_bytes_get_data (file, &size); + g_assert_cmpint (size, ==, 4096); g_assert (strncmp (contents, old, strlen (old)) == 0); g_mapped_file_free (file); - } int |