1 /* -*-c++-*-
2 *
3 *  OpenSceneGraph example, osgunittests.
4 *
5 *  Permission is hereby granted, free of charge, to any person obtaining a copy
6 *  of this software and associated documentation files (the "Software"), to deal
7 *  in the Software without restriction, including without limitation the rights
8 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 *  copies of the Software, and to permit persons to whom the Software is
10 *  furnished to do so, subject to the following conditions:
11 *
12 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 *  THE SOFTWARE.
19 */
20 
21 #include <osg/Notify>
22 #include <osg/ArgumentParser>
23 #include <osgDB/FileNameUtils>
24 #include <list>
25 
runFileNameUtilsTest(osg::ArgumentParser &)26 void runFileNameUtilsTest(osg::ArgumentParser&)
27 {
28 typedef std::list<std::string> Strings;
29     Strings strings;
30     strings.push_back(std::string(""));
31     strings.push_back(std::string("myfile"));
32     strings.push_back(std::string(".osgt"));
33     strings.push_back(std::string("myfile.osgt"));
34     strings.push_back(std::string("/myfile.osgt"));
35     strings.push_back(std::string("home/robert/myfile.osgt"));
36     strings.push_back(std::string("/home/robert/myfile.osgt"));
37     strings.push_back(std::string("\\myfile.osgt"));
38     strings.push_back(std::string("home\\robert\\myfile.osgt"));
39     strings.push_back(std::string("\\home\\robert\\myfile.osgt"));
40     strings.push_back(std::string("\\home/robert\\myfile.osgt"));
41     strings.push_back(std::string("\\home\\robert/myfile.osgt"));
42     strings.push_back(std::string("home/robert/"));
43     strings.push_back(std::string("\\home\\robert\\"));
44     strings.push_back(std::string("home/robert/myfile"));
45     strings.push_back(std::string("\\home\\robert\\myfile"));
46     strings.push_back(std::string("home/robert/.osgt"));
47     strings.push_back(std::string("\\home\\robert\\.osgt"));
48     strings.push_back(std::string("home/robert/myfile.ext.osgt"));
49     strings.push_back(std::string("home\\robert\\myfile.ext.osgt"));
50 
51     for(Strings::iterator itr = strings.begin();
52         itr != strings.end();
53         ++itr)
54     {
55         std::string& str = *itr;
56         OSG_NOTICE<<"string="<<str;
57         OSG_NOTICE<<"\n\tosgDB::getFilePath(str)="<<osgDB::getFilePath(str);
58         OSG_NOTICE<<"\n\tosgDB::getSimpleFileName(str)="<<osgDB::getSimpleFileName(str);
59         OSG_NOTICE<<"\n\tosgDB::getStrippedName(str)="<<osgDB::getStrippedName(str);
60         OSG_NOTICE<<"\n\tosgDB::getFileExtension(str)="<<osgDB::getFileExtension(str);
61         OSG_NOTICE<<"\n\tosgDB::getFileExtensionIncludingDot(str)="<<osgDB::getFileExtensionIncludingDot(str);
62         OSG_NOTICE<<"\n\tosgDB::getNameLessExtension(str)="<<osgDB::getNameLessExtension(str);
63         OSG_NOTICE<<"\n\tosgDB::getNameLessAllExtensions(str)="<<osgDB::getNameLessAllExtensions(str);
64         OSG_NOTICE<<std::endl<<std::endl;
65     }
66 }
67