Files
Bigfoot/Bigfoot/Tests/System/File.cpp
Romain BOULLARD 00b86fbd00
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Failing after 5m37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Clang Format Checks (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Maintenance
2026-05-16 17:10:17 +02: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.ToAbsolute().IsRelative());
}
/****************************************************************************************/
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
{
EXPECT_TRUE(m_file.ToAbsolute().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, GetPath_ShouldReturnThePath)
{
EXPECT_STREQ(m_file.GetPath().data(), "Fixture/file");
}
/****************************************************************************************/
TEST_F(FileFixture, ToAbsolute_ShouldReturnTheAbsolutePath)
{
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.ToAbsolute().GetPath().data());
}
/****************************************************************************************/
TEST_F(FileFixture, ToRelative_ShouldReturnTheRelativePath)
{
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.ToRelative().GetPath().data());
}
} // namespace Bigfoot