[runtime] Move eglib into mono/eglib so it becomes a convenience library similar...
[mono.git] / mono / eglib / test / dir.c
1 #include <config.h>
2 #include <glib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #ifdef HAVE_UNISTD_H
6 #include <unistd.h>
7 #endif
8 #ifdef G_OS_UNIX
9 #include <pthread.h>
10 #endif
11 #include "test.h"
12
13 /* This test is just to be used with valgrind */
14 RESULT
15 test_dir ()
16 {
17         GDir *dir;
18         GError *error;
19         const gchar *name;
20
21         /*
22         dir = g_dir_open (NULL, 0, NULL);
23         */
24         dir = g_dir_open ("", 0, NULL);
25         if (dir != NULL)
26                 return FAILED ("1 Should be an error");
27
28         dir = g_dir_open ("", 9, NULL);
29         if (dir != NULL)
30                 return FAILED ("2 Should be an error");
31
32         error = NULL;
33         dir = g_dir_open (".ljasdslakjd", 9, &error);
34         if (dir != NULL)
35                 return FAILED ("3 opendir should fail");
36         if (error == NULL)
37                 return FAILED ("4 got no error");
38         g_error_free (error);
39         error = NULL;
40         dir = g_dir_open (g_get_tmp_dir (), 9, &error);
41         if (dir == NULL)
42                 return FAILED ("5 opendir should succeed");
43         if (error != NULL)
44                 return FAILED ("6 got an error");
45         name = NULL;
46         name = g_dir_read_name (dir);
47         if (name == NULL)
48                 return FAILED ("7 didn't read a file name");
49         while ((name = g_dir_read_name (dir)) != NULL) {
50                 if (strcmp (name, ".") == 0)
51                         return FAILED (". directory found");
52                 if (strcmp (name, "..") == 0)
53                         return FAILED (".. directory found");
54         }
55         g_dir_close (dir);
56         return OK;
57 }
58
59 static Test dir_tests [] = {
60         {"g_dir_*", test_dir},
61         {NULL, NULL}
62 };
63
64 DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests)
65
66