GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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 "phoenix_check.h" |
||
12 |
|||
13 |
#include "string_filename.h" |
||
14 |
|||
15 |
///Check string lower expression |
||
16 |
/** @param testName : name of the test |
||
17 |
* @param strValue : string to be tested |
||
18 |
* @param strReference : reference string |
||
19 |
* @return true is both strings are equal, false otherwise |
||
20 |
*/ |
||
21 |
14 |
bool checkString(const std::string & testName, const std::string & strValue, const std::string & strReference){ |
|
22 |
14 |
return phoenix_check(testName, strValue, strReference); |
|
23 |
} |
||
24 |
|||
25 |
///Test the string filename function |
||
26 |
1 |
void testStringFilename(){ |
|
27 |
✓ | 2 |
std::string fileName("someDir/someOtherDir/fileName.extention"); |
28 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(checkString("Test getFileName", getFileName(fileName), "fileName.extention")); |
29 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(checkString("Test getDirectory", getDirectory(fileName), "someDir/someOtherDir")); |
30 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(checkString("Test eraseExtension", eraseExtension(fileName), "someDir/someOtherDir/fileName")); |
31 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(checkString("Test getExtention", getExtention(fileName), "extention")); |
32 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test getExtention", getExtention("fileWithoutExtention"), "")); |
33 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test eraseExtension", eraseExtension(""), "")); |
34 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test eraseExtension", eraseExtension("file.tar.gz"), "file.tar")); |
35 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(checkString("Test getLongestExtention", getLongestExtention(fileName), "extention")); |
36 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test getLongestExtention", getLongestExtention("fileWithoutExtention"), "")); |
37 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test getLongestExtention", getLongestExtention("Shadok.tar.gz"), "tar.gz")); |
38 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test getLongestExtention", getLongestExtention("../Shadok.tar.gz"), "tar.gz")); |
39 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test eraseLongestExtension", eraseLongestExtension(""), "")); |
40 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test eraseLongestExtension", eraseLongestExtension("file.tar.gz"), "file")); |
41 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(checkString("Test eraseLongestExtension", eraseLongestExtension("../file.tar.gz"), "../file")); |
42 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(isFileOrDirExist("Makefile")); |
43 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(isFileOrDirExist("CMakeFiles")); |
44 |
|||
45 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isFileExist("")); |
46 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isFileOrDirExist("")); |
47 |
|||
48 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(isFileExist("./Makefile")); |
49 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isFileExist("CMakeFiles")); |
50 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isFileExist("SomeInexistingFile")); |
51 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(getFileContent("Makefile") != ""); |
52 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("Test getFileContent missing file", getFileContent("SomeInexistingFile"), "")); |
53 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(phoenix_check("Test getFileContent NULL", getFileContent(NULL), "")); |
54 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!saveFileContent(NULL, "")); |
55 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!saveFileContent(NULL, "some string")); |
56 |
|||
57 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(saveFileContent("testFile.txt", "some file content")); |
58 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(!saveFileContent("", "some file content")); |
59 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isDirectoryExist("")); |
60 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(isDirectoryExist("CMakeFiles")); |
61 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(phoenix_check("Test isDirectoryExist not dir", isDirectoryExist("SomeInexistingDir"), false)); |
62 |
|||
63 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(getCurrentDirectory() != ""); |
64 |
2 |
std::vector<std::string> vecDir; |
|
65 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("Test getExistingFileName empty", getExistingFileName("", vecDir), "")); |
66 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("Test getExistingFileName", getExistingFileName("Makefile", vecDir), "")); |
67 |
✓✓ | 1 |
vecDir.push_back("SomeInexistingDir"); |
68 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(getExistingFileName("", vecDir) == ""); |
69 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(getExistingFileName("Makefile", vecDir) == ""); |
70 |
✓✓ | 1 |
vecDir.push_back("./"); |
71 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(getExistingFileName("Makefile", vecDir) != ""); |
72 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(createDirectoriesIfNotExist("someDir")); |
73 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(createDirectoriesIfNotExist("someDir/someOtherDir")); |
74 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(createDirectoriesIfNotExist("///")); |
75 |
|||
76 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(makeAbsolutePath("") != ""); |
77 |
✓✓✓✓ ✓✓✓ |
1 |
phoenix_assert(makeAbsolutePath("./dir") != ""); |
78 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(makeAbsolutePath("/usr/lib") == "/usr/lib"); |
79 |
|||
80 |
2 |
std::vector<std::string> vecPath; |
|
81 |
✓✓ | 1 |
vecPath.push_back(""); |
82 |
✓✓ | 1 |
vecPath.push_back("./dir"); |
83 |
✓✓ | 1 |
vecPath.push_back("/usr/lib"); |
84 |
✓ | 2 |
std::vector<std::string> vecAbsolutePath = makeAbsolutePath(vecPath); |
85 |
✓✓✓✓ ✓ |
1 |
phoenix_assert(vecAbsolutePath[0lu] != ""); |
86 |
✓✓✓✓ ✓ |
1 |
phoenix_assert(vecAbsolutePath[1lu] != ""); |
87 |
✓✓✓✓ |
1 |
phoenix_assert(vecAbsolutePath[2lu] == "/usr/lib"); |
88 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isAbsolutePath("")); |
89 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(isAbsolutePath("/someting/absolute")); |
90 |
✓✓✓✓ ✓✓ |
1 |
phoenix_assert(!isAbsolutePath("../someting/not/absolute")); |
91 |
✓✓✓✓ ✓✓✓✓ ✓✓ |
1 |
phoenix_assert(phoenix_check("getUnderPath : empty", getUnderPath("", ""), "")); |
92 |
✓✓✓✓ ✓✓✓✓ ✓✓ |
1 |
phoenix_assert(phoenix_check("getUnderPath : base", getUnderPath("/some/dir/path", "dir"), "path")); |
93 |
✓✓✓✓ ✓✓✓✓ ✓✓ |
1 |
phoenix_assert(phoenix_check("getUnderPath : not found", getUnderPath("/some/dir/path", "nothere"), "")); |
94 |
|||
95 |
2 |
std::vector<std::string> vecUnderPath; |
|
96 |
✓✓ | 1 |
vecUnderPath.push_back("/usr/lib/shadok.so"); |
97 |
✓✓ | 1 |
vecUnderPath.push_back("/usr/bin/shadok"); |
98 |
✓✓ | 2 |
std::vector<std::string> vecOutUnderPath = getUnderPath(vecUnderPath, "usr"); |
99 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(phoenix_check("getUnderPath("+vecUnderPath[0]+")", vecOutUnderPath[0], "lib/shadok.so")); |
100 |
✓✓✓✓ ✓✓✓✓ |
1 |
phoenix_assert(phoenix_check("getUnderPath("+vecUnderPath[1]+")", vecOutUnderPath[1], "bin/shadok")); |
101 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : empty", removePathDots(""), "")); |
102 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : relative", removePathDots("./some/path"), "./some/path")); |
103 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : relative path", removePathDots("some/relative/path"), "some/relative/path")); |
104 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : absolute path", removePathDots("/some/absolute/path"), "/some/absolute/path")); |
105 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dot relative path", removePathDots("some/./relative/path"), "some/relative/path")); |
106 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dot absolute path", removePathDots("/some/./absolute/path"), "/some/absolute/path")); |
107 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots relative path", removePathDots("some/relative/../path"), "some/path")); |
108 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots absolute path", removePathDots("/some/absolute/../path"), "/some/path")); |
109 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 2 relative path", removePathDots("some/../relative/../path"), "path")); |
110 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 2 absolute path", removePathDots("/some/../absolute/../path"), "/path")); |
111 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 1.5 relative path", removePathDots("some/./relative/../path"), "some/path")); |
112 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 1.5 absolute path", removePathDots("/some/./absolute/../path"), "/some/path")); |
113 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 1.8 relative path", removePathDots("some//relative/../path"), "some/path")); |
114 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("removePathDots : dots 1.8 absolute path", removePathDots("/some//absolute/../path"), "/some/path")); |
115 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("getDirName : /some/dir", getDirName("/some/dir"), "dir")); |
116 |
✓✓✓✓ ✓✓✓✓ ✓ |
1 |
phoenix_assert(phoenix_check("getDirName : /some/dir/again/", getDirName("/some/dir/again/"), "again")); |
117 |
1 |
} |
|
118 |
|||
119 |
1 |
int main(int argc, char** argv){ |
|
120 |
1 |
testStringFilename(); |
|
121 |
1 |
return 0; |
|
122 |
} |
||
123 |
|||
124 |
Generated by: GCOVR (Version 4.2) |