]> git.saurik.com Git - wxWidgets.git/blame - tests/filename/filenametest.cpp
fix g++ warnings for float->int conversions
[wxWidgets.git] / tests / filename / filenametest.cpp
CommitLineData
f095b1fc
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/filename/filename.cpp
3// Purpose: wxFileName unit test
4// Author: Vadim Zeitlin
5// Created: 2004-07-25
6// RCS-ID: $Id$
7// Copyright: (c) 2004 Vadim Zeitlin
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
8899b155 14#include "testprec.h"
f095b1fc
VZ
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
f7c69b90 21 #include "wx/utils.h"
f095b1fc
VZ
22#endif // WX_PRECOMP
23
24#include "wx/filename.h"
c08dd08b 25#include "wx/filefn.h"
f095b1fc 26
2264775b
VZ
27// ----------------------------------------------------------------------------
28// local functions
29// ----------------------------------------------------------------------------
30
31// define stream inserter for wxFileName to use it in CPPUNIT_ASSERT_EQUAL()
32inline std::ostream& operator<<(std::ostream& o, const wxFileName& fn)
33{
34 return o << fn.GetFullPath();
35}
36
f095b1fc
VZ
37// ----------------------------------------------------------------------------
38// test data
39// ----------------------------------------------------------------------------
40
5fed01a9 41static struct TestFileNameInfo
f095b1fc
VZ
42{
43 const wxChar *fullname;
44 const wxChar *volume;
45 const wxChar *path;
46 const wxChar *name;
47 const wxChar *ext;
48 bool isAbsolute;
49 wxPathFormat format;
50} filenames[] =
51{
69858116 52 // the empty string
e7b54c07
VS
53 { _T(""), _T(""), _T(""), _T(""), _T(""), false, wxPATH_UNIX },
54 { _T(""), _T(""), _T(""), _T(""), _T(""), false, wxPATH_DOS },
55 { _T(""), _T(""), _T(""), _T(""), _T(""), false, wxPATH_VMS },
69858116 56
f095b1fc
VZ
57 // Unix file names
58 { _T("/usr/bin/ls"), _T(""), _T("/usr/bin"), _T("ls"), _T(""), true, wxPATH_UNIX },
59 { _T("/usr/bin/"), _T(""), _T("/usr/bin"), _T(""), _T(""), true, wxPATH_UNIX },
60 { _T("~/.zshrc"), _T(""), _T("~"), _T(".zshrc"), _T(""), true, wxPATH_UNIX },
61 { _T("../../foo"), _T(""), _T("../.."), _T("foo"), _T(""), false, wxPATH_UNIX },
62 { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), false, wxPATH_UNIX },
63 { _T("~/foo.bar"), _T(""), _T("~"), _T("foo"), _T("bar"), true, wxPATH_UNIX },
64 { _T("/foo"), _T(""), _T("/"), _T("foo"), _T(""), true, wxPATH_UNIX },
65 { _T("Mahogany-0.60/foo.bar"), _T(""), _T("Mahogany-0.60"), _T("foo"), _T("bar"), false, wxPATH_UNIX },
66 { _T("/tmp/wxwin.tar.bz"), _T(""), _T("/tmp"), _T("wxwin.tar"), _T("bz"), true, wxPATH_UNIX },
67
68 // Windows file names
69 { _T("foo.bar"), _T(""), _T(""), _T("foo"), _T("bar"), false, wxPATH_DOS },
70 { _T("\\foo.bar"), _T(""), _T("\\"), _T("foo"), _T("bar"), false, wxPATH_DOS },
71 { _T("c:foo.bar"), _T("c"), _T(""), _T("foo"), _T("bar"), false, wxPATH_DOS },
72 { _T("c:\\foo.bar"), _T("c"), _T("\\"), _T("foo"), _T("bar"), true, wxPATH_DOS },
73 { _T("c:\\Windows\\command.com"), _T("c"), _T("\\Windows"), _T("command"), _T("com"), true, wxPATH_DOS },
bf7f7793 74
ea6319cb 75#if 0
c7099635
VZ
76 // NB: when using the wxFileName::GetLongPath() function on these two
77 // strings, the program will hang for several seconds blocking inside
78 // Win32 GetLongPathName() function
f095b1fc
VZ
79 { _T("\\\\server\\foo.bar"), _T("server"), _T("\\"), _T("foo"), _T("bar"), true, wxPATH_DOS },
80 { _T("\\\\server\\dir\\foo.bar"), _T("server"), _T("\\dir"), _T("foo"), _T("bar"), true, wxPATH_DOS },
ea6319cb 81#endif
f095b1fc 82
34841b21
VZ
83 // consecutive [back]slashes should be treated as single occurrences of
84 // them and not interpreted as share names if there is a volume name
85 { _T("c:\\aaa\\bbb\\ccc"), _T("c"), _T("\\aaa\\bbb"), _T("ccc"), _T(""), true, wxPATH_DOS },
9b9596de 86 { _T("c:\\\\aaa\\bbb\\ccc"), _T("c"), _T("\\\\aaa\\bbb"), _T("ccc"), _T(""), true, wxPATH_DOS },
bf7f7793 87
f095b1fc
VZ
88 // wxFileName support for Mac file names is broken currently
89#if 0
90 // Mac file names
91 { _T("Volume:Dir:File"), _T("Volume"), _T("Dir"), _T("File"), _T(""), true, wxPATH_MAC },
92 { _T("Volume:Dir:Subdir:File"), _T("Volume"), _T("Dir:Subdir"), _T("File"), _T(""), true, wxPATH_MAC },
93 { _T("Volume:"), _T("Volume"), _T(""), _T(""), _T(""), true, wxPATH_MAC },
94 { _T(":Dir:File"), _T(""), _T("Dir"), _T("File"), _T(""), false, wxPATH_MAC },
95 { _T(":File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), false, wxPATH_MAC },
96 { _T("File.Ext"), _T(""), _T(""), _T("File"), _T(".Ext"), false, wxPATH_MAC },
97#endif // 0
98
ea6319cb 99#if 0
f095b1fc 100 // VMS file names
bf7f7793
RR
101 // NB: on Windows they have the same effect of the \\server\\ strings
102 // (see the note above)
f095b1fc 103 { _T("device:[dir1.dir2.dir3]file.txt"), _T("device"), _T("dir1.dir2.dir3"), _T("file"), _T("txt"), true, wxPATH_VMS },
ea6319cb 104#endif
f095b1fc
VZ
105 { _T("file.txt"), _T(""), _T(""), _T("file"), _T("txt"), false, wxPATH_VMS },
106};
107
108// ----------------------------------------------------------------------------
109// test class
110// ----------------------------------------------------------------------------
111
112class FileNameTestCase : public CppUnit::TestCase
113{
114public:
115 FileNameTestCase() { }
116
117private:
118 CPPUNIT_TEST_SUITE( FileNameTestCase );
119 CPPUNIT_TEST( TestConstruction );
33366127 120 CPPUNIT_TEST( TestComparison );
f095b1fc 121 CPPUNIT_TEST( TestSplit );
4524a24b 122 CPPUNIT_TEST( TestSetPath );
c08dd08b 123 CPPUNIT_TEST( TestStrip );
bf7f7793 124 CPPUNIT_TEST( TestNormalize );
395f3aa8 125 CPPUNIT_TEST( TestReplace );
60c0dfe5
VZ
126#ifdef __WINDOWS__
127 CPPUNIT_TEST( TestShortLongPath );
128#endif // __WINDOWS__
f095b1fc
VZ
129 CPPUNIT_TEST_SUITE_END();
130
131 void TestConstruction();
33366127 132 void TestComparison();
f095b1fc
VZ
133 void TestSplit();
134 void TestSetPath();
c08dd08b 135 void TestStrip();
bf7f7793 136 void TestNormalize();
395f3aa8 137 void TestReplace();
60c0dfe5
VZ
138#ifdef __WINDOWS__
139 void TestShortLongPath();
140#endif // __WINDOWS__
f095b1fc
VZ
141
142 DECLARE_NO_COPY_CLASS(FileNameTestCase)
143};
144
145// register in the unnamed registry so that these tests are run by default
146CPPUNIT_TEST_SUITE_REGISTRATION( FileNameTestCase );
147
148// also include in it's own registry so that these tests can be run alone
149CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileNameTestCase, "FileNameTestCase" );
150
151void FileNameTestCase::TestConstruction()
152{
153 for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
154 {
5fed01a9 155 const TestFileNameInfo& fni = filenames[n];
f095b1fc
VZ
156
157 wxFileName fn(fni.fullname, fni.format);
158
9b9596de
VZ
159 // the original full name could contain consecutive [back]slashes,
160 // squeeze them except for the double backslash in the beginning in
161 // Windows filenames where it has special meaning
162 wxString fullnameOrig;
163 if ( fni.format == wxPATH_DOS )
164 {
165 // copy the backslashes at beginning unchanged
166 const wxChar *p = fni.fullname;
167 while ( *p == _T('\\') )
168 fullnameOrig += *p++;
169
170 // replace consecutive slashes with single ones in the rest
171 for ( wxChar chPrev = _T('\0'); *p; p++ )
172 {
173 if ( *p == _T('\\') && chPrev == _T('\\') )
174 continue;
175
176 chPrev = *p;
177 fullnameOrig += chPrev;
178 }
179 }
180 else // !wxPATH_DOS
181 {
182 fullnameOrig = fni.fullname;
183 }
184
185 fullnameOrig.Replace(_T("//"), _T("/"));
186
187
f095b1fc 188 wxString fullname = fn.GetFullPath(fni.format);
9b9596de 189 CPPUNIT_ASSERT_EQUAL( fullnameOrig, fullname );
f095b1fc 190
ab8576b4
VZ
191 // notice that we use a dummy working directory to ensure that paths
192 // with "../.." in them could be normalized, otherwise this would fail
193 // if the test is run from root directory or its direct subdirectory
2264775b
VZ
194 CPPUNIT_ASSERT_MESSAGE
195 (
b51abd73 196 (const char *)wxString::Format(_T("Normalize(%s) failed"), fni.fullname).mb_str(),
c2173965 197 fn.Normalize(wxPATH_NORM_ALL, _T("/foo/bar/baz"), fni.format)
2264775b 198 );
4c2deb19
VZ
199
200 if ( *fni.volume && *fni.path )
201 {
202 // check that specifying the volume separately or as part of the
203 // path doesn't make any difference
204 wxString pathWithVolume = fni.volume;
205 pathWithVolume += wxFileName::GetVolumeSeparator(fni.format);
206 pathWithVolume += fni.path;
207
2264775b 208 CPPUNIT_ASSERT_EQUAL( wxFileName(pathWithVolume,
4c2deb19
VZ
209 fni.name,
210 fni.ext,
2264775b 211 fni.format), fn );
4c2deb19 212 }
f095b1fc 213 }
69858116
VZ
214
215 wxFileName fn;
216
217 // empty strings
218 fn.AssignDir(wxEmptyString);
219 CPPUNIT_ASSERT( !fn.IsOk() );
220
221 fn.Assign(wxEmptyString);
222 CPPUNIT_ASSERT( !fn.IsOk() );
223
224 fn.Assign(wxEmptyString, wxEmptyString);
225 CPPUNIT_ASSERT( !fn.IsOk() );
226
227 fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString);
228 CPPUNIT_ASSERT( !fn.IsOk() );
229
230 fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString);
231 CPPUNIT_ASSERT( !fn.IsOk() );
f095b1fc
VZ
232}
233
33366127
VZ
234void FileNameTestCase::TestComparison()
235{
523cd68a
VZ
236 wxFileName fn1(wxT("/tmp/file1"));
237 wxFileName fn2(wxT("/tmp/dir2/../file2"));
238 fn1.Normalize();
239 fn2.Normalize();
2264775b 240 CPPUNIT_ASSERT_EQUAL(fn1.GetPath(), fn2.GetPath());
33366127
VZ
241}
242
f095b1fc
VZ
243void FileNameTestCase::TestSplit()
244{
245 for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
246 {
5fed01a9 247 const TestFileNameInfo& fni = filenames[n];
f095b1fc
VZ
248 wxString volume, path, name, ext;
249 wxFileName::SplitPath(fni.fullname,
250 &volume, &path, &name, &ext, fni.format);
251
2264775b
VZ
252 CPPUNIT_ASSERT_EQUAL( wxString(fni.volume), volume );
253 CPPUNIT_ASSERT_EQUAL( wxString(fni.path), path );
254 CPPUNIT_ASSERT_EQUAL( wxString(fni.name), name );
255 CPPUNIT_ASSERT_EQUAL( wxString(fni.ext), ext );
f095b1fc 256 }
dfecbee5
VZ
257
258 // special case of empty extension
259 wxFileName fn(_T("foo."));
2264775b 260 CPPUNIT_ASSERT_EQUAL( wxString(_T("foo.")), fn.GetFullPath() );
f095b1fc
VZ
261}
262
4524a24b
VZ
263void FileNameTestCase::TestSetPath()
264{
265 wxFileName fn(_T("d:\\test\\foo.bar"), wxPATH_DOS);
67050b6d
VS
266 fn.SetPath(_T("c:\\temp"), wxPATH_DOS);
267 CPPUNIT_ASSERT( fn.SameAs(wxFileName(_T("c:\\temp\\foo.bar"), wxPATH_DOS)) );
4524a24b 268
67050b6d
VS
269 fn = wxFileName(_T("/usr/bin/ls"), wxPATH_UNIX);
270 fn.SetPath(_T("/usr/local/bin"), wxPATH_UNIX);
271 CPPUNIT_ASSERT( fn.SameAs(wxFileName(_T("/usr/local/bin/ls"), wxPATH_UNIX)) );
4524a24b
VZ
272}
273
bf7f7793
RR
274void FileNameTestCase::TestNormalize()
275{
276 // prepare some data to be used later
277 wxString sep = wxFileName::GetPathSeparator();
278 wxString cwd = wxGetCwd();
279 wxString home = wxGetUserHome();
280
281 cwd.Replace(sep, wxT("/"));
282 if (cwd.Last() != wxT('/'))
283 cwd += wxT('/');
284 home.Replace(sep, wxT("/"));
285 if (home.Last() != wxT('/'))
286 home += wxT('/');
287
288 // since we will always be testing paths using the wxPATH_UNIX
289 // format, we need to remove the volume, if present
290 if (home.Contains(wxT(':')))
291 home = home.AfterFirst(wxT(':'));
292 if (cwd.Contains(wxT(':')))
293 cwd = cwd.AfterFirst(wxT(':'));
294
8e083702 295 static const struct FileNameTest
bf7f7793 296 {
527587d3 297 const char *original;
bf7f7793 298 int flags;
527587d3 299 const char *expected;
c7099635 300 wxPathFormat fmt;
bf7f7793
RR
301 } tests[] =
302 {
303 // test wxPATH_NORM_ENV_VARS
304#ifdef __WXMSW__
c7099635 305 { "%ABCDEF%/g/h/i", wxPATH_NORM_ENV_VARS, "abcdef/g/h/i", wxPATH_UNIX },
bf7f7793 306#else
c7099635 307 { "$(ABCDEF)/g/h/i", wxPATH_NORM_ENV_VARS, "abcdef/g/h/i", wxPATH_UNIX },
bf7f7793
RR
308#endif
309
310 // test wxPATH_NORM_DOTS
c7099635 311 { "a/.././b/c/../../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
bf7f7793
RR
312
313 // test wxPATH_NORM_TILDE
314 // NB: do the tilde expansion also under Windows to test if it works there too
c7099635 315 { "/a/b/~", wxPATH_NORM_TILDE, "/a/b/~", wxPATH_UNIX },
527587d3
VZ
316 { "/~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
317 { "~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
c7099635
VZ
318
319 // test wxPATH_NORM_CASE
320 { "Foo", wxPATH_NORM_CASE, "Foo", wxPATH_UNIX },
321 { "Foo", wxPATH_NORM_CASE, "foo", wxPATH_DOS },
322 { "C:\\Program Files\\wx", wxPATH_NORM_CASE,
323 "c:\\program files\\wx", wxPATH_DOS },
324 { "C:/Program Files/wx", wxPATH_NORM_ALL | wxPATH_NORM_CASE,
325 "c:\\program files\\wx", wxPATH_DOS },
9a0c5c01
VZ
326 { "C:\\Users\\zeitlin", wxPATH_NORM_ALL | wxPATH_NORM_CASE,
327 "c:\\users\\zeitlin", wxPATH_DOS },
bf7f7793
RR
328
329 // test wxPATH_NORM_ABSOLUTE
527587d3
VZ
330 { "a/b/", wxPATH_NORM_ABSOLUTE, "CWD/a/b/", wxPATH_UNIX },
331 { "a/b/c.ext", wxPATH_NORM_ABSOLUTE, "CWD/a/b/c.ext", wxPATH_UNIX },
c7099635 332 { "/a", wxPATH_NORM_ABSOLUTE, "/a", wxPATH_UNIX },
bf7f7793
RR
333
334 // test giving no flags at all to Normalize()
c7099635
VZ
335 { "a/b/", 0, "a/b/", wxPATH_UNIX },
336 { "a/b/c.ext", 0, "a/b/c.ext", wxPATH_UNIX },
ea6319cb
VZ
337 { "/a", 0, "/a", wxPATH_UNIX },
338
339 // test handling dots without wxPATH_NORM_DOTS and wxPATH_NORM_ABSOLUTE
340 // for both existing and non-existent files (this is important under
341 // MSW where GetLongPathName() works only for the former)
342 { "./foo", wxPATH_NORM_LONG, "./foo", wxPATH_UNIX },
343 { "../foo", wxPATH_NORM_LONG, "../foo", wxPATH_UNIX },
344 { ".\\test.bkl", wxPATH_NORM_LONG, ".\\test.bkl", wxPATH_DOS },
345 { ".\\foo", wxPATH_NORM_LONG, ".\\foo", wxPATH_DOS },
346 { "..\\Makefile.in", wxPATH_NORM_LONG, "..\\Makefile.in", wxPATH_DOS },
347 { "..\\foo", wxPATH_NORM_LONG, "..\\foo", wxPATH_DOS },
348#ifdef __WXMSW__
349 { "..\\MKINST~1", wxPATH_NORM_LONG, "..\\mkinstalldirs", wxPATH_DOS },
350#endif
bf7f7793
RR
351 };
352
353 // set the env var ABCDEF
354 wxSetEnv(_T("ABCDEF"), _T("abcdef"));
355
2264775b 356 for ( size_t i = 0; i < WXSIZEOF(tests); i++ )
bf7f7793 357 {
c7099635
VZ
358 const FileNameTest& fnt = tests[i];
359 wxFileName fn(fnt.original, fnt.fmt);
bf7f7793
RR
360
361 // be sure this normalization does not fail
a779d809 362 WX_ASSERT_MESSAGE
2264775b 363 (
a779d809 364 ("#%d: Normalize(%s) failed", (int)i, fnt.original),
c7099635 365 fn.Normalize(fnt.flags, cwd, fnt.fmt)
2264775b 366 );
bf7f7793
RR
367
368 // compare result with expected string
527587d3
VZ
369 wxString expected(tests[i].expected);
370 expected.Replace(_T("HOME/"), home);
371 expected.Replace(_T("CWD/"), cwd);
a779d809
VZ
372 WX_ASSERT_EQUAL_MESSAGE
373 (
374 ("array element #%d", (int)i),
375 expected, fn.GetFullPath(fnt.fmt)
376 );
bf7f7793
RR
377 }
378}
379
395f3aa8
FM
380void FileNameTestCase::TestReplace()
381{
382 static const struct FileNameTest
383 {
384 const char *original;
385 const char *env_contents;
386 const char *replace_fmtstring;
387 const char *expected;
388 wxPathFormat fmt;
389 } tests[] =
390 {
391 { "/usr/a/strange path/lib/someFile.ext", "/usr/a/strange path", "$%s", "$TEST_VAR/lib/someFile.ext", wxPATH_UNIX },
392 { "/usr/a/path/lib/someFile.ext", "/usr/a/path", "$%s", "$TEST_VAR/lib/someFile.ext", wxPATH_UNIX },
393 { "/usr/a/path/lib/someFile", "/usr/a/path/", "$%s", "$TEST_VARlib/someFile", wxPATH_UNIX },
394 { "/usr/a/path/lib/", "/usr/a/path/", "$(%s)", "$(TEST_VAR)lib/", wxPATH_UNIX },
395 { "/usr/a/path/lib/", "/usr/a/path/", "${{%s}}", "${{TEST_VAR}}lib/", wxPATH_UNIX },
396 { "/usr/a/path/lib/", "/usr/a/path/", "%s", "TEST_VARlib/", wxPATH_UNIX },
397 { "/usr/a/path/lib/", "/usr/a/path/", "%s//", "TEST_VAR/lib/", wxPATH_UNIX },
398 // note: empty directory components are automatically removed by wxFileName thus
399 // using // in the replace format string has no effect
400
401 { "/usr/../a/path/lib/", "/usr/a/path/", "%s", "/usr/../a/path/lib/", wxPATH_UNIX },
402 { "/usr/a/path/usr/usr", "/usr", "%s", "TEST_VAR/a/pathTEST_VAR/usr", wxPATH_UNIX },
403 { "/usr/a/path/usr/usr", "/usr", "$%s", "$TEST_VAR/a/path$TEST_VAR/usr", wxPATH_UNIX },
404 { "/a/b/c/d", "a/", "%s", "/TEST_VARb/c/d", wxPATH_UNIX },
405
406 { "C:\\A\\Strange Path\\lib\\someFile", "C:\\A\\Strange Path", "%%%s%%", "%TEST_VAR%\\lib\\someFile", wxPATH_WIN },
407 { "C:\\A\\Path\\lib\\someFile", "C:\\A\\Path", "%%%s%%", "%TEST_VAR%\\lib\\someFile", wxPATH_WIN },
408 { "C:\\A\\Path\\lib\\someFile", "C:\\A\\Path", "$(%s)", "$(TEST_VAR)\\lib\\someFile", wxPATH_WIN }
409 };
410
411 for ( size_t i = 0; i < WXSIZEOF(tests); i++ )
412 {
413 const FileNameTest& fnt = tests[i];
414 wxFileName fn(fnt.original, fnt.fmt);
415
416 // set the environment variable
417 wxSetEnv(_T("TEST_VAR"), fnt.env_contents);
418
419 // be sure this ReplaceEnvVariable does not fail
420 WX_ASSERT_MESSAGE
421 (
422 ("#%d: ReplaceEnvVariable(%s) failed", (int)i, fnt.replace_fmtstring),
423 fn.ReplaceEnvVariable("TEST_VAR", fnt.replace_fmtstring, fnt.fmt)
424 );
425
426 // compare result with expected string
427 wxString expected(fnt.expected);
428 WX_ASSERT_EQUAL_MESSAGE
429 (
430 ("array element #%d", (int)i),
431 expected, fn.GetFullPath(fnt.fmt)
432 );
433 }
434
435 // now test ReplaceHomeDir
436
437 wxFileName fn = wxFileName::DirName(wxGetHomeDir());
438 fn.AppendDir("test1");
439 fn.AppendDir("test2");
440 fn.AppendDir("test3");
441 fn.SetName("some file");
442
443 WX_ASSERT_MESSAGE
444 (
445 ("ReplaceHomeDir(%s) failed", fn.GetFullPath()),
446 fn.ReplaceHomeDir()
447 );
448
449 CPPUNIT_ASSERT_EQUAL( wxString(_T("~/test1/test2/test3/some file")),
450 fn.GetFullPath(wxPATH_UNIX) );
451}
452
c08dd08b
RN
453void FileNameTestCase::TestStrip()
454{
181dd701
VZ
455 CPPUNIT_ASSERT_EQUAL( "", wxFileName::StripExtension(_T("")) );
456 CPPUNIT_ASSERT_EQUAL( ".", wxFileName::StripExtension(_T(".")) );
457 CPPUNIT_ASSERT_EQUAL( ".vimrc", wxFileName::StripExtension(_T(".vimrc")) );
458 CPPUNIT_ASSERT_EQUAL( "bad", wxFileName::StripExtension(_T("bad")) );
459 CPPUNIT_ASSERT_EQUAL( "good", wxFileName::StripExtension(_T("good.wav")) );
460 CPPUNIT_ASSERT_EQUAL( "good.wav", wxFileName::StripExtension(_T("good.wav.wav")) );
ff3d9a35 461}
60c0dfe5
VZ
462
463#ifdef __WINDOWS__
464
465void FileNameTestCase::TestShortLongPath()
466{
3f302e75 467 wxFileName fn(_T("C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"));
60c0dfe5
VZ
468
469 // incredibly enough, GetLongPath() used to return different results during
470 // the first and subsequent runs, test for this
471 CPPUNIT_ASSERT_EQUAL( fn.GetLongPath(), fn.GetLongPath() );
472 CPPUNIT_ASSERT_EQUAL( fn.GetShortPath(), fn.GetShortPath() );
473}
474
475#endif // __WINDOWS__