GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixString/TESTS/TEST_SYSTEM/main.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 46 46 100.0%
Branches: 186 186 100.0%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6 ****************************************/
7
8 #include <iostream>
9 #include <vector>
10 #include "phoenix_assert.h"
11 #include "string_filename.h"
12 #include "string_system.h"
13
14 ///Test the string system function
15 1 void testStringSystem(){
16
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(getProgramDirectory() != "");
17
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(getProgramLocation() != "");
18
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(getProgramPrefix() != "");
19
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(getFileModificationTime("Makefile") != 0l);
20
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(getFileModificationTime("") == -1l);
21
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(getFileModificationTime("SomeInexistingFile") == -1l);
22
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
1 phoenix_assert(getHomeDir() != "");
23
24 1 std::list<std::string> listFile;
25
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(getListAllFileInDir(listFile, "./"));
26
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(getListFileInDir(listFile, "./", "\\.cmake"));
27
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 getListFileInCurrentDir(listFile, "\\.cmake");
28
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
1 phoenix_assert(listFile.size() != 0lu);
29
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(!isStringMatchRegex("", ""));
30
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(!isStringMatchRegex("es", ""));
31
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(!isStringMatchRegex("", "egzg"));
32
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(!isStringMatchRegex("thing.txt", "*.*"));
33
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(isStringMatchRegex("file.txt", "\\.txt"));
34
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(createDirIfNotExist("NewDirectory"));
35
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(createDirIfNotExist("NewDirectory"));
36
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(saveFileContent("NewDirectory/newFile.txt", "some content of the new file"));
37 1 std::vector<std::string> vecFile1;
38
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 time_t lastTime = getFileInDirPerTime(vecFile1, "NewDirectory/");
39
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
1 phoenix_assert(vecFile1.size() == 1lu);
40 1 std::vector<std::string> vecFile2;
41
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
1 time_t lastTime2 = getFileInDirPerTime(vecFile2, "NewDirectory/", lastTime);
42
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
1 phoenix_assert(lastTime2 == lastTime);
43
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
1 phoenix_assert(vecFile2.size() == 0lu);
44
1/1
✓ Branch 1 taken 1 times.
1 std::string currentNode(getCurrentNodeName());
45
5/5
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
1 phoenix_assert(currentNode != "");
46
47
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
1 phoenix_assert(phoenix_getenv("UNEXISTING_VARIABLE") == "");
48
7/7
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
1 phoenix_assert(phoenix_setenv("SomeExistingVariable", "42"));
49
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
1 phoenix_assert(phoenix_getenv("SomeExistingVariable") == "42");
50
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_unsetenv("SomeExistingVariable"));
51
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(phoenix_chmod("Makefile"));
52
6/6
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
1 phoenix_assert(!phoenix_chmod("UnexistingFile"));
53
54
2/2
✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
2 std::vector<std::string> vecFoundFile = phoenix_find("./*.cmake");
55
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
1 phoenix_assert(vecFoundFile.size() != 0lu);
56 1 }
57
58 1 int main(int argc, char** argv){
59 1 std::list<std::string> listArg;
60
1/1
✓ Branch 1 taken 1 times.
1 makeListArgument(listArg, argc, argv);
61
4/4
✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
1 phoenix_assert(listArg.size() != 0lu);
62
1/1
✓ Branch 1 taken 1 times.
1 testStringSystem();
63 1 return 0;
64 1 }
65
66
67