Common/FileSystem: Add IsAbsolutePath() and tests

This commit is contained in:
Connor McLaughlin
2020-07-23 02:35:37 +10:00
parent d46c104d1b
commit 266d70c629
6 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#include "common/file_system.h"
#include <gtest/gtest.h>
TEST(FileSystem, IsAbsolutePath)
{
#ifdef WIN32
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\Path"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\Path\\Subdirectory"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:/"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:/Path"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:/Path/Subdirectory"));
ASSERT_FALSE(FileSystem::IsAbsolutePath(""));
ASSERT_FALSE(FileSystem::IsAbsolutePath("C:"));
ASSERT_FALSE(FileSystem::IsAbsolutePath("Path"));
ASSERT_FALSE(FileSystem::IsAbsolutePath("Path/Subdirectory"));
#else
ASSERT_TRUE(FileSystem::IsAbsolutePath("/"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("/path"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("/path/subdirectory"));
ASSERT_FALSE(FileSystem::IsAbsolutePath(""));
ASSERT_FALSE(FileSystem::IsAbsolutePath("path"));
ASSERT_FALSE(FileSystem::IsAbsolutePath("path/subdirectory"));
#endif
}