diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/test/lldir_tut.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/test/lldir_tut.cpp')
-rw-r--r-- | linden/indra/test/lldir_tut.cpp | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/linden/indra/test/lldir_tut.cpp b/linden/indra/test/lldir_tut.cpp new file mode 100644 index 0000000..99f4cd3 --- /dev/null +++ b/linden/indra/test/lldir_tut.cpp | |||
@@ -0,0 +1,264 @@ | |||
1 | /** | ||
2 | * @file lldir_tut.cpp | ||
3 | * @date 2008-05 | ||
4 | * @brief LLDir test cases. | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2008, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include <tut/tut.h> | ||
34 | #include "linden_common.h" | ||
35 | #include "lltut.h" | ||
36 | |||
37 | #include "lldir.h" | ||
38 | |||
39 | namespace tut | ||
40 | { | ||
41 | struct LLDirTest | ||
42 | { | ||
43 | }; | ||
44 | typedef test_group<LLDirTest> LLDirTest_t; | ||
45 | typedef LLDirTest_t::object LLDirTest_object_t; | ||
46 | tut::LLDirTest_t tut_LLDirTest("LLDir"); | ||
47 | |||
48 | template<> template<> | ||
49 | void LLDirTest_object_t::test<1>() | ||
50 | // getDirDelimiter | ||
51 | { | ||
52 | ensure("getDirDelimiter", !gDirUtilp->getDirDelimiter().empty()); | ||
53 | } | ||
54 | |||
55 | template<> template<> | ||
56 | void LLDirTest_object_t::test<2>() | ||
57 | // getBaseFileName | ||
58 | { | ||
59 | std::string delim = gDirUtilp->getDirDelimiter(); | ||
60 | std::string rawFile = "foo"; | ||
61 | std::string rawFileExt = "foo.bAr"; | ||
62 | std::string rawFileNullExt = "foo."; | ||
63 | std::string rawExt = ".bAr"; | ||
64 | std::string rawDot = "."; | ||
65 | std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; | ||
66 | std::string pathExt = pathNoExt + ".eXt"; | ||
67 | std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; | ||
68 | std::string dottedPathExt = dottedPathNoExt + ".eXt"; | ||
69 | |||
70 | // foo[.bAr] | ||
71 | |||
72 | ensure_equals("getBaseFileName/r-no-ext/no-strip-exten", | ||
73 | gDirUtilp->getBaseFileName(rawFile, false), | ||
74 | "foo"); | ||
75 | |||
76 | ensure_equals("getBaseFileName/r-no-ext/strip-exten", | ||
77 | gDirUtilp->getBaseFileName(rawFile, true), | ||
78 | "foo"); | ||
79 | |||
80 | ensure_equals("getBaseFileName/r-ext/no-strip-exten", | ||
81 | gDirUtilp->getBaseFileName(rawFileExt, false), | ||
82 | "foo.bAr"); | ||
83 | |||
84 | ensure_equals("getBaseFileName/r-ext/strip-exten", | ||
85 | gDirUtilp->getBaseFileName(rawFileExt, true), | ||
86 | "foo"); | ||
87 | |||
88 | // foo. | ||
89 | |||
90 | ensure_equals("getBaseFileName/rn-no-ext/no-strip-exten", | ||
91 | gDirUtilp->getBaseFileName(rawFileNullExt, false), | ||
92 | "foo."); | ||
93 | |||
94 | ensure_equals("getBaseFileName/rn-no-ext/strip-exten", | ||
95 | gDirUtilp->getBaseFileName(rawFileNullExt, true), | ||
96 | "foo"); | ||
97 | |||
98 | // .bAr | ||
99 | // interesting case - with no basename, this IS the basename, not the extension. | ||
100 | |||
101 | ensure_equals("getBaseFileName/e-ext/no-strip-exten", | ||
102 | gDirUtilp->getBaseFileName(rawExt, false), | ||
103 | ".bAr"); | ||
104 | |||
105 | ensure_equals("getBaseFileName/e-ext/strip-exten", | ||
106 | gDirUtilp->getBaseFileName(rawExt, true), | ||
107 | ".bAr"); | ||
108 | |||
109 | // . | ||
110 | |||
111 | ensure_equals("getBaseFileName/d/no-strip-exten", | ||
112 | gDirUtilp->getBaseFileName(rawDot, false), | ||
113 | "."); | ||
114 | |||
115 | ensure_equals("getBaseFileName/d/strip-exten", | ||
116 | gDirUtilp->getBaseFileName(rawDot, true), | ||
117 | "."); | ||
118 | |||
119 | // aa/bb/cc/dd/ee[.eXt] | ||
120 | |||
121 | ensure_equals("getBaseFileName/no-ext/no-strip-exten", | ||
122 | gDirUtilp->getBaseFileName(pathNoExt, false), | ||
123 | "ee"); | ||
124 | |||
125 | ensure_equals("getBaseFileName/no-ext/strip-exten", | ||
126 | gDirUtilp->getBaseFileName(pathNoExt, true), | ||
127 | "ee"); | ||
128 | |||
129 | ensure_equals("getBaseFileName/ext/no-strip-exten", | ||
130 | gDirUtilp->getBaseFileName(pathExt, false), | ||
131 | "ee.eXt"); | ||
132 | |||
133 | ensure_equals("getBaseFileName/ext/strip-exten", | ||
134 | gDirUtilp->getBaseFileName(pathExt, true), | ||
135 | "ee"); | ||
136 | |||
137 | // aa/bb/cc.dd/ee[.eXt] | ||
138 | |||
139 | ensure_equals("getBaseFileName/d-no-ext/no-strip-exten", | ||
140 | gDirUtilp->getBaseFileName(dottedPathNoExt, false), | ||
141 | "ee"); | ||
142 | |||
143 | ensure_equals("getBaseFileName/d-no-ext/strip-exten", | ||
144 | gDirUtilp->getBaseFileName(dottedPathNoExt, true), | ||
145 | "ee"); | ||
146 | |||
147 | ensure_equals("getBaseFileName/d-ext/no-strip-exten", | ||
148 | gDirUtilp->getBaseFileName(dottedPathExt, false), | ||
149 | "ee.eXt"); | ||
150 | |||
151 | ensure_equals("getBaseFileName/d-ext/strip-exten", | ||
152 | gDirUtilp->getBaseFileName(dottedPathExt, true), | ||
153 | "ee"); | ||
154 | } | ||
155 | |||
156 | template<> template<> | ||
157 | void LLDirTest_object_t::test<3>() | ||
158 | // getDirName | ||
159 | { | ||
160 | std::string delim = gDirUtilp->getDirDelimiter(); | ||
161 | std::string rawFile = "foo"; | ||
162 | std::string rawFileExt = "foo.bAr"; | ||
163 | std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; | ||
164 | std::string pathExt = pathNoExt + ".eXt"; | ||
165 | std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; | ||
166 | std::string dottedPathExt = dottedPathNoExt + ".eXt"; | ||
167 | |||
168 | // foo[.bAr] | ||
169 | |||
170 | ensure_equals("getDirName/r-no-ext", | ||
171 | gDirUtilp->getDirName(rawFile), | ||
172 | ""); | ||
173 | |||
174 | ensure_equals("getDirName/r-ext", | ||
175 | gDirUtilp->getDirName(rawFileExt), | ||
176 | ""); | ||
177 | |||
178 | // aa/bb/cc/dd/ee[.eXt] | ||
179 | |||
180 | ensure_equals("getDirName/no-ext", | ||
181 | gDirUtilp->getDirName(pathNoExt), | ||
182 | "aa" + delim + "bb" + delim + "cc" + delim + "dd"); | ||
183 | |||
184 | ensure_equals("getDirName/ext", | ||
185 | gDirUtilp->getDirName(pathExt), | ||
186 | "aa" + delim + "bb" + delim + "cc" + delim + "dd"); | ||
187 | |||
188 | // aa/bb/cc.dd/ee[.eXt] | ||
189 | |||
190 | ensure_equals("getDirName/d-no-ext", | ||
191 | gDirUtilp->getDirName(dottedPathNoExt), | ||
192 | "aa" + delim + "bb" + delim + "cc.dd"); | ||
193 | |||
194 | ensure_equals("getDirName/d-ext", | ||
195 | gDirUtilp->getDirName(dottedPathExt), | ||
196 | "aa" + delim + "bb" + delim + "cc.dd"); | ||
197 | } | ||
198 | |||
199 | template<> template<> | ||
200 | void LLDirTest_object_t::test<4>() | ||
201 | // getExtension | ||
202 | { | ||
203 | std::string delim = gDirUtilp->getDirDelimiter(); | ||
204 | std::string rawFile = "foo"; | ||
205 | std::string rawFileExt = "foo.bAr"; | ||
206 | std::string rawFileNullExt = "foo."; | ||
207 | std::string rawExt = ".bAr"; | ||
208 | std::string rawDot = "."; | ||
209 | std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; | ||
210 | std::string pathExt = pathNoExt + ".eXt"; | ||
211 | std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; | ||
212 | std::string dottedPathExt = dottedPathNoExt + ".eXt"; | ||
213 | |||
214 | // foo[.bAr] | ||
215 | |||
216 | ensure_equals("getExtension/r-no-ext", | ||
217 | gDirUtilp->getExtension(rawFile), | ||
218 | ""); | ||
219 | |||
220 | ensure_equals("getExtension/r-ext", | ||
221 | gDirUtilp->getExtension(rawFileExt), | ||
222 | "bar"); | ||
223 | |||
224 | // foo. | ||
225 | |||
226 | ensure_equals("getExtension/rn-no-ext", | ||
227 | gDirUtilp->getExtension(rawFileNullExt), | ||
228 | ""); | ||
229 | |||
230 | // .bAr | ||
231 | // interesting case - with no basename, this IS the basename, not the extension. | ||
232 | |||
233 | ensure_equals("getExtension/e-ext", | ||
234 | gDirUtilp->getExtension(rawExt), | ||
235 | ""); | ||
236 | |||
237 | // . | ||
238 | |||
239 | ensure_equals("getExtension/d", | ||
240 | gDirUtilp->getExtension(rawDot), | ||
241 | ""); | ||
242 | |||
243 | // aa/bb/cc/dd/ee[.eXt] | ||
244 | |||
245 | ensure_equals("getExtension/no-ext", | ||
246 | gDirUtilp->getExtension(pathNoExt), | ||
247 | ""); | ||
248 | |||
249 | ensure_equals("getExtension/ext", | ||
250 | gDirUtilp->getExtension(pathExt), | ||
251 | "ext"); | ||
252 | |||
253 | // aa/bb/cc.dd/ee[.eXt] | ||
254 | |||
255 | ensure_equals("getExtension/d-no-ext", | ||
256 | gDirUtilp->getExtension(dottedPathNoExt), | ||
257 | ""); | ||
258 | |||
259 | ensure_equals("getExtension/d-ext", | ||
260 | gDirUtilp->getExtension(dottedPathExt), | ||
261 | "ext"); | ||
262 | } | ||
263 | } | ||
264 | |||