9 file = g_file_new_for_path ("./some/directory/testfile");
11 s = g_file_get_basename (file);
12 g_assert_cmpstr (s, ==, "testfile");
15 s = g_file_get_uri (file);
16 g_assert (g_str_has_prefix (s, "file://"));
17 g_assert (g_str_has_suffix (s, "/some/directory/testfile"));
20 g_assert (g_file_has_uri_scheme (file, "file"));
21 s = g_file_get_uri_scheme (file);
22 g_assert_cmpstr (s, ==, "file");
25 g_object_unref (file);
36 file = g_file_new_for_path ("./some/directory/testfile");
37 file2 = g_file_new_for_path ("./some/directory");
38 root = g_file_new_for_path ("/");
40 g_assert (g_file_has_parent (file, file2));
42 parent = g_file_get_parent (file);
43 g_assert (g_file_equal (parent, file2));
44 g_object_unref (parent);
46 g_assert (g_file_get_parent (root) == NULL);
48 g_object_unref (file);
49 g_object_unref (file2);
50 g_object_unref (root);
60 file = g_file_new_for_path ("./some/directory");
61 child = g_file_get_child (file, "child");
62 g_assert (g_file_has_parent (child, file));
64 child2 = g_file_get_child_for_display_name (file, "child2", NULL);
65 g_assert (g_file_has_parent (child2, file));
67 g_object_unref (child);
68 g_object_unref (child2);
69 g_object_unref (file);
78 file = g_file_new_for_path (SRCDIR "/file.c");
79 type = g_file_query_file_type (file, 0, NULL);
80 g_assert_cmpint (type, ==, G_FILE_TYPE_REGULAR);
81 g_object_unref (file);
83 file = g_file_new_for_path (SRCDIR "/schema-tests");
84 type = g_file_query_file_type (file, 0, NULL);
85 g_assert_cmpint (type, ==, G_FILE_TYPE_DIRECTORY);
86 g_object_unref (file);
90 main (int argc, char *argv[])
94 g_test_init (&argc, &argv, NULL);
96 g_test_add_func ("/file/basic", test_basic);
97 g_test_add_func ("/file/parent", test_parent);
98 g_test_add_func ("/file/child", test_child);
99 g_test_add_func ("/file/type", test_type);
101 return g_test_run ();