Files
Bigfoot/Bigfoot/Tests/System/File.cpp
Romain BOULLARD 6cd9801ef7
Some checks failed
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Has been cancelled
GiteaCI (#1)
Reviewed-on: #1
Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com>
Co-committed-by: Romain BOULLARD <romain.boullard@protonmail.com>
2026-01-28 14:29:12 +00:00

81 lines
2.3 KiB
C++

/*********************************************************************
* \file File.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <System/File.hpp>
#include <gtest/gtest.h>
namespace Bigfoot
{
class FileFixture: public ::testing::Test
{
public:
File m_file {eastl::string_view {"Fixture/file"}};
File m_nonExistent {eastl::string_view {"Fixture/bigfoot"}};
};
/****************************************************************************************/
TEST_F(FileFixture, IsRelative_ShouldReturnTrueOnRelativeFile)
{
EXPECT_TRUE(m_file.IsRelative());
}
/****************************************************************************************/
TEST_F(FileFixture, IsRelative_ShouldReturnFalseOnAbsoluteFile)
{
EXPECT_FALSE(m_file.Absolute().IsRelative());
}
/****************************************************************************************/
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
{
EXPECT_TRUE(m_file.Absolute().IsAbsolute());
}
TEST_F(FileFixture, IsAbsolute_ShouldReturnFalseOnRelativeFile)
{
EXPECT_FALSE(m_file.IsAbsolute());
}
/****************************************************************************************/
TEST_F(FileFixture, Exists_ShouldReturnTrueOnExistingFile)
{
EXPECT_TRUE(m_file.Exists());
}
/****************************************************************************************/
TEST_F(FileFixture, Exists_ShouldReturnFalseOnNonExistingFile)
{
EXPECT_FALSE(m_nonExistent.Exists());
}
/****************************************************************************************/
TEST_F(FileFixture, Path_ShouldReturnThePath)
{
EXPECT_STREQ(m_file.Path().data(), "Fixture/file");
}
/****************************************************************************************/
TEST_F(FileFixture, Absolute_ShouldReturnTheAbsolutePath)
{
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.Absolute().Path().data());
}
/****************************************************************************************/
TEST_F(FileFixture, Relative_ShouldReturnTheRelativePath)
{
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.Relative().Path().data());
}
} // namespace Bigfoot