aboutsummaryrefslogtreecommitdiffhomepage
path: root/libslang/src/test/ospath.sl
blob: caf4a5ab6e79f3020f53aa5363b45e5403736a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
_debug_info = 1; () = evalfile ("inc.sl");

print ("Testing ospath ...");

static define test_path (path, dir, base, ext, dirbase)
{
   if (dir != path_dirname (path))
     failed ("path_dirname " + path);
   
   if (base != path_basename (path))
     failed ("path_basename " + path);
   
   if (ext != path_extname (path))
     failed ("path_extname " + path);
   
   if (dirbase != path_concat (dir, base))
     failed ("path_concat(%s,%s)", dir, base);
}

#ifdef UNIX
test_path ("etc/rc.d", "etc", "rc.d", ".d", "etc/rc.d");
test_path ("etc", ".", "etc", "", "./etc");
test_path ("usr/etc/", "usr/etc", "", "", "usr/etc/");
test_path ("/", "/", "", "", "/");
test_path (".", ".", ".", ".", "./.");
test_path ("/a./b", "/a.", "b", "", "/a./b");
test_path (".c", ".", ".c", ".c", "./.c");
#elifndef VMS
test_path ("etc\\rc.d", "etc", "rc.d", ".d", "etc\\rc.d");
test_path ("etc", ".", "etc", "", ".\\etc");
test_path ("usr\\etc\\", "usr\\etc", "", "", "usr\\etc\\");
test_path ("\\", "\\", "", "", "\\");
test_path (".", ".", ".", ".", ".\\.");
test_path ("\\a.\\b", "\\a.", "b", "", "\\a.\\b");
test_path (".c", ".", ".c", ".c", ".\\.c");
#else
message ("**** NOT IMPLEMENTED ****");
#endif
print ("Ok\n");

exit (0);