grive2/libgrive/test/util/ConfigTest.cc

66 lines
1.6 KiB
C++
Raw Normal View History

/*
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"
#include "json/Val.hh"
#include "util/log/Log.hh"
2012-08-01 23:46:59 +04:00
#include <boost/program_options.hpp>
#include <iostream>
using namespace grut;
using namespace gr ;
2012-08-01 23:46:59 +04:00
namespace po = boost::program_options;
ConfigTest::ConfigTest( )
{
}
2012-08-01 23:46:59 +04:00
void ConfigTest::TestInitialiseWithNoPath( )
{
2012-08-01 23:46:59 +04:00
po::variables_map vm;
po::notify(vm);
2012-08-01 23:46:59 +04:00
Config config(vm);
GRUT_ASSERT_EQUAL( "./.grive", config.Filename().string()) ;
}
2012-08-01 23:46:59 +04:00
void ConfigTest::TestInitialiseWithPath( )
{
2012-08-01 23:46:59 +04:00
char const *argv[] = { "Program", "-p", "/home/grive" };
int argc = 3;
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()) ;
}