2015-09-29 14:29:10 +02:00
|
|
|
#include "testutils/ProgramOptionsTestBase.h"
|
|
|
|
#include "../../src/program_options/ProgramOptions.h"
|
2015-10-17 19:38:24 +02:00
|
|
|
#include <messmer/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h>
|
2015-09-29 14:29:10 +02:00
|
|
|
|
|
|
|
using namespace cryfs::program_options;
|
|
|
|
using std::vector;
|
2015-10-17 19:38:24 +02:00
|
|
|
using boost::none;
|
|
|
|
using std::string;
|
2015-09-29 14:29:10 +02:00
|
|
|
|
|
|
|
class ProgramOptionsTest: public ProgramOptionsTestBase {};
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, BaseDir) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("/home/user/mydir", "", none, false, none, options({"./myExecutable"}));
|
2015-09-29 14:29:10 +02:00
|
|
|
EXPECT_EQ("/home/user/mydir", testobj.baseDir());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, MountDir) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("", "/home/user/mydir", none, false, none, options({"./myExecutable"}));
|
2015-09-29 14:29:10 +02:00
|
|
|
EXPECT_EQ("/home/user/mydir", testobj.mountDir());
|
|
|
|
}
|
|
|
|
|
2015-10-24 19:56:05 +02:00
|
|
|
TEST_F(ProgramOptionsTest, ConfigfileNone) {
|
|
|
|
ProgramOptions testobj("", "", none, true, none, options({"./myExecutable"}));
|
|
|
|
EXPECT_EQ(none, testobj.configFile());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, ConfigfileSome) {
|
|
|
|
ProgramOptions testobj("", "", string("/home/user/configfile"), true, none, options({"./myExecutable"}));
|
|
|
|
EXPECT_EQ("/home/user/configfile", testobj.configFile().get());
|
2015-09-29 14:39:10 +02:00
|
|
|
}
|
|
|
|
|
2015-10-15 05:26:05 +02:00
|
|
|
TEST_F(ProgramOptionsTest, ForegroundFalse) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("", "", none, false, none, options({"./myExecutable"}));
|
2015-10-15 05:26:05 +02:00
|
|
|
EXPECT_FALSE(testobj.foreground());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, ForegroundTrue) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("", "", none, true, none, options({"./myExecutable"}));
|
2015-10-15 05:26:05 +02:00
|
|
|
EXPECT_TRUE(testobj.foreground());
|
|
|
|
}
|
|
|
|
|
2015-10-17 19:38:24 +02:00
|
|
|
TEST_F(ProgramOptionsTest, LogfileNone) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("", "", none, true, none, options({"./myExecutable"}));
|
2015-10-17 19:38:24 +02:00
|
|
|
EXPECT_EQ(none, testobj.logFile());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, LogfileSome) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("", "", none, true, string("logfile"), options({"./myExecutable"}));
|
2015-10-17 19:38:24 +02:00
|
|
|
EXPECT_EQ("logfile", testobj.logFile().get());
|
|
|
|
}
|
|
|
|
|
2015-09-29 14:29:10 +02:00
|
|
|
TEST_F(ProgramOptionsTest, EmptyFuseOptions) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, options({"./myExecutable"}));
|
2015-09-29 14:29:10 +02:00
|
|
|
//Fuse should have the mount dir as first parameter
|
|
|
|
EXPECT_VECTOR_EQ({"./myExecutable", "/home/user/mydir"}, testobj.fuseOptions());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(ProgramOptionsTest, SomeFuseOptions) {
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, options({"./myExecutable", "-f", "--longoption"}));
|
2015-09-29 14:29:10 +02:00
|
|
|
//Fuse should have the mount dir as first parameter
|
|
|
|
EXPECT_VECTOR_EQ({"./myExecutable", "/home/user/mydir", "-f", "--longoption"}, testobj.fuseOptions());
|
|
|
|
}
|