2008-12-18 22:28:57 +01:00
|
|
|
/*
|
2009-01-21 21:04:20 +01:00
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
|
|
|
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam,
|
|
|
|
* Leandro Penz, Kimmo Varis
|
2008-12-18 22:28:57 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "testsuite.h"
|
2009-01-06 15:18:36 +01:00
|
|
|
#include "../src/filelister.h"
|
2008-12-18 22:28:57 +01:00
|
|
|
|
|
|
|
class TestFileLister : public TestFixture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestFileLister() : TestFixture("TestFileLister")
|
|
|
|
{ }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void run()
|
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
TEST_CASE(simplify_path);
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplify_path()
|
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
ASSERT_EQUALS(std::string("index.h"), FileLister::simplifyPath("index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("/path/"), FileLister::simplifyPath("/path/"));
|
|
|
|
ASSERT_EQUALS(std::string("/"), FileLister::simplifyPath("/"));
|
|
|
|
ASSERT_EQUALS(std::string("./index.h"), FileLister::simplifyPath("./index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("../index.h"), FileLister::simplifyPath("../index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../other/../index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("/index.h"), FileLister::simplifyPath("/path/../other///././../index.h"));
|
|
|
|
ASSERT_EQUALS(std::string("../path/index.h"), FileLister::simplifyPath("../path/other/../index.h"));
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
REGISTER_TEST(TestFileLister)
|