| GCC Code Coverage Report | |||||||||||||||||||||
        
  | 
    |||||||||||||||||||||
| Line | Branch | Exec | Source | 
1  | 
    /*  | 
    ||
2  | 
    * The ManaPlus Client  | 
    ||
3  | 
    * Copyright (C) 2016-2019 The ManaPlus Developers  | 
    ||
4  | 
    * Copyright (C) 2019-2021 Andrei Karas  | 
    ||
5  | 
    *  | 
    ||
6  | 
    * This file is part of The ManaPlus Client.  | 
    ||
7  | 
    *  | 
    ||
8  | 
    * This program is free software; you can redistribute it and/or modify  | 
    ||
9  | 
    * it under the terms of the GNU General Public License as published by  | 
    ||
10  | 
    * the Free Software Foundation; either version 2 of the License, or  | 
    ||
11  | 
    * any later version.  | 
    ||
12  | 
    *  | 
    ||
13  | 
    * This program is distributed in the hope that it will be useful,  | 
    ||
14  | 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
    ||
15  | 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
    ||
16  | 
    * GNU General Public License for more details.  | 
    ||
17  | 
    *  | 
    ||
18  | 
    * You should have received a copy of the GNU General Public License  | 
    ||
19  | 
    * along with this program. If not, see <http://www.gnu.org/licenses/>.  | 
    ||
20  | 
    */  | 
    ||
21  | 
    |||
22  | 
    #include "unittests/unittests.h"  | 
    ||
23  | 
    |||
24  | 
    #include "fs/virtfs/fs.h"  | 
    ||
25  | 
    |||
26  | 
    #include "utils/checkutils.h"  | 
    ||
27  | 
    |||
28  | 
    #ifndef UNITTESTS_CATCH  | 
    ||
29  | 
    #include <algorithm>  | 
    ||
30  | 
    #endif // UNITTESTS_CATCH  | 
    ||
31  | 
    |||
32  | 
    #include "debug.h"  | 
    ||
33  | 
    |||
34  | 
    ✓✗ | 3  | 
    TEST_CASE("VirtFs1 exists1", "") | 
    
35  | 
    { | 
    ||
36  | 
    ✓✗ | 3  | 
        VirtFs::init("."); | 
    
37  | 
    3  | 
        const bool dir1 = VirtFs::mountDirSilent("data/", | 
    |
38  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
39  | 
    3  | 
        VirtFs::mountDirSilent("..\\data", | 
    |
40  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
41  | 
    |||
42  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test")); | 
    
43  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/")); | 
    
44  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/dir1")); | 
    
45  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/dir1/")); | 
    
46  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/dir") == false); | 
    
47  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test//units.xml") == true); | 
    
48  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/\\units123.xml") == false); | 
    
49  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
50  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == false); | 
    
51  | 
    |||
52  | 
    ✗✓ | 1  | 
    if (dir1 == true)  | 
    
53  | 
        { | 
    ||
54  | 
            VirtFs::mountDir("data//test", | 
    ||
55  | 
    Append_false);  | 
    ||
56  | 
    }  | 
    ||
57  | 
    else  | 
    ||
58  | 
        { | 
    ||
59  | 
    3  | 
            VirtFs::mountDirSilent("..//data\\test", | 
    |
60  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
61  | 
    }  | 
    ||
62  | 
    |||
63  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test") == true); | 
    
64  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/dir1")); | 
    
65  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/dir1\\")); | 
    
66  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/dir") == false); | 
    
67  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test\\units.xml") == true); | 
    
68  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/units123.xml") == false); | 
    
69  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
70  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == true); | 
    
71  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml/") == false); | 
    
72  | 
    |||
73  | 
    ✗✓ | 1  | 
    if (dir1 == true)  | 
    
74  | 
            VirtFs::unmountDirSilent("data/test"); | 
    ||
75  | 
    else  | 
    ||
76  | 
    ✓✗ | 3  | 
            VirtFs::unmountDirSilent("../data/test"); | 
    
77  | 
    |||
78  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test") == true); | 
    
79  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("test/dir1")); | 
    
80  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/dir") == false); | 
    
81  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test\\units.xml") == true); | 
    
82  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/units123.xml") == false); | 
    
83  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
84  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == false); | 
    
85  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml/") == false); | 
    
86  | 
    |||
87  | 
    1  | 
    VirtFs::deinit();  | 
    |
88  | 
    1  | 
    }  | 
    |
89  | 
    |||
90  | 
    ✓✗ | 3  | 
    TEST_CASE("VirtFs1 exists2", "") | 
    
91  | 
    { | 
    ||
92  | 
    ✓✗ | 3  | 
        VirtFs::init("."); | 
    
93  | 
    ✓✗ | 6  | 
        const bool dir1 = VirtFs::mountDirSilent2("data/", | 
    
94  | 
    "test",  | 
    ||
95  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
96  | 
    ✓✗ | 6  | 
        VirtFs::mountDirSilent2("..\\data", | 
    
97  | 
    "test",  | 
    ||
98  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
99  | 
    |||
100  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test") == false); | 
    
101  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/") == false); | 
    
102  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1")); | 
    
103  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1/")); | 
    
104  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("dir") == false); | 
    
105  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == true); | 
    
106  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units123.xml") == false); | 
    
107  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
108  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("units.xml")); | 
    
109  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("file1.txt") == false); | 
    
110  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("file2.txt") == false); | 
    
111  | 
    |||
112  | 
    ✗✓ | 1  | 
    if (dir1 == true)  | 
    
113  | 
        { | 
    ||
114  | 
            VirtFs::mountDir2("data//test", | 
    ||
115  | 
    "dir2",  | 
    ||
116  | 
    Append_false);  | 
    ||
117  | 
    }  | 
    ||
118  | 
    else  | 
    ||
119  | 
        { | 
    ||
120  | 
    ✓✗ | 6  | 
            VirtFs::mountDirSilent2("..//data\\test", | 
    
121  | 
    "dir2",  | 
    ||
122  | 
    ✓✗ | 1  | 
    Append_false);  | 
    
123  | 
    }  | 
    ||
124  | 
    |||
125  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test") == false); | 
    
126  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/") == false); | 
    
127  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1")); | 
    
128  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1/")); | 
    
129  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("dir") == false); | 
    
130  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == true); | 
    
131  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("units123.xml") == false); | 
    
132  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
133  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("units.xml")); | 
    
134  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("file1.txt")); | 
    
135  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("file2.txt")); | 
    
136  | 
    |||
137  | 
    ✗✓ | 1  | 
    if (dir1 == true)  | 
    
138  | 
            VirtFs::unmountDirSilent2("data/test", "dir2"); | 
    ||
139  | 
    else  | 
    ||
140  | 
    ✓✗✓✗ | 
    6  | 
            VirtFs::unmountDirSilent2("../data/test", "dir2"); | 
    
141  | 
    |||
142  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test") == false); | 
    
143  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("test/") == false); | 
    
144  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1")); | 
    
145  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("dir1/")); | 
    
146  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("dir") == false); | 
    
147  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units.xml") == true); | 
    
148  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("units123.xml") == false); | 
    
149  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("tesQ/units.xml") == false); | 
    
150  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    6  | 
        REQUIRE(VirtFs::exists("units.xml")); | 
    
151  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("file1.txt") == false); | 
    
152  | 
    ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗  | 
    7  | 
        REQUIRE(VirtFs::exists("file2.txt") == false); | 
    
153  | 
    |||
154  | 
    1  | 
    VirtFs::deinit();  | 
    |
155  | 
    ✓✗✓✗ | 
    4  | 
    }  | 
    
| Generated by: GCOVR (Version 3.3) |