Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
FileManagement.cpp
Go to the documentation of this file.
2
5
6#include <catch2/reporters/catch_reporter_event_listener.hpp>
7#include <catch2/reporters/catch_reporter_registrars.hpp>
8#include <iostream>
9
10namespace Divide
11{
12
13TEST_CASE( "File Existence Check" "[file_management]" )
14{
16
17 const ResourcePath invalidFileName{ "abc.cba" };
18
19 const Divide::SysInfo& systemInfo = Divide::const_sysInfo();
20 const ResourcePath workingPath = systemInfo._workingDirectory;
21
22 CHECK_TRUE(Divide::pathExists(workingPath));
23 CHECK_FALSE(Divide::fileExists(invalidFileName));
24}
25
26TEST_CASE( "Path Existence Check" "[file_management]" )
27{
29
30 const ResourcePath invalidPath{"abccba"};
31
32 CHECK_TRUE(Divide::pathExists(Divide::Paths::g_assetsLocation));
33 CHECK_FALSE(Divide::pathExists(invalidPath));
34}
35
36TEST_CASE( "Extension Check" "[file_management]" )
37{
38 const ResourcePath file1{"temp.xyz"};
39 const ResourcePath file2{"folder/temp.st"};
40 const ResourcePath file3{"folder/temp"};
41 const char* ext1 = "xyz";
42 const char* ext2 = "st";
43
44 CHECK_TRUE(Divide::hasExtension(file1, ext1));
45 CHECK_TRUE(Divide::hasExtension(file2, ext2));
46 CHECK_FALSE(Divide::hasExtension(file1, ext2));
47 CHECK_FALSE(Divide::hasExtension(file3, ext2));
48}
49
50TEST_CASE( "Lexically Normal Path Compare" "[file_management]" )
51{
52 const ResourcePath path1_in{"foo/./bar/.."};
53 const ResourcePath path2_in{"foo\\/./bar/../"};
54
55 const ResourcePath path_out{"foo/"};
56
57 CHECK_EQUAL(path1_in, path_out);
58 CHECK_EQUAL(path2_in, path_out);
59}
60
61} //namespace Divide
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
bool hasExtension(const ResourcePath &filePath, const std::string_view extensionNoDot)
const SysInfo & const_sysInfo() noexcept
bool fileExists(const ResourcePath &filePathAndName)
bool pathExists(const ResourcePath &filePath)
TEST_CASE("ByteBuffer RW Bool", "[byte_buffer]")
ResourcePath _workingDirectory
#define CHECK_EQUAL(LHS, RHS)
#define CHECK_TRUE(...)