Permalink
Browse files

fix broken unit tests

  • Loading branch information...
1 parent 804fe92 commit 29f17397c18c9e7eff22e4d52d9c388393ab3e38 justin committed Aug 1, 2012
Showing with 24 additions and 24 deletions.
  1. +0 −6 libgrive/src/util/Config.cc
  2. +0 −1 libgrive/src/util/Config.hh
  3. +22 −14 libgrive/test/util/ConfigTest.cc
  4. +2 −3 libgrive/test/util/ConfigTest.hh
@@ -34,12 +34,6 @@ const std::string default_filename = ".grive";
const char *env_name = "GR_CONFIG";
const std::string default_root_folder = ".";
-Config::Config( const fs::path& root_path ) :
- m_path( GetPath( root_path ) )
-{
- m_file = Read() ;
-}
-
Config::Config( const po::variables_map& vm )
{
m_cmd.Add( "log-xml", Json(vm.count("log-xml") > 0) ) ;
@@ -39,7 +39,6 @@ public :
struct Error : virtual Exception {} ;
typedef boost::error_info<struct FileTag, std::string> File ;
- Config( const fs::path& root_path ) ;
Config( const boost::program_options::variables_map& vm ) ;
const fs::path Filename() const ;
@@ -25,33 +25,41 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "protocol/Json.hh"
#include "util/log/Log.hh"
+#include <boost/program_options.hpp>
#include <iostream>
using namespace grut;
using namespace gr ;
+namespace po = boost::program_options;
ConfigTest::ConfigTest( )
{
}
-void ConfigTest::TestInitialiseWithEmptyString( )
+void ConfigTest::TestInitialiseWithNoPath( )
{
- Config config("");
- GRUT_ASSERT_EQUAL( "/home/.grive", config.Filename().string()) ;
-}
+ po::variables_map vm;
+ po::notify(vm);
-void ConfigTest::TestInitialiseWithString( )
-{
- Config config("/home/.grive");
- GRUT_ASSERT_EQUAL( "/home/.grive", config.Filename().string()) ;
+ Config config(vm);
+ GRUT_ASSERT_EQUAL( "./.grive", config.Filename().string()) ;
}
-void ConfigTest::TestInitialiseWithFileSystemPath( )
+void ConfigTest::TestInitialiseWithPath( )
{
- fs::path path("/home");
- fs::path file(".grive");
- Config config(path / file);
- GRUT_ASSERT_EQUAL( "/home/.grive", config.Filename().string());
-}
+ char const *argv[] = { "Program", "-p", "/home/grive" };
+ int argc = 3;
+ 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()) ;
+}
@@ -30,12 +30,11 @@ class ConfigTest : public CppUnit::TestFixture
public :
ConfigTest( ) ;
- // declare suit function
CPPUNIT_TEST_SUITE( ConfigTest ) ;
- CPPUNIT_TEST_EXCEPTION( TestInitialiseWithEmptyString, gr::Config::Error ) ;
+ CPPUNIT_TEST( TestInitialiseWithEmptyString ) ;
CPPUNIT_TEST( TestInitialiseWithString ) ;
CPPUNIT_TEST( TestInitialiseWithFileSystemPath ) ;
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE_END();
private :
void TestInitialiseWithEmptyString( );

1 comment on commit 29f1739

markk commented on 29f1739 Nov 23, 2012

The function names have been changed in ConfigTest.cc but not in ConfigTest.hh. This currently won't compile for me. It works with this patch:

diff --git a/libgrive/test/util/ConfigTest.hh b/libgrive/test/util/ConfigTest.hh
index f7e100d..451e535 100644
--- a/libgrive/test/util/ConfigTest.hh
+++ b/libgrive/test/util/ConfigTest.hh
@@ -31,15 +31,13 @@ public :
        ConfigTest( ) ;

        CPPUNIT_TEST_SUITE( ConfigTest ) ;
-         CPPUNIT_TEST( TestInitialiseWithEmptyString ) ;
-         CPPUNIT_TEST( TestInitialiseWithString ) ;
-         CPPUNIT_TEST( TestInitialiseWithFileSystemPath ) ;
+         CPPUNIT_TEST( TestInitialiseWithPath ) ;
+         CPPUNIT_TEST( TestInitialiseWithNoPath ) ;
        CPPUNIT_TEST_SUITE_END();

 private :
-  void TestInitialiseWithEmptyString( );
-  void TestInitialiseWithString( );
-  void TestInitialiseWithFileSystemPath( );
+  void TestInitialiseWithPath( );
+  void TestInitialiseWithNoPath( );
 } ;

 } // end of namespace
Please sign in to comment.