-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
77 lines (59 loc) · 2.19 KB
/
main.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include "mounts.h"
using namespace std;
#define assert(expr) my_assert(expr, #expr, __LINE__)
bool my_assert(bool expr, string const & name, int line) {
std::cout << (expr ? "[PASS] " : "[FAIL] ") << name << " in line " << line << std::endl;
return expr;
}
int main()
{
Mounts m("C:\\Users\\admin\\documents");
m.mount("/work", "W:\\Dokumente\\");
m.mount("/nas", "N:\\documents");
m.mount("/work/kunde1","W:\\kunde1");
m.mount("/work/kunde2", "W:\\kunde2");
m.mount("/work/kunde1/shared", "W:\\shared");
m.mount("/work/kunde2/shared", "W:\\shared");
//assert(m.absolutePath("/") == "C:\\Users\\admin\\documents");
// auto v = m.allMountPathes("C:\\Users\\admin\\documents");
// assert(1 == v.size());
// assert("/" == v.front());
// v = m.allMountPathes("C:\\");
// assert(v.size() == 0);
{
auto result = m.absolutePath("/work/kunde1/Vertrag.doc");
cout << result << endl;
assert(result == "W:\\kunde1/Vertrag.doc");
}
{
auto result = m.allMountPathes("W:\\shared\\Styleguide.md");
if(assert(result.size()==2)) {
assert(find(result.begin(),result.end(),("/work/kunde1/shared\\Styleguide.md"))!=result.end());
assert(find(result.begin(),result.end(),("/work/kunde2/shared\\Styleguide.md"))!=result.end());
}
}
{
auto result = m.getMountPointsBelow("/work/kunde1");
if(assert(result.size()==2)) {
assert(find(result.begin(),result.end(),pair<string,string>("/work/kunde1", "W:\\kunde1"))!=result.end());
assert(find(result.begin(),result.end(),pair<string,string>("/work/kunde1/shared", "W:\\shared"))!=result.end());
}
}
{
auto m2 = m;
m2.unmountAbsolute("W:\\shared");
auto result = m2.allMountPathes("W:\\shared");
assert(result.size() == 0);
}
{
auto m2 = m;
m2.unmountBelow("/work/kunde1");
auto result = m2.allMountPathes("W:\\kunde1");
assert(result.size() == 0);
}
return 0;
}