File: UrlTest.cpp

package info (click to toggle)
storm-lang 0.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 52,004 kB
  • sloc: ansic: 261,462; cpp: 140,405; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (33 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (4)
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
#include "stdafx.h"
#include "Core/Io/Url.h"
#include "Core/Str.h"

BEGIN_TEST(UrlTest, Core) {
	Engine &e = gEngine();

	Url *root = parsePath(e, S("/home/dev/other/"));
	Url *other = parsePath(e, S("/home/dev/foo/bar.txt"));

	Url *relative = other->relative(root);
	CHECK_OBJ_EQ(relative, parsePath(e, S("../foo/bar.txt")));
	CHECK_OBJ_EQ(root->push(relative), other);
	CHECK_OBJ_EQ(other->title(), new (e) Str(S("bar")));
	CHECK_OBJ_EQ(other->ext(), new (e) Str(S("txt")));
	CHECK_OBJ_EQ(other->name(), new (e) Str(S("bar.txt")));

	Url *hidden = parsePath(e, S("/home/.hidden"));
	CHECK_OBJ_EQ(hidden->name(), new (e) Str(S(".hidden")));

	CHECK_OBJ_EQ(parsePath(e, S("/home/a/.././dev/other/")), root);

	// Windows network shares.
	CHECK_OBJ_EQ(parsePath(e, S("//host/share/foo")), parsePath(e, S("/host/share/foo")));

	// Windows paths.
	CHECK_OBJ_EQ(parsePath(e, S("C:/host/share/foo")), parsePath(e, S("/C:/host/share/foo")));

	// Check the 'executableFileUrl'...
	CHECK(executableFileUrl(e)->exists());

	// TODO: Test file IO.
} END_TEST