2012-07-29 21:17:10 +04:00
|
|
|
/*
|
|
|
|
grive: an GPL program to sync a local directory with Google Drive
|
|
|
|
Copyright (C) 2012 Wan Wai Ho
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation version 2
|
|
|
|
of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ConfigTest.hh"
|
|
|
|
|
|
|
|
#include "Assert.hh"
|
|
|
|
|
|
|
|
#include "util/Config.hh"
|
2015-05-16 00:27:59 +03:00
|
|
|
#include "json/Val.hh"
|
2012-07-29 21:17:10 +04:00
|
|
|
#include "util/log/Log.hh"
|
|
|
|
|
2012-08-01 23:46:59 +04:00
|
|
|
#include <boost/program_options.hpp>
|
2012-07-29 21:17:10 +04:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace grut;
|
|
|
|
using namespace gr ;
|
2012-08-01 23:46:59 +04:00
|
|
|
namespace po = boost::program_options;
|
2012-07-29 21:17:10 +04:00
|
|
|
|
|
|
|
ConfigTest::ConfigTest( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-01 23:46:59 +04:00
|
|
|
void ConfigTest::TestInitialiseWithNoPath( )
|
2012-07-29 21:17:10 +04:00
|
|
|
{
|
2012-08-01 23:46:59 +04:00
|
|
|
po::variables_map vm;
|
|
|
|
po::notify(vm);
|
2012-07-29 21:17:10 +04:00
|
|
|
|
2012-08-01 23:46:59 +04:00
|
|
|
Config config(vm);
|
|
|
|
GRUT_ASSERT_EQUAL( "./.grive", config.Filename().string()) ;
|
2012-07-29 21:17:10 +04:00
|
|
|
}
|
|
|
|
|
2012-08-01 23:46:59 +04:00
|
|
|
void ConfigTest::TestInitialiseWithPath( )
|
2012-07-29 21:17:10 +04:00
|
|
|
{
|
2012-08-01 23:46:59 +04:00
|
|
|
char const *argv[] = { "Program", "-p", "/home/grive" };
|
|
|
|
int argc = 3;
|
2012-07-29 21:17:10 +04:00
|
|
|
|
2012-08-01 23:46:59 +04:00
|
|
|
po::options_description desc( "Grive options" );
|
|
|
|
desc.add_options()
|
|
|
|
( "path,p", po::value<std::string>(), "Path to sync")
|
|
|
|
;
|
|
|
|
|
|
|
|
po::variables_map vm;
|
|
|
|
po::store(po::parse_command_line( argc, argv, desc), vm );
|
|
|
|
po::notify(vm);
|
|
|
|
|
|
|
|
Config config(vm);
|
|
|
|
GRUT_ASSERT_EQUAL( "/home/grive/.grive", config.Filename().string()) ;
|
|
|
|
}
|
2012-07-29 21:17:10 +04:00
|
|
|
|