[WinForms] Fix #18506 ActiveTracker, do not propagate message to control when it...
[mono-project.git] / mono / unit-tests / test-path.c
bloba5f56e02cb3434a022455ace86a3f7c1d81d137f
1 /*
2 * test-path.c
3 */
5 #include "config.h"
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "glib.h"
10 #include "mono/utils/mono-path.c"
12 static char*
13 make_path (const char *a, int itrail, int slash, int upcase)
15 // Append 0, 1, or 2 trailing slashes to a.
16 g_assert (itrail >= 0 && itrail <= 2);
17 char trail [] = "//";
18 trail [itrail] = 0;
19 char *b = g_strdup_printf ("%s%s", a, trail);
21 #ifdef HOST_WIN32
22 if (slash)
23 g_strdelimit (b, '/', '\\');
24 if (upcase)
25 g_strdelimit (b, 'a', 'A');
26 #endif
27 return b;
30 int
31 main (void)
33 // Use letters not numbers in this data to exercise case insensitivity.
34 static const char * const bases [2] = {"/", "/a"};
35 static const char * const files [6] = {"/a", "/a/b", "/a/b/c", "/ab", "/b", "/b/b/"};
37 static const gboolean result [2][6] = {
38 { TRUE, FALSE, FALSE, TRUE, TRUE, FALSE },
39 { FALSE, TRUE, FALSE, FALSE, FALSE, FALSE }
42 int i = 0;
43 gboolean const verbose = !!getenv("V");
45 #ifdef HOST_WIN32
46 const int win32 = 1;
47 #else
48 const int win32 = 0;
49 #endif
51 // Iterate a cross product.
52 for (int upcase_file = 0; upcase_file <= win32; ++upcase_file) {
53 for (int upcase_base = 0; upcase_base <= win32; ++upcase_base) {
54 for (int itrail_base = 0; itrail_base <= 2; ++itrail_base) {
55 for (int itrail_file = 0; itrail_file <= 2; ++itrail_file) {
56 for (int ibase = 0; ibase < G_N_ELEMENTS (bases); ++ibase) {
57 for (int ifile = 0; ifile < G_N_ELEMENTS (files); ++ifile) {
58 for (int islash_base = 0; islash_base <= win32; ++islash_base) {
59 for (int islash_file = 0; islash_file <= win32; ++islash_file) {
61 char *base = make_path (bases [ibase], itrail_base, islash_base, upcase_base);
62 char *file = make_path (files [ifile], itrail_file, islash_file, upcase_file);
63 //verbose && printf ("mono_path_filename_in_basedir (%s, %s)\n", file, base);
64 gboolean r = mono_path_filename_in_basedir (file, base);
65 verbose && printf ("mono_path_filename_in_basedir (%s, %s):%d\n", file, base, r);
66 g_assertf (result [ibase][ifile] == r,
67 "mono_path_filename_in_basedir (%s, %s):%d\n", file, base, r);
68 if (strcmp (base, file) == 0)
69 g_assertf (!r,
70 "mono_path_filename_in_basedir (%s, %s):%d\n", file, base, r);
71 g_free (base);
72 g_free (file);
73 ++i;
82 printf ("%d tests\n", i);
84 return 0;