mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-30 13:57:59 +03:00
Imported Upstream version 0.26.0
This commit is contained in:
commit
9a2b6c69b6
1398 changed files with 212217 additions and 0 deletions
|
@ -0,0 +1,66 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
#include "components/file_finder/file_finder.hpp"
|
||||
|
||||
struct FileFinderTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
FileFinderTest()
|
||||
: mTestDir("./filefinder_test_dir/")
|
||||
, mTestFile("test.txt")
|
||||
, mTestFileUppercase("TEST.TXT")
|
||||
, mTestFileNotFound("foobarbaz.txt")
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
boost::filesystem::create_directory(boost::filesystem::path(mTestDir));
|
||||
|
||||
std::ofstream ofs(std::string(mTestDir + mTestFile).c_str(), std::ofstream::out);
|
||||
ofs << std::endl;
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
{
|
||||
boost::filesystem::remove_all(boost::filesystem::path(mTestDir));
|
||||
}
|
||||
|
||||
std::string mTestDir;
|
||||
std::string mTestFile;
|
||||
std::string mTestFileUppercase;
|
||||
std::string mTestFileNotFound;
|
||||
};
|
||||
|
||||
TEST_F(FileFinderTest, FileFinder_has_file)
|
||||
{
|
||||
FileFinder::FileFinder fileFinder(mTestDir);
|
||||
ASSERT_TRUE(fileFinder.has(mTestFile));
|
||||
ASSERT_TRUE(fileFinder.has(mTestFileUppercase));
|
||||
ASSERT_TRUE(fileFinder.lookup(mTestFile) == std::string(mTestDir + mTestFile));
|
||||
ASSERT_TRUE(fileFinder.lookup(mTestFileUppercase) == std::string(mTestDir + mTestFile));
|
||||
}
|
||||
|
||||
TEST_F(FileFinderTest, FileFinder_does_not_have_file)
|
||||
{
|
||||
FileFinder::FileFinder fileFinder(mTestDir);
|
||||
ASSERT_FALSE(fileFinder.has(mTestFileNotFound));
|
||||
ASSERT_TRUE(fileFinder.lookup(mTestFileNotFound).empty());
|
||||
}
|
||||
|
||||
TEST_F(FileFinderTest, FileFinderStrict_has_file)
|
||||
{
|
||||
FileFinder::FileFinderStrict fileFinder(mTestDir);
|
||||
ASSERT_TRUE(fileFinder.has(mTestFile));
|
||||
ASSERT_FALSE(fileFinder.has(mTestFileUppercase));
|
||||
ASSERT_TRUE(fileFinder.lookup(mTestFile) == std::string(mTestDir + mTestFile));
|
||||
ASSERT_FALSE(fileFinder.lookup(mTestFileUppercase) == std::string(mTestDir + mTestFile));
|
||||
}
|
||||
|
||||
TEST_F(FileFinderTest, FileFinderStrict_does_not_have_file)
|
||||
{
|
||||
FileFinder::FileFinderStrict fileFinder(mTestDir);
|
||||
ASSERT_FALSE(fileFinder.has(mTestFileNotFound));
|
||||
ASSERT_TRUE(fileFinder.lookup(mTestFileNotFound).empty());
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include "components/file_finder/search.hpp"
|
||||
|
||||
struct SearchTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
SearchTest()
|
||||
: mTestDir("./search_test_dir/")
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
boost::filesystem::create_directory(boost::filesystem::path(mTestDir));
|
||||
|
||||
std::ofstream ofs(std::string(mTestDir + "test2.txt").c_str(), std::ofstream::out);
|
||||
ofs << std::endl;
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
{
|
||||
boost::filesystem::remove_all(boost::filesystem::path(mTestDir));
|
||||
}
|
||||
|
||||
std::string mTestDir;
|
||||
};
|
||||
|
||||
TEST_F(SearchTest, file_not_found)
|
||||
{
|
||||
struct Result : public FileFinder::ReturnPath
|
||||
{
|
||||
Result(const boost::filesystem::path& expectedPath)
|
||||
: mExpectedPath(expectedPath)
|
||||
{
|
||||
}
|
||||
|
||||
void add(const boost::filesystem::path& p)
|
||||
{
|
||||
ASSERT_FALSE(p == mExpectedPath);
|
||||
}
|
||||
|
||||
private:
|
||||
boost::filesystem::path mExpectedPath;
|
||||
|
||||
} r(boost::filesystem::path(mTestDir + "test.txt"));
|
||||
|
||||
FileFinder::find(mTestDir, r, false);
|
||||
}
|
||||
|
||||
TEST_F(SearchTest, file_found)
|
||||
{
|
||||
struct Result : public FileFinder::ReturnPath
|
||||
{
|
||||
Result(const boost::filesystem::path& expectedPath)
|
||||
: mExpectedPath(expectedPath)
|
||||
{
|
||||
}
|
||||
|
||||
void add(const boost::filesystem::path& p)
|
||||
{
|
||||
ASSERT_TRUE(p == mExpectedPath);
|
||||
}
|
||||
|
||||
private:
|
||||
boost::filesystem::path mExpectedPath;
|
||||
|
||||
} r(boost::filesystem::path(mTestDir + "test2.txt"));
|
||||
|
||||
FileFinder::find(mTestDir, r, false);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue