/[eiffelstudio]/trunk/eweasel/tests/path001/test.e
ViewVC logotype

Contents of /trunk/eweasel/tests/path001/test.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91112 - (show annotations)
Fri Feb 1 07:59:19 2013 UTC (6 years, 11 months ago) by manus
File size: 5942 byte(s)
Added more tests and updated to normalization of paths.

1 class
2 TEST
3
4 create
5 make
6
7 feature {NONE} -- Initialization
8
9 make
10 do
11 test_components
12 test_linux
13 end
14
15 test_components
16 local
17 p: PATH
18 do
19 create p.make_from_string ("/")
20 check_equal ("components", p.components.count = 1)
21 check_equal ("components", p.components.i_th (1).name.same_string_general ("/"))
22
23 create p.make_from_string ("/home/local/a")
24 check_equal ("components", p.components.count = 4)
25 check_equal ("components", p.components.i_th (1).name.same_string_general ("/"))
26 check_equal ("components", p.components.i_th (2).name.same_string_general ("home"))
27 check_equal ("components", p.components.i_th (3).name.same_string_general ("local"))
28 check_equal ("components", p.components.i_th (4).name.same_string_general ("a"))
29 end
30
31 test_linux
32 local
33 p: PATH
34 l_components: ARRAYED_LIST [PATH]
35 do
36 create p.make_from_string ("/usr/local/home/manus/")
37 check_equal ("is_relative", not p.is_relative)
38 check_equal ("is_absolute", p.is_absolute)
39 check_equal ("is_empty", not p.is_empty)
40 check_equal ("is_simple", not p.is_simple)
41
42 check attached p.entry as l_entry then
43 check_equal ("entry1", l_entry.name.same_string_general ("manus"))
44 end
45 check attached p.parent as l_parent then
46 check_equal ("parent1", l_parent.name.same_string_general ("/usr/local/home"))
47 check attached l_parent.entry as l_entry then
48 check_equal ("entry", l_entry.name.same_string_general ("home"))
49 end
50 check attached l_parent.parent as l_parent2 then
51 check_equal ("parent2", l_parent2.name.same_string_general ("/usr/local"))
52 check attached l_parent2.entry as l_entry then
53 check_equal ("entry", l_entry.name.same_string_general ("local"))
54 end
55 check attached l_parent2.parent as l_parent3 then
56 check_equal ("parent3", l_parent3.name.same_string_general ("/usr"))
57 check attached l_parent3.entry as l_entry then
58 check_equal ("entry", l_entry.name.same_string_general ("usr"))
59 end
60 check attached l_parent3.parent as l_parent4 then
61 check_equal ("parent4", l_parent4.name.same_string_general ("/"))
62 check_equal ("entry", l_parent4.entry = Void)
63 check attached l_parent4.parent as l_parent5 then
64 check_equal ("parent5", l_parent5.name.same_string_general ("/"))
65 check_equal ("entry", l_parent5.entry = Void)
66 end
67 end
68 end
69 end
70 end
71 check attached p.root as l_root then
72 check_equal ("root1", l_root.name.same_string_general ("/"))
73 end
74
75 l_components := p.components
76 check_equal ("components", l_components.i_th (1).name.same_string_general ("/"))
77 check_equal ("components", l_components.i_th (2).name.same_string_general ("usr"))
78 check_equal ("components", l_components.i_th (3).name.same_string_general ("local"))
79 check_equal ("components", l_components.i_th (4).name.same_string_general ("home"))
80
81
82 create p.make_from_string ("/usr//////local////////home/manus")
83 check_equal ("is_relative", not p.is_relative)
84 check_equal ("is_absolute", p.is_absolute)
85 check_equal ("is_empty", not p.is_empty)
86 check_equal ("is_simple", not p.is_simple)
87 check attached p.entry as l_entry then
88 check_equal ("entry1", l_entry.name.same_string_general ("manus"))
89 end
90 check attached p.parent as l_parent then
91 check_equal ("parent1", l_parent.name.same_string_general ("/usr/local/home"))
92 check attached l_parent.entry as l_entry then
93 check_equal ("entry", l_entry.name.same_string_general ("home"))
94 end
95 check attached l_parent.parent as l_parent2 then
96 check_equal ("parent2", l_parent2.name.same_string_general ("/usr/local"))
97 check attached l_parent2.entry as l_entry then
98 check_equal ("entry", l_entry.name.same_string_general ("local"))
99 end
100 check attached l_parent2.parent as l_parent3 then
101 check_equal ("parent3", l_parent3.name.same_string_general ("/usr"))
102 check attached l_parent3.entry as l_entry then
103 check_equal ("entry", l_entry.name.same_string_general ("usr"))
104 end
105 check attached l_parent3.parent as l_parent4 then
106 check_equal ("parent4", l_parent4.name.same_string_general ("/"))
107 check_equal ("entry", l_parent4.entry = Void)
108 check attached l_parent4.parent as l_parent5 then
109 check_equal ("parent5", l_parent5.name.same_string_general ("/"))
110 check_equal ("entry", l_parent5.entry = Void)
111 end
112 end
113 end
114 end
115 end
116 check attached p.root as l_root then
117 check_equal ("root1", l_root.name.same_string_general ("/"))
118 end
119
120 create p.make_from_string("abc")
121 check_equal ("is_relative", p.is_relative)
122 check_equal ("is_absolute", not p.is_absolute)
123 check_equal ("is_empty", not p.is_empty)
124 check_equal ("is_simple", p.is_simple)
125 check_equal ("entry", p.entry ~ p)
126 check_equal ("parent", p.parent.same_as (create {PATH}.make_current))
127 check_equal ("components", p.components.count = 1 and then p.components.first ~ p)
128
129 create p.make_from_string("abc/def")
130 check_equal ("is_relative", p.is_relative)
131 check_equal ("is_absolute", not p.is_absolute)
132 check_equal ("is_empty", not p.is_empty)
133 check_equal ("is_simple", not p.is_simple)
134 check_equal ("entry", p.entry ~ create {PATH}.make_from_string ("def"))
135 check_equal ("parent", p.parent ~ create {PATH}.make_from_string ("abc"))
136 check_equal ("components", p.components.count = 2 and then
137 p.components.i_th (1) ~ create {PATH}.make_from_string ("abc") and then
138 p.components.i_th (2) ~ create {PATH}.make_from_string ("def"))
139
140
141 create p.make_from_string ("/abc/./toto/titi/tutu/../../tata")
142 check_equal ("canonical", p.canonical_path.name.same_string_general ("/abc/toto/tata"))
143 end
144
145 check_equal (tag: STRING; b: BOOLEAN)
146 do
147 if not b then
148 io.put_string ("Error in " + tag + "%N")
149 end
150 end
151
152 env: EXECUTION_ENVIRONMENT
153 --
154 once
155 create Result
156 end
157
158 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23