PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "PPath.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

bool checkString (const std::string &testName, const std::string &strValue, const std::string &strReference)
 Check string lower expression. More...
 
int main (int argc, char **argv)
 
void testPPathCreateDirectory ()
 Test the createDirectory. More...
 
void testPPathFileContent ()
 Test load and save file content. More...
 
void testPPathGetExtention ()
 Test the getExtension of PPath. More...
 
void testPPathGetFileDirName ()
 Test the getFileName and getDirectoryName. More...
 
void testPPathGetProgram ()
 Test getProgramDirectory, getProgramLocation and getProgramPrefix. More...
 
void testPPathGetUnderPath ()
 Test the getUnderPath. More...
 
void testPPathIsAbsolute ()
 Test isAbsolute path. More...
 
void testPPathIsExist ()
 Test the PString. More...
 
void testPPathListAllFileInDir ()
 Test the getAllFileInDir. More...
 
void testPPathMakeAbsolute ()
 Test the PPath makeAbsolute. More...
 
void testPPathOperator ()
 Test PPath operators. More...
 
void testPPathRemoveDots ()
 Test the simplify. More...
 

Function Documentation

◆ checkString()

bool checkString ( const std::string &  testName,
const std::string &  strValue,
const std::string &  strReference 
)

Check string lower expression.

Parameters
testName: name of the test
strValue: string to be tested
strReference: reference string
Returns
true is both strings are equal, false otherwise

Definition at line 20 of file main.cpp.

20  {
21  return phoenix_check(testName, strValue, strReference);
22 }
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.

References phoenix_check().

Referenced by checkEraseChar(), checkFormat(), checkPStringLowerUpper(), checkPStringReplace(), checkValueToStringConvertion(), testPPathGetFileDirName(), and testPString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 182 of file main.cpp.

182  {
195  return 0;
196 }
void testPPathIsAbsolute()
Test isAbsolute path.
Definition: main.cpp:33
void testPPathCreateDirectory()
Test the createDirectory.
Definition: main.cpp:78
void testPPathOperator()
Test PPath operators.
Definition: main.cpp:160
void testPPathGetExtention()
Test the getExtension of PPath.
Definition: main.cpp:55
void testPPathGetUnderPath()
Test the getUnderPath.
Definition: main.cpp:88
void testPPathRemoveDots()
Test the simplify.
Definition: main.cpp:119
void testPPathGetFileDirName()
Test the getFileName and getDirectoryName.
Definition: main.cpp:39
void testPPathMakeAbsolute()
Test the PPath makeAbsolute.
Definition: main.cpp:137
void testPPathFileContent()
Test load and save file content.
Definition: main.cpp:95
void testPPathIsExist()
Test the PString.
Definition: main.cpp:25
void testPPathGetProgram()
Test getProgramDirectory, getProgramLocation and getProgramPrefix.
Definition: main.cpp:144
void testPPathListAllFileInDir()
Test the getAllFileInDir.
Definition: main.cpp:167

References testPPathCreateDirectory(), testPPathFileContent(), testPPathGetExtention(), testPPathGetFileDirName(), testPPathGetProgram(), testPPathGetUnderPath(), testPPathIsAbsolute(), testPPathIsExist(), testPPathListAllFileInDir(), testPPathMakeAbsolute(), testPPathOperator(), and testPPathRemoveDots().

+ Here is the call graph for this function:

◆ testPPathCreateDirectory()

void testPPathCreateDirectory ( )

Test the createDirectory.

Definition at line 78 of file main.cpp.

78  {
79  phoenix_assert(!PPath("").createDirectory());
80  phoenix_assert(PPath(".").createDirectory());
81  phoenix_assert(PPath("someDirectory").createDirectory());
82  phoenix_assert(PPath("some/Directory/with/sub/directories").createDirectory());
83  phoenix_assert(PPath("someDirectory").isDirectoryExist());
84  phoenix_assert(PPath("some/Directory/with/sub/directories").isDirectoryExist());
85 }
Path of a directory or a file.
Definition: PPath.h:17
#define phoenix_assert(isOk)

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testPPathFileContent()

void testPPathFileContent ( )

Test load and save file content.

Definition at line 95 of file main.cpp.

95  {
96  phoenix_assert(PPath("testFile.txt").saveFileContent("some file content"));
97  phoenix_assert(!PPath("").saveFileContent("some file content"));
98 
99  phoenix_assert(PPath("testFile.txt").loadFileContent() == "some file content");
100  phoenix_assert(PPath("testFile.txt").getFileSize() == 17lu);
101  phoenix_assert(PPath("testUnexistingFile.txt").getFileSize() == 0lu);
102 
103  phoenix_assert(PPath("").checkFileBegning("") == false);
104  phoenix_assert(!PPath("UnexistingFile").checkFileBegning(""));
105  phoenix_assert(!PPath("testFile.txt").checkFileBegning(""));
106  phoenix_assert(!PPath("testFile.txt").checkFileBegning("# Not the match"));
107  phoenix_assert(PPath("testFile.txt").checkFileBegning("some file"));
108 
109  phoenix_assert(!PPath("").changeMode());
110  phoenix_assert(!PPath("testUnexistingFile.txt").changeMode());
111  phoenix_assert(PPath("testFile.txt").changeMode());
112 
113  phoenix_assert(PPath("testFile.txt").getFileModificationTime() != 0l);
114  phoenix_assert(PPath("").getFileModificationTime() == -1l);
115  phoenix_assert(PPath("SomeInexistingFile").getFileModificationTime() == -1l);
116 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testPPathGetExtention()

void testPPathGetExtention ( )

Test the getExtension of PPath.

Definition at line 55 of file main.cpp.

55  {
56  phoenix_assert(phoenix_check("Test getExtension", PPath("").getExtension(), ""));
57  phoenix_assert(phoenix_check("Test getExtension", PPath("path/without/extention").getExtension(), ""));
58  phoenix_assert(phoenix_check("Test getExtension", PPath("path/with/extention.txt").getExtension(), "txt"));
59  phoenix_assert(phoenix_check("Test getExtension", PPath("path/with/extention.tar.gz").getExtension(), "gz"));
60 
61  phoenix_assert(phoenix_check("Test getLongestExtension", PPath("").getLongestExtension(), ""));
62  phoenix_assert(phoenix_check("Test getLongestExtension", PPath("path/without/extention").getLongestExtension(), ""));
63  phoenix_assert(phoenix_check("Test getLongestExtension", PPath("path/with/extention.txt").getLongestExtension(), "txt"));
64  phoenix_assert(phoenix_check("Test getLongestExtension", PPath("path/with/extention.tar.gz").getLongestExtension(), "tar.gz"));
65 
66  phoenix_assert(phoenix_check("Test eraseExtension", PPath("").eraseExtension(), ""));
67  phoenix_assert(phoenix_check("Test eraseExtension", PPath("path/without/extention").eraseExtension(), "path/without/extention"));
68  phoenix_assert(phoenix_check("Test eraseExtension", PPath("path/with/extention.txt").eraseExtension(), "path/with/extention"));
69  phoenix_assert(phoenix_check("Test eraseExtension", PPath("path/with/extention.tar.gz").eraseExtension(), "path/with/extention.tar"));
70 
71  phoenix_assert(phoenix_check("Test eraseLongestExtension", PPath("").eraseLongestExtension(), ""));
72  phoenix_assert(phoenix_check("Test eraseLongestExtension", PPath("path/without/extention").eraseLongestExtension(), "path/without/extention"));
73  phoenix_assert(phoenix_check("Test eraseLongestExtension", PPath("path/with/extention.txt").eraseLongestExtension(), "path/with/extention"));
74  phoenix_assert(phoenix_check("Test eraseLongestExtension", PPath("path/with/extention.tar.gz").eraseLongestExtension(), "path/with/extention"));
75 }

References phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathGetFileDirName()

void testPPathGetFileDirName ( )

Test the getFileName and getDirectoryName.

Definition at line 39 of file main.cpp.

39  {
40  phoenix_assert(phoenix_check("Test getFileName", PPath("").getFileName(), ""));
41  phoenix_assert(phoenix_check("Test getFileName", PPath("/some/path/with/file.txt").getFileName(), "file.txt"));
42  phoenix_assert(phoenix_check("Test getDirectoryName", PPath("").getDirectoryName(), ""));
43  phoenix_assert(phoenix_check("Test getDirectoryName", PPath("/some/path/to/directory").getDirectoryName(), "directory"));
44  phoenix_assert(phoenix_check("Test getDirectoryName", PPath("/some/path/to/directory/").getDirectoryName(), "directory"));
45 
46  phoenix_assert(checkString("Test getParentDirectory", PPath("").getParentDirectory(), ""));
47  phoenix_assert(checkString("Test getParentDirectory", PPath("/some/path/to/directory").getParentDirectory(), "/some/path/to"));
48  phoenix_assert(checkString("Test getParentDirectory", PPath("../some/path/to/directory").getParentDirectory(), "../some/path/to"));
49  phoenix_assert(checkString("Test getParentDirectory", PPath("/some/path/to/directory/").getParentDirectory(), "/some/path/to"));
50  phoenix_assert(checkString("Test getParentDirectory", PPath("/some/path/to/directory///").getParentDirectory(), "/some/path/to"));
51  phoenix_assert(checkString("Test getParentDirectory", PPath("../some/path/to/directory/").getParentDirectory(), "../some/path/to"));
52 }
bool checkString(const std::string &testName, const std::string &strValue, const std::string &strReference)
Check string lower expression.
Definition: main.cpp:20

References checkString(), phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathGetProgram()

void testPPathGetProgram ( )

Test getProgramDirectory, getProgramLocation and getProgramPrefix.

Definition at line 144 of file main.cpp.

144  {
151  std::cout << "testPPathGetProgram : PPath::getProgramLocation() = '" << PPath::getProgramLocation() << "'" << std::endl;
152  std::cout << "testPPathGetProgram : PPath::getProgramDirectory() = '" << PPath::getProgramDirectory() << "'" << std::endl;
153  std::cout << "testPPathGetProgram : PPath::getProgramPrefix() = '" << PPath::getProgramPrefix() << "'" << std::endl;
154  std::cout << "testPPathGetProgram : PPath::getHomeDir() = '" << PPath::getHomeDir() << "'" << std::endl;
155  std::cout << "testPPathGetProgram : PPath::getCurrentDirectory() = '" << PPath::getCurrentDirectory() << "'" << std::endl;
156  std::cout << "testPPathGetProgram : PPath::getCurrentNodeName() = '" << PPath::getCurrentNodeName() << "'" << std::endl;
157 }
static PPath getCurrentDirectory()
Returns the current directory.
Definition: PPath.cpp:636
static PString getCurrentNodeName()
Get the name of the current node on which the program is running.
Definition: PPath.cpp:650
static PPath getHomeDir()
Gets the $HOME directory.
Definition: PPath.cpp:629
static PPath getProgramPrefix()
Get the program prefix (installation directory without /bin)
Definition: PPath.cpp:622
static PPath getProgramLocation()
Get the program location.
Definition: PPath.cpp:585
static PPath getProgramDirectory()
Get the program directory.
Definition: PPath.cpp:606

References PPath::getCurrentDirectory(), PPath::getCurrentNodeName(), PPath::getHomeDir(), PPath::getProgramDirectory(), PPath::getProgramLocation(), PPath::getProgramPrefix(), and phoenix_assert.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathGetUnderPath()

void testPPathGetUnderPath ( )

Test the getUnderPath.

Definition at line 88 of file main.cpp.

88  {
89  phoenix_assert(phoenix_check("getUnderPath : empty", PPath("").getUnderPath(""), ""));
90  phoenix_assert(phoenix_check("getUnderPath : base", PPath("/some/dir/path").getUnderPath("dir"), "path"));
91  phoenix_assert(phoenix_check("getUnderPath : not found", PPath("/some/dir/path").getUnderPath("nothere"), ""));
92 }

References phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathIsAbsolute()

void testPPathIsAbsolute ( )

Test isAbsolute path.

Definition at line 33 of file main.cpp.

33  {
34  phoenix_assert(PPath("/absolute/Path/").isAbsolutePath());
35  phoenix_assert(!PPath("no/absolute/Path/").isAbsolutePath());
36 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testPPathIsExist()

void testPPathIsExist ( )

Test the PString.

Definition at line 25 of file main.cpp.

25  {
26  phoenix_assert(!PPath("").isExist());
27  phoenix_assert(!PPath("Unexisting/path").isExist());
28  phoenix_assert(!PPath("Unexisting/path/to/file").isFileExist());
29  phoenix_assert(!PPath("Unexisting/path/to/dir").isDirectoryExist());
30 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testPPathListAllFileInDir()

void testPPathListAllFileInDir ( )

Test the getAllFileInDir.

Definition at line 167 of file main.cpp.

167  {
168  phoenix_assert(PPath("./").getAllFileInDir().size() != 0lu);
169  phoenix_assert(PPath("./").getAllElementInDir().size() != 0lu);
170 
171  PPath testDirectory("./TestDirectory");
172  PVecPath vecElement = testDirectory.getAllElementInDir();
173  phoenix_assert(phoenix_check("TestDirectory nb elements in TestDirectory", vecElement.size(), 4lu));
174 
175  PVecPath vecFile = testDirectory.getAllFileInDir();
176  phoenix_assert(phoenix_check("TestDirectory nb files in TestDirectory", vecFile.size(), 2lu));
177 
178  PVecPath vecDir = testDirectory.getAllDirectoryInDir();
179  phoenix_assert(phoenix_check("TestDirectory nb directories in TestDirectory", vecDir.size(), 2lu));
180 }
std::vector< PPath > PVecPath
Definition: PPath.h:75

References PPath::getAllDirectoryInDir(), PPath::getAllElementInDir(), PPath::getAllFileInDir(), phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathMakeAbsolute()

void testPPathMakeAbsolute ( )

Test the PPath makeAbsolute.

Definition at line 137 of file main.cpp.

137  {
138  phoenix_assert(PPath("").makeAbsolute() != "");
139  phoenix_assert(PPath("./dir").makeAbsolute() != "");
140  phoenix_assert(PPath("/usr/lib").makeAbsolute() == "/usr/lib");
141 }

References phoenix_assert.

Referenced by main().

+ Here is the caller graph for this function:

◆ testPPathOperator()

void testPPathOperator ( )

Test PPath operators.

Definition at line 160 of file main.cpp.

160  {
161  PPath path1("some/Path"), path2("and/other");
162  phoenix_assert(phoenix_check("testPPathOperator /", PPath(path1 / path2), "some/Path/and/other"));
163  phoenix_assert(phoenix_check("testPPathOperator +", PPath(path1 + path2), "some/Pathand/other"));
164 }

References phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPPathRemoveDots()

void testPPathRemoveDots ( )

Test the simplify.

Definition at line 119 of file main.cpp.

119  {
120  phoenix_assert(phoenix_check("testPPathRemoveDots : empty", PPath("").simplify(), ""));
121  phoenix_assert(phoenix_check("testPPathRemoveDots : relative", PPath("./some/path").simplify(), "./some/path"));
122  phoenix_assert(phoenix_check("testPPathRemoveDots : relative path", PPath("some/relative/path").simplify(), "some/relative/path"));
123  phoenix_assert(phoenix_check("testPPathRemoveDots : absolute path", PPath("/some/absolute/path").simplify(), "/some/absolute/path"));
124  phoenix_assert(phoenix_check("testPPathRemoveDots : dot relative path", PPath("some/./relative/path").simplify(), "some/relative/path"));
125  phoenix_assert(phoenix_check("testPPathRemoveDots : dot absolute path", PPath("/some/./absolute/path").simplify(), "/some/absolute/path"));
126  phoenix_assert(phoenix_check("testPPathRemoveDots : dots relative path", PPath("some/relative/../path").simplify(), "some/path"));
127  phoenix_assert(phoenix_check("testPPathRemoveDots : dots absolute path", PPath("/some/absolute/../path").simplify(), "/some/path"));
128  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 2 relative path", PPath("some/../relative/../path").simplify(), "path"));
129  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 2 absolute path", PPath("/some/../absolute/../path").simplify(), "/path"));
130  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 1.5 relative path", PPath("some/./relative/../path").simplify(), "some/path"));
131  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 1.5 absolute path", PPath("/some/./absolute/../path").simplify(), "/some/path"));
132  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 1.8 relative path", PPath("some//relative/../path").simplify(), "some/path"));
133  phoenix_assert(phoenix_check("testPPathRemoveDots : dots 1.8 absolute path", PPath("/some//absolute/../path").simplify(), "/some/path"));
134 }

References phoenix_assert, and phoenix_check().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: