11 file = g_mapped_file_new (SRCDIR "/empty", FALSE, &error);
12 g_assert_no_error (error);
14 g_assert (g_mapped_file_get_contents (file) == NULL);
16 g_mapped_file_free (file);
20 test_nonexisting (void)
26 file = g_mapped_file_new ("no-such-file", FALSE, &error);
27 g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
28 g_clear_error (&error);
29 g_assert (file == NULL);
38 const gchar *old = "MMMMMMMMMMMMMMMMMMMMMMMMM";
39 const gchar *new = "abcdefghijklmnopqrstuvxyz";
42 file = g_mapped_file_new (SRCDIR "/4096-random-bytes", TRUE, &error);
43 g_assert_no_error (error);
45 contents = g_mapped_file_get_contents (file);
46 g_assert (strncmp (contents, old, strlen (old)) == 0);
48 memcpy (contents, new, strlen (new));
49 g_assert (strncmp (contents, new, strlen (new)) == 0);
51 g_mapped_file_free (file);
54 file = g_mapped_file_new (SRCDIR "/4096-random-bytes", TRUE, &error);
55 g_assert_no_error (error);
57 contents = g_mapped_file_get_contents (file);
58 g_assert (strncmp (contents, old, strlen (old)) == 0);
60 g_mapped_file_free (file);
64 main (int argc, char *argv[])
66 g_test_init (&argc, &argv, NULL);
68 g_test_add_func ("/mappedfile/empty", test_empty);
69 g_test_add_func ("/mappedfile/nonexisting", test_nonexisting);
70 g_test_add_func ("/mappedfile/writable", test_writable);