-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFsTest.cpp
More file actions
41 lines (31 loc) · 1.05 KB
/
FsTest.cpp
File metadata and controls
41 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Fs.h"
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
int main() {
NSFs::CPath filePath = L"test.txt";
std::string content = "Hello, World!";
assert(NSFs::WriteFile(filePath, content).has_value());
auto exists = NSFs::Exists(filePath);
assert(exists.has_value());
assert(exists.value());
auto isRegularFile = NSFs::IsRegularFile(filePath);
assert(isRegularFile.has_value());
assert(isRegularFile.value());
auto isDirectory = NSFs::IsDirectory(filePath);
assert(isDirectory.has_value());
assert(!isDirectory.value());
auto read = NSFs::ReadFile<std::vector<uint8_t>>(filePath);
assert(read.has_value());
assert(content == std::string(read.value().begin(), read.value().end()));
assert(NSFs::Remove(filePath).has_value());
exists = NSFs::Exists(filePath);
assert(exists.has_value());
assert(!exists.value());
isRegularFile = NSFs::IsRegularFile(filePath);
assert(!isRegularFile.has_value());
isDirectory = NSFs::IsDirectory(filePath);
assert(!isDirectory.has_value());
std::cout << "PASS" << std::endl;
}