In System.Windows.Forms:
[mono-project.git] / eglib / test / dir.c
blobc72e204d957d47c18414d599007acc9f9f3d294e
1 #include <glib.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <pthread.h>
6 #include "test.h"
8 /* This test is just to be used with valgrind */
9 RESULT
10 test_dir ()
12 GDir *dir;
13 GError *error;
14 const gchar *name;
17 dir = g_dir_open (NULL, 0, NULL);
19 dir = g_dir_open ("", 0, NULL);
20 if (dir != NULL)
21 return FAILED ("1 Should be an error");
23 dir = g_dir_open ("", 9, NULL);
24 if (dir != NULL)
25 return FAILED ("2 Should be an error");
27 error = NULL;
28 dir = g_dir_open (".ljasdslakjd", 9, &error);
29 if (dir != NULL)
30 return FAILED ("3 opendir should fail");
31 if (error == NULL)
32 return FAILED ("4 got no error");
33 g_error_free (error);
34 error = NULL;
35 dir = g_dir_open (g_get_tmp_dir (), 9, &error);
36 if (dir == NULL)
37 return FAILED ("5 opendir should succeed");
38 if (error != NULL)
39 return FAILED ("6 got an error");
40 name = NULL;
41 name = g_dir_read_name (dir);
42 if (name == NULL)
43 return FAILED ("7 didn't read a file name");
44 while ((name = g_dir_read_name (dir)) != NULL) {
45 if (strcmp (name, ".") == 0)
46 return FAILED (". directory found");
47 if (strcmp (name, "..") == 0)
48 return FAILED (".. directory found");
50 g_dir_close (dir);
51 return OK;
54 static Test dir_tests [] = {
55 {"g_dir_*", test_dir},
56 {NULL, NULL}
59 DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests)