Commit d52cd0e9 authored by Maria Fava's avatar Maria Fava
Browse files

styling

parent fae0e1ac
......@@ -7,11 +7,11 @@
#include "ADDHCmd.h"
#include <cstdlib>
#include "ADDHWriter.h"
#include "Config.h"
#include <cstdlib>
/*! \namespace ntof
*
* namespace used for all the element of the nTOF
......@@ -92,12 +92,12 @@ bool ADDHCmd::isValidPath(std::string filePath, std::string filePathPrefix)
{
// filePath is relative, convert to absolute
char *absoluteFilePath = realpath(filePath.c_str(), NULL);
if(absoluteFilePath == NULL)
if (absoluteFilePath == NULL)
{
return false;
}
filePath = absoluteFilePath;
free(absoluteFilePath);
free(absoluteFilePath);
}
if (filePath.find(filePathPrefix + "/") != std::string::npos)
{
......
......@@ -8,8 +8,8 @@
#include <cppunit/extensions/HelperMacros.h>
#include "ADDH.h"
#include "Config.h"
#include "ADDHCmd.h"
#include "Config.h"
#include "local-config.h"
#include "test_helpers.hpp"
......@@ -23,7 +23,8 @@ protected:
CPPUNIT_TEST(validatePath);
CPPUNIT_TEST_SUITE_END();
bfs::path abs_tmp,abs_tmp_in, rel_tmp, rel_tmp_in;
bfs::path abs_tmp, abs_tmp_in, rel_tmp, rel_tmp_in;
public:
void setUp()
{
......@@ -50,25 +51,30 @@ public:
ADDHCmd *addhCmd_ = new ADDHCmd();
// create a filepath to be used as filepathPrefix
bfs::path abs_path_tmp = abs_tmp / "path";
bfs::path abs_path_tmp = abs_tmp / "path";
bfs::create_directories(abs_path_tmp);
bfs::path rel_path_tmp = rel_tmp / "path";
bfs::path rel_path_tmp = rel_tmp / "path";
bfs::create_directories(rel_path_tmp);
std::string absolute_path_str_correct = "/tmp/test_ADDHCmd/path";
std::string relative_path_str_correct = "./test_ADDHCmd/path";
std::string absolute_path_str_incorrect = "/tmp/test_ADDHCmd_in";
std::string relative_path_str_incorrect = "./test_ADDHCmd_in";
std::string relative_path_str_non_existent = "./test_ADDHCmd_non";
EQ(true,
addhCmd_->isValidPath(absolute_path_str_correct, "test_ADDHCmd"));
EQ(true,
addhCmd_->isValidPath(relative_path_str_correct, "test_ADDHCmd"));
EQ(true, addhCmd_->isValidPath(absolute_path_str_correct, "test_ADDHCmd"));
EQ(true, addhCmd_->isValidPath(relative_path_str_correct, "test_ADDHCmd"));
EQ(false, addhCmd_->isValidPath(absolute_path_str_incorrect, "test_ADDHCmd"));
EQ(false, addhCmd_->isValidPath(relative_path_str_incorrect, "test_ADDHCmd"));
EQ(false,
addhCmd_->isValidPath(absolute_path_str_incorrect, "test_ADDHCmd"));
EQ(false,
addhCmd_->isValidPath(relative_path_str_incorrect, "test_ADDHCmd"));
EQ(false, addhCmd_->isValidPath(relative_path_str_non_existent, "test_ADDHCmd"));
EQ(false,
addhCmd_->isValidPath(relative_path_str_non_existent,
"test_ADDHCmd"));
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment