Add some more cases to the app-id unit tests
[glib.git] / glib / tests / dir.c
blob74dbe143d778ff26afa09a4b15403d63465a2310
1 #include <glib.h>
3 static void
4 test_dir_read (void)
6 GDir *dir;
7 GError *error;
8 gchar *first;
9 const gchar *name;
11 error = NULL;
12 dir = g_dir_open (".", 0, &error);
13 g_assert_no_error (error);
15 first = NULL;
16 while ((name = g_dir_read_name (dir)) != NULL)
18 if (first == NULL)
19 first = g_strdup (name);
20 g_assert_cmpstr (name, !=, ".");
21 g_assert_cmpstr (name, !=, "..");
24 g_dir_rewind (dir);
25 g_assert_cmpstr (g_dir_read_name (dir), ==, first);
27 g_free (first);
28 g_dir_close (dir);
31 static void
32 test_dir_nonexisting (void)
34 GDir *dir;
35 GError *error;
37 error = NULL;
38 dir = g_dir_open ("/pfrkstrf", 0, &error);
39 g_assert (dir == NULL);
40 g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
41 g_error_free (error);
44 int
45 main (int argc, char *argv[])
47 g_test_init (&argc, &argv, NULL);
49 g_test_add_func ("/dir/read", test_dir_read);
50 g_test_add_func ("/dir/nonexisting", test_dir_nonexisting);
52 return g_test_run ();