-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
47 lines (31 loc) · 1.19 KB
/
test.cpp
File metadata and controls
47 lines (31 loc) · 1.19 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
42
43
44
45
46
47
#include <iostream>
#include <string.h>
#include "FileManager.h"
int main(){
FileManager fm = FileManager("./Test");
std::vector<char> initialData = fm.getFileData("./test.png");
char* cdata = initialData.data();
char* Cdata = reinterpret_cast<char* >(cdata);
char* filedata = new char[initialData.size()];
memcpy(filedata, Cdata, initialData.size());
fm.writeFile("./new.png", Cdata, initialData.size());
std::vector<char> afterData = fm.getFileData("./new.png");
if (afterData == initialData) {
std::cout << "it worked" << std::endl;
} else {
std::cout << "it did in fact not work" << std::endl;
}
std::vector<char> original = fm.getFileData("./brew.rtf");
std::vector<char> corrupt = fm.getFileData("./brew1.rtf");
if (original == corrupt) {
std::cout << "well it worked" << std::endl;
} else {
std::cout << "well it didnt work" << std::endl;
std::string s(original.begin(), original.end());
std::cout << s << std::endl;
std::string e(corrupt.begin(), corrupt.end());
std::cout << e << std::endl;
}
return 0;
}
// run with g++ -std=c++2a test.cpp FileManager.cpp