- rework the testsuite after new boost in factory broke it.
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Sat, 16 Feb 2008 02:01:57 +0000 (02:01 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Sat, 16 Feb 2008 02:01:57 +0000 (02:01 +0000)
- remove the feature to test on arbitrary directories
- use testcase auto registration
- remove lot lot of registration code
- use a macro to add testcases, following the convention:
  Class1_test.cc then just use ADD_TESTS(Class1 Class2..)
- port some testcases missing to boost

47 files changed:
CMakeLists.txt
tests/CMakeLists.txt
tests/media/CMakeLists.txt
tests/media/file_exists_test.cc
tests/media/media1_test.cc [moved from tests/media/media1.cc with 79% similarity]
tests/media/media2_test.cc [moved from tests/media/media2.cc with 92% similarity]
tests/media/media3_test.cc [moved from tests/media/media3.cc with 84% similarity]
tests/media/media4_test.cc [moved from tests/media/media4.cc with 89% similarity]
tests/media/throw_if_not_exists_test.cc [moved from tests/media/throw_if_not_exists.cc with 100% similarity]
tests/parser/inifile/CMakeLists.txt
tests/parser/inifile/inidict_test.cc
tests/parser/inifile/iniparser_test.cc
tests/parser/yum/CMakeLists.txt
tests/parser/yum/PatchFileReader_test.cc
tests/parser/yum/PatchesFileReader_test.cc
tests/parser/yum/RepomdFileReader_test.cc
tests/repo/CMakeLists.txt
tests/repo/RepoVariables_test.cc
tests/repo/susetags/CMakeLists.txt
tests/repo/susetags/Downloader_test.cc
tests/repo/yum/CMakeLists.txt
tests/repo/yum/YUMDownloader_test.cc
tests/zypp/Arch_test.cc
tests/zypp/CMakeLists.txt
tests/zypp/Capabilities_test.cc
tests/zypp/CheckSum_test.cc
tests/zypp/Digest_test.cc
tests/zypp/Edition_test.cc
tests/zypp/Fetcher_test.cc
tests/zypp/FileChecker_test.cc
tests/zypp/KeyRing_test.cc
tests/zypp/PathInfo_test.cc
tests/zypp/PoolQuery_test.cc
tests/zypp/ProgressData_test.cc
tests/zypp/PtrTypes_test.cc [moved from tests/zypp/PtrTypes.cc with 97% similarity]
tests/zypp/PublicKey_test.cc
tests/zypp/RWPtr_test.cc [moved from tests/zypp/RWPtr.cc with 92% similarity]
tests/zypp/RepoInfo_test.cc
tests/zypp/RepoManager_test.cc
tests/zypp/RepoStatus_test.cc
tests/zypp/ResKind_test.cc
tests/zypp/TranslatedText_test.cc
tests/zypp/Url_test.cc
tests/zypp/Vendor1_test.cc [deleted file]
tests/zypp/Vendor_test.cc [moved from tests/zypp/Vendor2_test.cc with 62% similarity]
tests/zypp/base/CMakeLists.txt
tests/zypp/base/Sysconfig_test.cc

index cfd024d..6519983 100644 (file)
@@ -27,6 +27,15 @@ GENERATE_PACKAGING(${PACKAGE} ${VERSION})
 
 INCLUDE(CPack)
 
+MACRO(ADD_TESTS)
+  FOREACH( loop_var ${ARGV} )
+    SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN" )
+    ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
+    TARGET_LINK_LIBRARIES( ${loop_var}_test  zypp boost_unit_test_framework)
+    ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
+  ENDFOREACH( loop_var )
+ENDMACRO(ADD_TESTS)
+
 ####################################################################
 
 FIND_PACKAGE(Rpm REQUIRED)
index 23ea42b..0d5d8c7 100644 (file)
@@ -2,8 +2,7 @@ ENABLE_TESTING()
 
 ADD_DEFINITIONS( -DTESTS_SRC_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\" )
 
-#ADD_SUBDIRECTORY( cache )
-#ADD_SUBDIRECTORY( media )
-#ADD_SUBDIRECTORY( zypp )
-#ADD_SUBDIRECTORY( parser )
-#ADD_SUBDIRECTORY( repo )
+#ADD_SUBDIRECTORY( media EXCLUDE_FROM_ALL )
+ADD_SUBDIRECTORY( zypp )
+ADD_SUBDIRECTORY( parser )
+ADD_SUBDIRECTORY( repo )
index 937274d..ac4196c 100644 (file)
@@ -1,180 +1,2 @@
 
-########### next target ###############
-
-SET(media2_SRCS
-media2.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${media2_SRCS})
-
-KDE3_ADD_EXECUTABLE(media2 ${media2_SRCS})
-
-TARGET_LINK_LIBRARIES(media2  ${QT_AND_KDECORE_LIBS} )
-
-
-########### next target ###############
-
-SET(media3_SRCS
-media3.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${media3_SRCS})
-
-KDE3_ADD_EXECUTABLE(media3 ${media3_SRCS})
-
-TARGET_LINK_LIBRARIES(media3  ${QT_AND_KDECORE_LIBS} )
-
-
-########### next target ###############
-
-SET(media4_SRCS
-media4.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${media4_SRCS})
-
-KDE3_ADD_EXECUTABLE(media4 ${media4_SRCS})
-
-TARGET_LINK_LIBRARIES(media4  ${QT_AND_KDECORE_LIBS} )
-
-
-########### next target ###############
-
-SET(fileexists_SRCS
-file_exists_test.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${fileexists_SRCS})
-
-KDE3_ADD_EXECUTABLE(fileexists ${fileexists_SRCS})
-
-TARGET_LINK_LIBRARIES(fileexists  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
-
-
-########### next target ###############
-
-SET(throw_if_not_exists_SRCS
-throw_if_not_exists.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${throw_if_not_exists_SRCS})
-
-KDE3_ADD_EXECUTABLE(throw_if_not_exists ${throw_if_not_exists_SRCS})
-
-TARGET_LINK_LIBRARIES(throw_if_not_exists  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
-
-
-########### next target ###############
-
-SET(media1_SRCS
-media1.cc
-mymediaverifier.h
-)
-
-KDE3_AUTOMOC(${media1_SRCS})
-
-IF(KDE3_BUILD_TESTS)
-
-KDE3_ADD_EXECUTABLE(media1 ${media1_SRCS})
-
-TARGET_LINK_LIBRARIES(media1  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
-
-ENDIF(KDE3_BUILD_TESTS)
-
-########### next target ###############
-
-SET(fileexists_SRCS
-dummy.cpp
-)
-
-KDE3_AUTOMOC(${fileexists_SRCS})
-
-FILE(WRITE dummy.cpp "//autogenerated file by cmake\n")
-IF(KDE3_BUILD_TESTS)
-
-KDE3_ADD_EXECUTABLE(fileexists ${fileexists_SRCS})
-
-TARGET_LINK_LIBRARIES(fileexists  ${QT_AND_KDECORE_LIBS} )
-
-ENDIF(KDE3_BUILD_TESTS)
-
-########### next target ###############
-
-SET(throw_if_not_exists_SRCS
-dummy.cpp
-)
-
-KDE3_AUTOMOC(${throw_if_not_exists_SRCS})
-
-FILE(WRITE dummy.cpp "//autogenerated file by cmake\n")
-IF(KDE3_BUILD_TESTS)
-
-KDE3_ADD_EXECUTABLE(throw_if_not_exists ${throw_if_not_exists_SRCS})
-
-TARGET_LINK_LIBRARIES(throw_if_not_exists  ${QT_AND_KDECORE_LIBS} )
-
-ENDIF(KDE3_BUILD_TESTS)
-
-########### install files ###############
-
-
-
-
-#original Makefile.am contents follow:
-
-### Process this file with automake to produce Makefile.in
-### ##################################################
-#
-## Do NOT list devel.* in subdirs. It's developers playgound and
-## must not prevent anything from building.
-#SUBDIRS =
-#
-### ##################################################
-#
-#
-#TESTS = media1 fileexists
-#
-#noinst_PROGRAMS = media2 media3 media4 fileexists throw_if_not_exists
-#
-#check_PROGRAMS = media1 fileexists throw_if_not_exists
-#
-#
-### ##################################################
-#
-#LDADD =       $(top_srcdir)/zypp/lib@PACKAGE@.la 
-#
-### ##################################################
-#
-#media1_SOURCES = media1.cc mymediaverifier.h
-#media1_LDADD = $(LDADD) -lboost_unit_test_framework
-#
-#fileexists_SOURCES = file_exists_test.cc mymediaverifier.h
-#fileexists_LDADD = $(LDADD) -lboost_unit_test_framework
-#
-#media2_SOURCES = media2.cc mymediaverifier.h
-#media2_LDADD = $(LDADD)
-#
-#media3_SOURCES = media3.cc mymediaverifier.h
-#media3_LDADD = $(LDADD)
-#
-#media4_SOURCES = media4.cc mymediaverifier.h
-#media4_LDADD = $(LDADD)
-#
-#throw_if_not_exists_SOURCES = throw_if_not_exists.cc mymediaverifier.h
-#throw_if_not_exists_LDADD = $(LDADD) -lboost_unit_test_framework
-#
-### ##################################################
-#
-#.PHONY:        always
-#
-#$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
-#
-##$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
-##     $(MAKE) -C $(top_srcdir)/zypp
-#
-### ##################################################
\ No newline at end of file
+ADD_TESTS(media1 media2 media3 media4 file_exists throw_if_not_exists)
\ No newline at end of file
index b65bedd..3a06301 100644 (file)
@@ -18,7 +18,7 @@ using namespace zypp::media;
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
 
-void http_test()
+BOOST_AUTO_TEST_CASE(http_test)
 {
   //MediaVerifierRef verifier( new MyMediaVerifier() );
   MediaManager     mm;
@@ -58,7 +58,7 @@ void ftp_test()
   mm.release(id); 
 }
 
-void iso_test()
+BOOST_AUTO_TEST_CASE(isotest)
 {
    if ( geteuid() != 0 )
    {
@@ -83,7 +83,7 @@ void iso_test()
   mm.release(id); 
 }
 
-void nfs_test()
+BOOST_AUTO_TEST_CASE(nfs_tst)
 {
    if ( geteuid() != 0 )
    {
@@ -103,19 +103,4 @@ void nfs_test()
   
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-  //tests would need root-privileges
-  test_suite* test= BOOST_TEST_SUITE( "MediaFileExistTest" );
-  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
-  test->add( BOOST_TEST_CASE( &http_test ), 0 /* expected zero error */ );
-  test->add( BOOST_TEST_CASE( &ftp_test ), 0 /* expected zero error */ );
-  //test->add( BOOST_TEST_CASE( &iso_test ), 0 /* expected zero error */ );
-  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
-  return test;
-}
-
-
-
 // vim: set ts=2 sts=2 sw=2 ai et:
similarity index 79%
rename from tests/media/media1.cc
rename to tests/media/media1_test.cc
index 867ecc2..31e12c5 100644 (file)
@@ -17,7 +17,7 @@ using namespace zypp::media;
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
 
-void verifier_test()
+BOOST_AUTO_TEST_CASE(verifier_test)
 {
   MediaVerifierRef verifier(
       new MyMediaVerifier(/* "SUSE-Linux-CORE-i386 9" */)
@@ -35,14 +35,4 @@ void verifier_test()
   mm.provideFile(id, Pathname("/suse/setup/descr/EXTRA_PROV"));  
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-  test_suite* test= BOOST_TEST_SUITE( "MediaVerifierTest" );
-  test->add( BOOST_TEST_CASE( &verifier_test ), 0 /* expected zero error */ );
-  return test;
-}
-
-
-
 // vim: set ts=2 sts=2 sw=2 ai et:
similarity index 92%
rename from tests/media/media2.cc
rename to tests/media/media2_test.cc
index aa8716a..39e842a 100644 (file)
 
 #include "mymediaverifier.h"
 
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
 using namespace zypp;
 using namespace zypp::media;
 
@@ -36,7 +41,7 @@ do { \
   if( do_step) { pause(); if( do_quit) exit(0); } \
 } while(0);
 
-int main(int argc, char *argv[])
+BOOST_AUTO_TEST_CASE(strange_test)
 {
   {
       struct sigaction sa;
@@ -47,8 +52,8 @@ int main(int argc, char *argv[])
       sa.sa_handler = quit;
       sigaction(SIGTERM, &sa, NULL);
 
-      if( argc > 1 && std::string(argv[1]) == "-i")
-        do_step = true;
+      //if( argc > 1 && std::string(argv[1]) == "-i")
+      //  do_step = true;
   }
 
   MediaVerifierRef verifier(
@@ -142,8 +147,6 @@ int main(int argc, char *argv[])
     // hmm...
     ERR << "Catched *unknown* exception" << std::endl;
   }
-
-  return 0;
 }
 
 // vim: set ts=2 sts=2 sw=2 ai et:
similarity index 84%
rename from tests/media/media3.cc
rename to tests/media/media3_test.cc
index 0679b1f..988f291 100644 (file)
 
 #include "mymediaverifier.h"
 
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
 using namespace zypp;
 using namespace zypp::media;
 
@@ -35,7 +40,7 @@ do { \
   if( do_step) { pause(); if( do_quit) exit(0); } \
 } while(0);
 
-int main(int argc, char *argv[])
+BOOST_AUTO_TEST_CASE(strange_test)
 {
   bool eject_src = false;
   bool close_src = false;
@@ -48,18 +53,18 @@ int main(int argc, char *argv[])
       sa.sa_handler = quit;
       sigaction(SIGTERM, &sa, NULL);
 
-      std::cerr << "ARGS=" << argc << std::endl;
-      for(int i=1; i < argc; i++)
-      {
-        if( std::string(argv[i]) == "-i")
-          do_step = true;
-        else
-        if( std::string(argv[i]) == "-e")
-          eject_src = true;
-        else
-        if( std::string(argv[i]) == "-c")
-          close_src = true;
-      }
+//       std::cerr << "ARGS=" << argc << std::endl;
+//       for(int i=1; i < argc; i++)
+//       {
+//         if( std::string(argv[i]) == "-i")
+//           do_step = true;
+//         else
+//         if( std::string(argv[i]) == "-e")
+//           eject_src = true;
+//         else
+//         if( std::string(argv[i]) == "-c")
+//           close_src = true;
+//       }
   }
 
   MediaVerifierRef verifier(
@@ -148,8 +153,6 @@ int main(int argc, char *argv[])
     // hmm...
     ERR << "Catched *unknown* exception" << std::endl;
   }
-
-  return 0;
 }
 
 // vim: set ts=2 sts=2 sw=2 ai et:
similarity index 89%
rename from tests/media/media4.cc
rename to tests/media/media4_test.cc
index e731b4d..4f4e93a 100644 (file)
 
 #include <signal.h>
 #include <stdlib.h>
+#include <boost/test/unit_test.hpp>
 
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
 using namespace zypp;
 using namespace zypp::media;
 
@@ -37,7 +40,7 @@ do { \
   if( do_step) { pause(); if( do_quit) exit(0); } \
 } while(0);
 
-int main(int argc, char *argv[])
+BOOST_AUTO_TEST_CASE(strange_test)
 {
   {
       struct sigaction sa;
@@ -48,8 +51,8 @@ int main(int argc, char *argv[])
       sa.sa_handler = quit;
       sigaction(SIGTERM, &sa, NULL);
 
-      if( argc > 1 && std::string(argv[1]) == "-i")
-        do_step = true;
+//       if( argc > 1 && std::string(argv[1]) == "-i")
+//         do_step = true;
   }
 
   MediaManager     mm;
@@ -93,8 +96,6 @@ int main(int argc, char *argv[])
     // hmm...
     ERR << "Catched *unknown* exception" << std::endl;
   }
-
-  return 0;
 }
 
 // vim: set ts=2 sts=2 sw=2 ai et:
index 1690b20..25e1113 100644 (file)
@@ -1,11 +1,2 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN )
 
-ADD_EXECUTABLE( inifile iniparser_test.cc )
-TARGET_LINK_LIBRARIES( inifile zypp boost_unit_test_framework )
-
-ADD_TEST(inifile ${CMAKE_CURRENT_BINARY_DIR}/inifile ${CMAKE_CURRENT_SOURCE_DIR}/data )
-
-ADD_EXECUTABLE( inidict inidict_test.cc )
-TARGET_LINK_LIBRARIES( inidict zypp boost_unit_test_framework )
-
-ADD_TEST(inidict ${CMAKE_CURRENT_BINARY_DIR}/inifile ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TESTS(inidict iniparser)
\ No newline at end of file
index dcdd4ae..f5b6370 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/InputStream.h"
@@ -21,10 +19,11 @@ using namespace zypp;
 using namespace zypp::parser;
 using namespace boost::unit_test;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) +  "/parser/inifile/data")
 
-void ini_read_test(const string &dir)
+BOOST_AUTO_TEST_CASE(ini_read)
 {
-  InputStream is((Pathname(dir)+"/1.ini"));
+  InputStream is((DATADIR+"/1.ini"));
   IniDict dict(is);
 
   //MIL << dict["homedmacvicar"]["type"] << endl;
@@ -45,9 +44,9 @@ void ini_read_test(const string &dir)
   BOOST_CHECK( !dict.hasEntry("foo", "bar") );
 }
 
-void ini_read_test2(const string &dir)
+BOOST_AUTO_TEST_CASE(ini_read2)
 {
-  InputStream is((Pathname(dir)+"/2.ini"));
+  InputStream is((DATADIR+"/2.ini"));
   IniDict dict(is);
 
   BOOST_CHECK( find( dict.sectionsBegin(), dict.sectionsEnd(), "base" ) != dict.sectionsEnd() );
@@ -55,31 +54,4 @@ void ini_read_test2(const string &dir)
   //BOOST_CHECK( i != dict.entriesEnd("base") );
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/parser/inifile/data").asString();
-    cout << "inidict_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-  
-  test_suite* test= BOOST_TEST_SUITE("ini_file");
-  
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&ini_read_test,
-                                 (std::string const*)params, params+1));
-  test->add(BOOST_PARAM_TEST_CASE(&ini_read_test2,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
 // vim: set ts=2 sts=2 sw=2 ai et:
index b4acb1b..bb647fc 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/InputStream.h"
@@ -20,6 +18,8 @@ using namespace zypp;
 using namespace zypp::parser;
 using namespace boost::unit_test;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) +  "/parser/inifile/data")
+
 class IniTest : public IniParser
 {
   virtual void consume( const std::string &section )
@@ -69,45 +69,16 @@ class WithSpacesTest : public IniParser
   }
 };
 
-void ini_read_test(const string &dir)
+BOOST_AUTO_TEST_CASE(ini_read)
 {
-  InputStream is((Pathname(dir)+"/1.ini"));
+  InputStream is((DATADIR+"/1.ini"));
   IniTest parser;
   parser.parse(is);
 }
 
-void ini_spaces_test(const string &dir)
+BOOST_AUTO_TEST_CASE(ini_spaces_test)
 {
-  InputStream is((Pathname(dir)+"/2.ini"));
+  InputStream is((DATADIR+"/2.ini"));
   WithSpacesTest parser;
   parser.parse(is);
 }
-
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/parser/inifile/data").asString();
-    cout << "inifile_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  test_suite* test= BOOST_TEST_SUITE("ini_file");
-
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&ini_read_test,
-                                 (std::string const*)params, params+1));
-  test->add(BOOST_PARAM_TEST_CASE(&ini_spaces_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
-// vim: set ts=2 sts=2 sw=2 ai et:
index 8dd5271..7893bb6 100644 (file)
@@ -1,14 +1,2 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN )
 
-ADD_EXECUTABLE( RepomdFileReader RepomdFileReader_test.cc )
-TARGET_LINK_LIBRARIES( RepomdFileReader zypp boost_unit_test_framework )
-
-ADD_EXECUTABLE( PatchesFileReader PatchesFileReader_test.cc )
-TARGET_LINK_LIBRARIES( PatchesFileReader zypp boost_unit_test_framework )
-
-ADD_EXECUTABLE( PatchFileReader PatchFileReader_test.cc )
-TARGET_LINK_LIBRARIES( PatchFileReader zypp boost_unit_test_framework )
-
-ADD_TEST(RepomdFileReader ${CMAKE_CURRENT_BINARY_DIR}/RepomdFileReader ${CMAKE_CURRENT_SOURCE_DIR}/data )
-ADD_TEST(PatchesFileReader ${CMAKE_CURRENT_BINARY_DIR}/PatchesFileReader ${CMAKE_CURRENT_SOURCE_DIR}/data )
-ADD_TEST(PatchFileReader ${CMAKE_CURRENT_BINARY_DIR}/PatchFileReader ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TESTS(RepomdFileReader PatchesFileReader PatchFileReader)
\ No newline at end of file
index 9eb0bb5..272c07b 100644 (file)
@@ -1,6 +1,4 @@
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/base/Easy.h"
 #include "zypp/Url.h"
@@ -14,6 +12,8 @@ using namespace boost::unit_test;
 using namespace zypp;
 using namespace zypp::parser::yum;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/yum/data")
+
 struct Check_fetchmsttfonts
 {
   bool operator()( const data::Patch_Ptr & data_r )
@@ -62,24 +62,7 @@ void patch_read_test( const Pathname & file_r )
   PatchFileReader( file_r, Check_fetchmsttfonts() );
 }
 
-test_suite * init_unit_test_suite( int argc, char * argv[] )
+BOOST_AUTO_TEST_CASE(patch_read)
 {
-  Pathname patchfile;
-  --argc; ++argv;
-  if ( argc )
-  {
-    patchfile = argv[0];
-    if ( PathInfo( patchfile ).isDir() )
-      patchfile /= "patch-fetchmsttfonts.sh-4347.xml";
-  }
-  else
-  {
-    patchfile = TESTS_SRC_DIR;
-    patchfile /= "parser/yum/data/patch-fetchmsttfonts.sh-4347.xml";
-  }
-
-  test_suite * test = BOOST_TEST_SUITE( "PatchFileReader" );
-  test->add( BOOST_PARAM_TEST_CASE( &patch_read_test, &patchfile, &patchfile+1 ) );
-
-  return test;
+  patch_read_test(DATADIR + "patch-fetchmsttfonts.sh-4347.xml");
 }
index 033a3f1..71b7d01 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/OnMediaLocation.h"
 #include "zypp/parser/yum/PatchesFileReader.h"
@@ -18,6 +16,8 @@ using namespace boost::unit_test;
 
 using namespace zypp::parser::yum;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/parser/yum/data")
+
 class Collector
 {
 public:
@@ -36,10 +36,10 @@ public:
   //vector<OnMediaLocation> items;
 };
 
-void patches_read_test(const string &dir)
+BOOST_AUTO_TEST_CASE(patches_read_test)
 {
   list<Pathname> entries;
-  if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
+  if ( filesystem::readdir( entries, DATADIR, false ) != 0 )
     ZYPP_THROW(Exception("failed to read directory"));
   
   for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
@@ -78,30 +78,4 @@ void patches_read_test(const string &dir)
   }
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/parser/yum/data").asString();
-    cout << "PatchesFileReader_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-    
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-  
-  test_suite* test= BOOST_TEST_SUITE("PatchesFileReader");
-  
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&patches_read_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
 // vim: set ts=2 sts=2 sw=2 ai et:
index 8398a3e..b6aa3c5 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/parser/yum/RepomdFileReader.h"
 #include "zypp/Url.h"
@@ -18,6 +16,8 @@ using namespace boost::unit_test;
 using namespace zypp::parser::yum;
 using repo::yum::ResourceType;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/yum/data")
+
 class Collector
 {
 public:
@@ -36,10 +36,10 @@ public:
   //vector<OnMediaLocation> items;
 };
 
-void repomd_read_test(const string &dir)
+BOOST_AUTO_TEST_CASE(repomd_read)
 {
   list<Pathname> entries;
-  if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
+  if ( filesystem::readdir( entries, DATADIR, false ) != 0 )
     ZYPP_THROW(Exception("failed to read directory"));
     
   for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
@@ -77,22 +77,5 @@ void repomd_read_test(const string &dir)
   }
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  if (argc < 2)
-  {
-    cout << "RepomdFileReader_test:"
-      " path to directory with test data required as parameter" << endl;
-    return (test_suite *)0;
-  }
-  
-  test_suite* test= BOOST_TEST_SUITE("RepomdFileReader");
-  string datadir = argv[1];
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&repomd_read_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
 
 // vim: set ts=2 sts=2 sw=2 ai et:
index b0a26bf..571c9ca 100644 (file)
@@ -1,9 +1,4 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN )
-
 ADD_SUBDIRECTORY( yum )
 ADD_SUBDIRECTORY( susetags )
 
-ADD_EXECUTABLE( RepoVariables RepoVariables_test.cc )
-TARGET_LINK_LIBRARIES( RepoVariables zypp boost_unit_test_framework )
-
-ADD_TEST(RepoVariables ${CMAKE_CURRENT_BINARY_DIR}/RepoVariables ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TESTS(RepoVariables)
index c5b1e7e..69ee58b 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/ZYppFactory.h"
 #include "zypp/Url.h"
@@ -19,10 +17,11 @@ using std::endl;
 using std::string;
 using namespace zypp;
 using namespace boost::unit_test;
-
 using namespace zypp::repo;
 
-void replace_test(const string &dir)
+#define DATADIR (Pathname(TESTS_SRC_DIR) +  "/repo/yum/data")
+
+BOOST_AUTO_TEST_CASE(replace_text)
 {
   /* check RepoVariablesStringReplacer */
 
@@ -49,30 +48,4 @@ void replace_test(const string &dir)
                    "http://site.org/update/?arch=i686");
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/repo/yum/data").asString();
-    cout << "RepoVariables_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  test_suite* test= BOOST_TEST_SUITE("RepoVariables");
-
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&replace_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
 // vim: set ts=2 sts=2 sw=2 ai et:
index f59dffc..4993c4e 100644 (file)
@@ -1,9 +1,2 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN )
 
-ADD_EXECUTABLE( 
-  Downloader
-  Downloader_test.cc
-)
-TARGET_LINK_LIBRARIES( Downloader zypp boost_unit_test_framework )
-
-ADD_TEST(Downloader ${CMAKE_CURRENT_BINARY_DIR}/Downloader ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TESTS(Downloader)
\ No newline at end of file
index f05df92..a474651 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/base/Logger.h"
 #include "zypp/Url.h"
@@ -20,15 +18,16 @@ using std::endl;
 using std::string;
 using namespace zypp;
 using namespace boost::unit_test;
-
 using namespace zypp::repo;
 
-void susetags_download_test(const string &dir)
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/repo/susetags/data")
+
+BOOST_AUTO_TEST_CASE(susetags_download)
 {
   KeyRingTestReceiver keyring_callbacks;
   keyring_callbacks.answerTrustKey(true);
 
-  Pathname p = dir + "/stable-x86-subset";
+  Pathname p = DATADIR + "/stable-x86-subset";
   Url url("dir:" + p.asString());
   MediaSetAccess media(url);
   susetags::Downloader downloader("/");
@@ -79,12 +78,12 @@ void susetags_download_test(const string &dir)
 
 }
 
-void susetags_gz_download_test(const string &dir)
+BOOST_AUTO_TEST_CASE(susetags_gz_download)
 {
   KeyRingTestReceiver keyring_callbacks;
   keyring_callbacks.answerTrustKey(true);
 
-  Pathname p = dir + "/stable-x86-subset-gz";
+  Pathname p = DATADIR + "/stable-x86-subset-gz";
   Url url("dir:" + p.asString());
   MediaSetAccess media(url);
   susetags::Downloader downloader("/");
@@ -135,32 +134,4 @@ void susetags_gz_download_test(const string &dir)
 
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/repo/susetags/data").asString();
-    cout << "SUSETags Downloader_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-    
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-  
-  test_suite* test= BOOST_TEST_SUITE("SUSETags Downloader");
-  
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&susetags_download_test,
-                                 (std::string const*)params, params+1));
-  test->add(BOOST_PARAM_TEST_CASE(&susetags_gz_download_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
 // vim: set ts=2 sts=2 sw=2 ai et:
index 7e82258..de237c0 100644 (file)
@@ -1,6 +1,2 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN )
 
-ADD_EXECUTABLE( YUMDownloader YUMDownloader_test.cc )
-TARGET_LINK_LIBRARIES( YUMDownloader zypp boost_unit_test_framework )
-
-ADD_TEST(YUMDownloader ${CMAKE_CURRENT_BINARY_DIR}/YUMDownloader ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TESTS(YUMDownloader)
\ No newline at end of file
index 952af39..993d230 100644 (file)
@@ -4,8 +4,6 @@
 #include <vector>
 #include <list>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/base/Logger.h"
 #include "zypp/Url.h"
@@ -18,17 +16,18 @@ using std::endl;
 using std::string;
 using namespace zypp;
 using namespace boost::unit_test;
-
 using namespace zypp::repo;
 
 #include "tests/zypp/KeyRingTestReceiver.h"
 
-void yum_download_test(const string &dir)
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/repo/yum/data")
+
+BOOST_AUTO_TEST_CASE(yum_download)
 {
   KeyRingTestReceiver keyring_callbacks;
   keyring_callbacks.answerTrustKey(true);
 
-  Pathname p = dir + "/10.2-updates-subset";
+  Pathname p = DATADIR + "/10.2-updates-subset";
   Url url("dir:" + p.asString());
   MediaSetAccess media(url);
   yum::Downloader yum("/");
@@ -65,30 +64,4 @@ void yum_download_test(const string &dir)
 
 }
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/repo/yum/data").asString();
-    cout << "YUMDownloader_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-    
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-  
-  test_suite* test= BOOST_TEST_SUITE("YUMDownloader");
-  
-  std::string const params[] = { datadir };
-  test->add(BOOST_PARAM_TEST_CASE(&yum_download_test,
-                                 (std::string const*)params, params+1));
-  return test;
-}
-
 // vim: set ts=2 sts=2 sw=2 ai et:
index 075872a..7a46dd2 100644 (file)
@@ -29,7 +29,7 @@ using namespace zypp;
 **
 **      DESCRIPTION :
 */
-void arch_test()
+BOOST_AUTO_TEST_CASE(arch_test)
 {
   Arch _arch32( "i386" );
 
@@ -43,11 +43,3 @@ void arch_test()
   BOOST_REQUIRE( ! Arch_noarch.empty() );
   BOOST_REQUIRE( ! ( _arch32.compare(Arch_x86_64) >= 0) );
 }
-
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "ArchTest" );
-    test->add( BOOST_TEST_CASE( &arch_test ), 0 /* expected zero error */ );
-    return test;
-}
index d25da0a..4372fa9 100644 (file)
@@ -1,25 +1,4 @@
-# source:     ${loop_var}_test.cc
-# executable: ${loop_var}_test
-# test:       ${loop_var}_test
 ADD_SUBDIRECTORY(base)
 
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK )
-
-#FOREACH( loop_var Vendor1 Vendor2 TranslatedText PoolQuery KeyRing MediaSetAccess ResKind Arch Url Edition Capabilities CheckSum PublicKey PathInfo Digest Fetcher FileChecker RepoManager RepoInfo RepoStatus ProgressData )
-FOREACH( loop_var PoolQuery )
-   ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
-   TARGET_LINK_LIBRARIES( ${loop_var}_test  zypp boost_unit_test_framework)
-   ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
-ENDFOREACH( loop_var )
-
-ADD_EXECUTABLE(RWPtr RWPtr.cc)
-TARGET_LINK_LIBRARIES(RWPtr zypp)
-
-ADD_EXECUTABLE(PtrTypes PtrTypes.cc)
-TARGET_LINK_LIBRARIES(PtrTypes zypp  )
-
-#ADD_EXECUTABLE(Signature Signature.cc)
-#TARGET_LINK_LIBRARIES(Signature zypp boost_unit_test_framework)
-
-ADD_TEST(PtrTypesTest ${CMAKE_CURRENT_BINARY_DIR}/PtrTypes)
+ADD_TESTS(RWPtr Vendor TranslatedText PoolQuery KeyRing MediaSetAccess ResKind Arch Url Edition Capabilities CheckSum PublicKey PathInfo Digest Fetcher FileChecker RepoManager RepoInfo RepoStatus ProgressData )
 
index 7e84107..2dc570b 100644 (file)
@@ -17,7 +17,7 @@ using boost::test_tools::close_at_tolerance;
 using namespace std;
 using namespace zypp;
 
-void capabilities_test()
+BOOST_AUTO_TEST_CASE(capabilities_test)
 {
 //     Resolvable::Kind kind = ResTraits<zypp::Package>::kind;
 //     CapFactory factory;
@@ -80,10 +80,3 @@ void capabilities_test()
   BOOST_CHECK_EQUAL( Capability::matches( c0, c1 ), CapMatch::yes );
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "CapabilitiesTest" );
-    test->add( BOOST_TEST_CASE( &capabilities_test ), 0 /* expected zero error */ );
-    return test;
-}
index 69336b9..0de9221 100644 (file)
@@ -4,27 +4,20 @@
 #include <string>
 
 // Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
-using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
-// parameterized test
-// http://www.boost.org/libs/test/example/unit_test_example4.cpp
-
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
 #include "zypp/ZYppFactory.h"
 #include "zypp/ZYpp.h"
 
+using boost::unit_test::test_case;
 using namespace std;
 using namespace zypp;
 
 
 // most frequently you implement test cases as a free functions
-void checksum_test()
+BOOST_AUTO_TEST_CASE(checksum_test)
 {
   BOOST_CHECK_THROW( CheckSum( "sha1", "dsdsads" ), Exception ); // wrong size
   BOOST_CHECK_THROW( CheckSum( "sha256", "dsdsads" ), Exception ); // wrong size
@@ -33,12 +26,3 @@ void checksum_test()
   BOOST_CHECK_THROW( CheckSum( "md2", "dsdsads" ), Exception ); // wrong size
 
 }
-
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "CheckSumTest" );
-    test->add( BOOST_TEST_CASE( &checksum_test ), 5 /* expected zero error */ , 0);
-    return test;
-}
-
index 8e7ef63..b385c7f 100644 (file)
@@ -5,22 +5,15 @@
 #include <list>
 #include <string>
 
-// Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
-using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
-// parameterized test
-// http://www.boost.org/libs/test/example/unit_test_example4.cpp
-
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
 #include "zypp/PathInfo.h"
 #include "zypp/Digest.h"
 
+using boost::unit_test::test_case;
+
 using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
@@ -29,7 +22,7 @@ using namespace zypp::filesystem;
  * Test case for
  * static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
  */
-void digest_test()
+BOOST_AUTO_TEST_CASE(digest)
 {
   string data("I will test the checksum of this");
   stringstream str1(data);
@@ -41,12 +34,3 @@ void digest_test()
   // FIXME i think it should throw
   BOOST_CHECK_EQUAL( Digest::digest( "lalala", str3) , "" ); 
 }
-
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "DigestTest" );
-    test->add( BOOST_TEST_CASE( &digest_test ), 0 /* expected zero error */ );
-    return test;
-}
-
index e6b6fc4..72e1bd7 100644 (file)
@@ -8,13 +8,12 @@
 
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
 
 using namespace std;
 using namespace zypp;
 
-void edition_test()
+BOOST_AUTO_TEST_CASE(edition)
 {
   Edition _ed1 ("1");
   Edition _ed2 ("1.1");
@@ -36,11 +35,3 @@ void edition_test()
   BOOST_CHECK_EQUAL( Edition::compare("2:1-1","2:1-1"), 0 );
   BOOST_CHECK_EQUAL( Edition::compare("3:1-1","2:1-1"), 1 );
 }
-
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "EditionTest" );
-    test->add( BOOST_TEST_CASE( &edition_test ), 0 /* expected zero error */ );
-    return test;
-}
index 8b0600f..c016eae 100644 (file)
@@ -15,30 +15,12 @@ using namespace zypp;
 using namespace zypp::media;
 using namespace boost::unit_test;
 
-void fetcher_simple_test()
-{
-  string dir(TESTS_SRC_DIR);
-  dir += "/zypp/data/Fetcher/remote-site";
-  MediaSetAccess media( "dir:" + dir, "/" );
-  Fetcher fetcher;
-}
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site")
 
-test_suite*
-init_unit_test_suite( int argc, char *argv[] )
+BOOST_AUTO_TEST_CASE(fetcher)
 {
-//   if (argc < 2)
-//   {
-//     cout << "mediasetaccesstest:"
-//       " path to directory with test data required as parameter" << endl;
-//     return (test_suite *)0;
-//   }
-
-  test_suite* test= BOOST_TEST_SUITE("Fetcher_test");
-
-  // simple test
-  test->add(BOOST_TEST_CASE(&fetcher_simple_test));
-
-  return test;
+  MediaSetAccess media( ("dir:" + DATADIR).asUrl(), "/" );
+  Fetcher fetcher;
 }
 
 // vim: set ts=2 sts=2 sw=2 ai et:
index 078583d..b56fc0f 100644 (file)
 #include "zypp/FileChecker.h"
 
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "KeyRingTestReceiver.h"
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using namespace boost::unit_test::log;
 
 using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
 
-void keyring_test( const string &dir )
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/FileChecker")
+
+BOOST_AUTO_TEST_CASE(keyring_test)
 {
-  Pathname file( Pathname(dir) + "hello.txt" );
-  Pathname file2( Pathname(dir) + "hello2.txt" );
-  Pathname pubkey( Pathname(dir) + "hello.txt.key" );
-  Pathname signature( Pathname(dir) + "hello.txt.asc" );
+  Pathname file( Pathname(DATADIR) + "hello.txt" );
+  Pathname file2( Pathname(DATADIR) + "hello2.txt" );
+  Pathname pubkey( Pathname(DATADIR) + "hello.txt.key" );
+  Pathname signature( Pathname(DATADIR) + "hello.txt.asc" );
   
   /**
    * 1st scenario, the signature does
@@ -65,12 +64,12 @@ void keyring_test( const string &dir )
   
 }
 
-void checksum_test( const string &dir )
+BOOST_AUTO_TEST_CASE(checksum_test)
 {
-  Pathname file( Pathname(dir) + "hello.txt" );
-  Pathname file2( Pathname(dir) + "hello2.txt" );
-  Pathname pubkey( Pathname(dir) + "hello.txt.key" );
-  Pathname signature( Pathname(dir) + "hello.txt.asc" );
+  Pathname file( Pathname(DATADIR) + "hello.txt" );
+  Pathname file2( Pathname(DATADIR) + "hello2.txt" );
+  Pathname pubkey( Pathname(DATADIR) + "hello.txt.key" );
+  Pathname signature( Pathname(DATADIR) + "hello.txt.asc" );
   
   /**
    * 1st scenario, checksum matches
@@ -89,30 +88,3 @@ void checksum_test( const string &dir )
   }
 }
 
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/zypp/data/FileChecker").asString();
-    cout << "filechecker_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  std::string const params[] = { datadir };
-    //set_log_stream( std::cout );
-  test_suite* test= BOOST_TEST_SUITE( "FileCheckerTest" );
-  test->add(BOOST_PARAM_TEST_CASE( &keyring_test,
-                              (std::string const*)params, params+1));
-  test->add(BOOST_PARAM_TEST_CASE( &checksum_test,
-                              (std::string const*)params, params+1));
-  return test;
-}
-
index 08e8a83..9500def 100644 (file)
@@ -11,8 +11,6 @@
 #include "zypp/TmpPath.h"
 
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "KeyRingTestReceiver.h"
 
@@ -24,11 +22,11 @@ using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
 
-void keyring_test( const string &dir )
+#define DATADIR (Pathname(TESTS_SRC_DIR) +  "/zypp/data/KeyRing")
+
+BOOST_AUTO_TEST_CASE(keyring_test)
 {
-  PublicKey key( Pathname(dir) + "public.asc" );
-  
-  
+  PublicKey key( Pathname(DATADIR) + "public.asc" );
 
  /** 
   * scenario #1
@@ -55,7 +53,7 @@ void keyring_test( const string &dir )
     BOOST_CHECK_MESSAGE( ! keyring.isKeyTrusted( key.id() ), "Imported untrusted key should be untrusted");
     
     keyring_callbacks.answerTrustKey(true);
-    bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc");
+    bool to_continue = keyring.verifyFileSignatureWorkflow( DATADIR + "repomd.xml", "Blah Blah", DATADIR + "repomd.xml.asc");
   
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known");
     BOOST_CHECK_MESSAGE( keyring_callbacks.askedTrustKey(), "Verify Signature Workflow with only 1 untrusted key should ask user wether to trust");
@@ -88,7 +86,7 @@ void keyring_test( const string &dir )
     keyring_callbacks.answerTrustKey(true);
     
     // now we will recheck with a corrupted file
-    bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml.corrupted", "Blah Blah", Pathname(dir) + "repomd.xml.asc");
+    bool to_continue = keyring.verifyFileSignatureWorkflow( DATADIR + "repomd.xml.corrupted", "Blah Blah", DATADIR + "repomd.xml.asc");
     
     // check wether the user got the right questions
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known");
@@ -118,7 +116,7 @@ void keyring_test( const string &dir )
     
     keyring_callbacks.answerTrustKey(true);
     // now we will recheck with a unsigned file
-    bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname() );
+    bool to_continue = keyring.verifyFileSignatureWorkflow( DATADIR + "repomd.xml", "Blah Blah", Pathname() );
     
     // check wether the user got the right questions
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known");
@@ -145,7 +143,7 @@ void keyring_test( const string &dir )
     BOOST_CHECK_MESSAGE( ! keyring.isKeyKnown( key.id() ), "empty keyring has not known keys");
     
     //keyring_callbacks.answerAcceptUnknownKey(true);
-    bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc");
+    bool to_continue = keyring.verifyFileSignatureWorkflow( DATADIR + "repomd.xml", "Blah Blah", DATADIR + "repomd.xml.asc");
     BOOST_CHECK_MESSAGE(keyring_callbacks.askedAcceptUnknownKey(), "Should ask to accept unknown key, empty keyring");
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedTrustKey(), "Unknown key cant be trusted");
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedImportKey(), "Unknown key cant be imported");
@@ -178,7 +176,7 @@ void keyring_test( const string &dir )
     BOOST_CHECK_MESSAGE( keyring.isKeyKnown( key.id() ), "Imported trusted key should be known");
     BOOST_CHECK_MESSAGE( keyring.isKeyTrusted( key.id() ), "Imported trusted key should be trusted");
     
-    bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc");
+    bool to_continue = keyring.verifyFileSignatureWorkflow( DATADIR + "repomd.xml", "Blah Blah", DATADIR + "repomd.xml.asc");
   
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known");
     BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedTrustKey(), "Verify Signature Workflow with only 1 untrusted key should ask user wether to trust");
@@ -196,9 +194,9 @@ void keyring_test( const string &dir )
   
 }
 
-void keyring_signature_test( const string &dir )
+BOOST_AUTO_TEST_CASE(signature_test)
 {
-  PublicKey key( Pathname(dir) + "public.asc" );
+  PublicKey key( DATADIR + "public.asc" );
 
   {
     KeyRingTestReceiver keyring_callbacks;
@@ -207,42 +205,16 @@ void keyring_signature_test( const string &dir )
     TmpDir tmp_dir;
     KeyRing keyring( tmp_dir.path() );
     
-    BOOST_CHECK_EQUAL( keyring.readSignatureKeyId( Pathname(dir) + "repomd.xml.asc" ), "BD61D89BD98821BE" );
+    BOOST_CHECK_EQUAL( keyring.readSignatureKeyId( DATADIR + "repomd.xml.asc" ), "BD61D89BD98821BE" );
     BOOST_CHECK_THROW( keyring.readSignatureKeyId(Pathname()), Exception );
     TmpFile tmp;
     BOOST_CHECK_EQUAL( keyring.readSignatureKeyId(tmp.path()), "" );
 
     keyring.importKey(key);
 
-    BOOST_CHECK(keyring.verifyFileSignature( Pathname(dir) + "repomd.xml", Pathname(dir) + "repomd.xml.asc"));
-    BOOST_CHECK( ! keyring.verifyFileSignature( Pathname(dir) + "repomd.xml.corrupted", Pathname(dir) + "repomd.xml.asc"));
+    BOOST_CHECK(keyring.verifyFileSignature( DATADIR + "repomd.xml", DATADIR + "repomd.xml.asc"));
+    BOOST_CHECK( ! keyring.verifyFileSignature( DATADIR + "repomd.xml.corrupted", DATADIR + "repomd.xml.asc"));
   }
 }
 
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/zypp/data/KeyRing").asString();
-    cout << "keyring_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  std::string const params[] = { datadir };
-    //set_log_stream( std::cout );
-  test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" );
-  test->add(BOOST_PARAM_TEST_CASE( &keyring_test,
-                              (std::string const*)params, params+1));
-  test->add(BOOST_PARAM_TEST_CASE( &keyring_signature_test,
-                              (std::string const*)params, params+1));
-  return test;
-}
 
index 13e627e..79eaa0d 100644 (file)
@@ -4,22 +4,16 @@
 #include <list>
 #include <string>
 
-// Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
-using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
-// parameterized test
-// http://www.boost.org/libs/test/example/unit_test_example4.cpp
-
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
 #include "zypp/PathInfo.h"
 #include "zypp/TmpPath.h"
 
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
 using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
@@ -29,7 +23,7 @@ using namespace zypp::filesystem;
  * bool is_checksum( const Pathname & file, const CheckSum &checksum );
  * std::string checksum( const Pathname & file, const std::string &algorithm );
  */
-void pathinfo_checksum_test()
+BOOST_AUTO_TEST_CASE(pathinfo_checksum_test)
 {
   const char *buffer = "I will test the checksum of this";
   TmpFile file;
@@ -52,7 +46,7 @@ void pathinfo_checksum_test()
   BOOST_REQUIRE( is_checksum( file.path(), file_md5 ) );
 }
 
-void pathinfo_is_exist_test()
+BOOST_AUTO_TEST_CASE(pathinfo_is_exist_test)
 {
   TmpDir dir;
   Pathname subdir("text with spaces");
@@ -68,7 +62,7 @@ void pathinfo_is_exist_test()
   BOOST_CHECK( PathInfo(filepath).isExist() );
 }
 
-void pathinfo_misc_test()
+BOOST_AUTO_TEST_CASE(pathipathinfo_misc_test)
 {
   TmpDir dir;
 
@@ -76,7 +70,7 @@ void pathinfo_misc_test()
   BOOST_CHECK(info.isDir());
 }
 
-void pathinfo_expandlink_test()
+BOOST_AUTO_TEST_CASE(pathinfo_expandlink_test)
 {
   TmpDir dir;
 
@@ -124,14 +118,4 @@ void pathinfo_expandlink_test()
   cout << brokenlink << " -> " << filesystem::expandlink(brokenlink) << endl;
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "PathInfoTest" );
-    test->add( BOOST_TEST_CASE( &pathinfo_checksum_test ), 0 /* expected zero error */ );
-    test->add( BOOST_TEST_CASE( &pathinfo_misc_test ), 0 /* expected zero error */ );
-    test->add( BOOST_TEST_CASE( &pathinfo_is_exist_test ), 0 /* expected zero error */ );
-    test->add( BOOST_TEST_CASE( &pathinfo_expandlink_test ), 0 /* expected zero error */ );
-    return test;
-}
 
index bbff216..a999d25 100644 (file)
@@ -1,12 +1,12 @@
 #include <stdio.h>
 #include <iostream>
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/ZYppFactory.h"
 #include "zypp/PoolQuery.h"
 
+#define BOOST_TEST_MODULE PoolQuery
+
 using std::cout;
 using std::endl;
 using std::string;
@@ -19,7 +19,7 @@ bool result_cb( const ResObject::Ptr &r )
   return true;
 }
 
-void poolquery_simple_test()
+BOOST_AUTO_TEST_CASE(pool_query )
 {
   Pathname dir(TESTS_SRC_DIR);
   dir += "/zypp/data/PoolQuery";
@@ -40,15 +40,15 @@ void poolquery_simple_test()
   cout << "search done." << endl;
 }
 
-bool init_function() {
-  framework::master_test_suite().add( BOOST_TEST_CASE( boost::bind( &poolquery_simple_test) ) );
-  return true;
-} 
-
-int
-main( int argc, char* argv[] )
-{
-return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
-} 
+// bool init_function() {
+//   framework::master_test_suite().add( BOOST_TEST_CASE( boost::bind( &poolquery_simple_test) ) );
+//   return true;
+// 
+// 
+// int
+// main( int argc, char* argv[] )
+// {
+// return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
+// 
 
 // vim: set ts=2 sts=2 sw=2 ai et:
index 70713a4..2d3900f 100644 (file)
@@ -8,19 +8,15 @@
 #include "zypp/base/Exception.h"
 
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 #include "zypp/ProgressData.h"
 
-using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using namespace boost::unit_test::log;
 
 using namespace std;
 using namespace zypp;
 
-void progressdata_test()
+BOOST_AUTO_TEST_CASE(progressdata_test)
 {
   {
     ProgressData progress(100);
@@ -60,12 +56,5 @@ void progressdata_test()
   }
   
 }
-
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  test_suite* test= BOOST_TEST_SUITE( "ProgressData_test" );
-    test->add( BOOST_TEST_CASE( &progressdata_test ), 0 /* expected zero error */ );
-    return test;
-}
+   
 
similarity index 97%
rename from tests/zypp/PtrTypes.cc
rename to tests/zypp/PtrTypes_test.cc
index a986b88..556ad58 100644 (file)
@@ -1,14 +1,19 @@
 #include <iostream>
 
+#include <boost/test/unit_test.hpp>
+
 #include "zypp/base/Logger.h"
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/ReferenceCounted.h>
 #include <zypp/base/ProvideNumericId.h>
 
+#define BOOST_TEST_MODULE PtrTypes
+
 using std::endl;
 using namespace zypp;
 using namespace zypp::base;
 
+
 #define TRACE_TAG DBG << this->numericId() << " " << __PRETTY_FUNCTION__ << endl
 
 /** Logs Ctor, CopyCtor, Assign and Dtor. */
@@ -116,7 +121,7 @@ template<class _RW>
 **      FUNCTION NAME : main
 **      FUNCTION TYPE : int
 */
-int main( int argc, char * argv[] )
+BOOST_AUTO_TEST_CASE(basic_test)
 {
   MIL << "===[START]=====" << endl;
   test<RW_pointer<NonIntrusive,          rw_pointer::Shared<NonIntrusive> > >();
@@ -130,5 +135,4 @@ int main( int argc, char * argv[] )
   cowt<RWCOW_pointer<const Intrusive,    rw_pointer::Intrusive<Intrusive> > >();
 
   MIL << "===[DONE]=====" << endl;
-  return 0;
 }
index ac0b6b2..181b382 100644 (file)
@@ -235,7 +235,7 @@ char susekey[]=
 size_t _susekey_size=2173;
 size_t *susekey_size=&_susekey_size;
 
-void publickey_test()
+BOOST_AUTO_TEST_CASE(publickey_test)
 {
   BOOST_CHECK_THROW( zypp::PublicKey("nonexistant"), Exception );
   
@@ -261,11 +261,3 @@ void publickey_test()
   BOOST_REQUIRE( ! empty_key.isValid() );
 }
 
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" );
-    test->add( BOOST_TEST_CASE( &publickey_test ), 0 /* expected zero error */ );
-    return test;
-}
-
similarity index 92%
rename from tests/zypp/RWPtr.cc
rename to tests/zypp/RWPtr_test.cc
index 6e1ddc6..ec11010 100644 (file)
@@ -1,7 +1,11 @@
+#include <boost/test/unit_test.hpp>
+
 #include <zypp/base/PtrTypes.h>
 #include <string>
 #include <iostream>
 
+#define BOOST_TEST_MODULE RWPtr_test
+
 struct Foo
 {
   int _foo;
@@ -46,11 +50,9 @@ do { \
   std::cerr << std::endl; \
 } while(0);
 
-int main(int argc, char *argv[])
+BOOST_AUTO_TEST_CASE(basic_test)
 {
-  (void)argv;
-
-  bool skip_reset = argc > 1;
+  bool skip_reset = false;
   int  result = 0;
 
   typedef zypp::RW_pointer<Foo> FooRef;
@@ -77,6 +79,5 @@ int main(int argc, char *argv[])
   std::cerr << "RESULT: "
             << (result == 0 ? "PASSED" : "FAILED")
             << std::endl;
-  return result;
 }
 
index d95ccaf..97ee150 100644 (file)
@@ -24,33 +24,9 @@ using namespace zypp;
 using namespace zypp::filesystem;
 using namespace zypp::repo;
 
-void repoinfo_test( const string &dir )
+BOOST_AUTO_TEST_CASE(repoinfo_test)
 {
 
 }
 
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/zypp/data/RepoInfo").asString();
-    cout << "repoinfo_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  std::string const params[] = { datadir };
-    //set_log_stream( std::cout );
-  test_suite* test= BOOST_TEST_SUITE( "RepoInfoTest" );
-  test->add(BOOST_PARAM_TEST_CASE( &repoinfo_test,
-                              (std::string const*)params, params+1));
-  return test;
-}
 
index 50f42d3..50e96a8 100644 (file)
 #include "zypp/RepoManager.h"
 
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
+
 
 #include "KeyRingTestReceiver.h"
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using namespace boost::unit_test::log;
 
 using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
 using namespace zypp::repo;
 
-void repomanager_test( const string &dir )
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/RepoManager")
+
+BOOST_AUTO_TEST_CASE(repomanager_test)
 {
   RepoManagerOptions opts;
   
@@ -36,7 +36,7 @@ void repomanager_test( const string &dir )
   TmpDir tmpRawCachePath;
   TmpDir tmpKnownReposPath;
   
-  BOOST_CHECK_EQUAL( filesystem::copy_dir_content( Pathname(dir) + "/repos.d", tmpKnownReposPath.path() ), 0 );
+  BOOST_CHECK_EQUAL( filesystem::copy_dir_content( DATADIR + "/repos.d", tmpKnownReposPath.path() ), 0 );
   
   opts.repoCachePath = tmpCachePath.path();
   opts.repoRawCachePath = tmpRawCachePath.path();
@@ -49,7 +49,7 @@ void repomanager_test( const string &dir )
   
   // now add a .repo file with 2 repositories in it
   Url url;
-  url.setPathName((Pathname(dir) + "/proprietary.repo").asString());
+  url.setPathName((DATADIR + "/proprietary.repo").asString());
   url.setScheme("file");
 
   manager.addRepositories(url);
@@ -149,28 +149,3 @@ void repomanager_test( const string &dir )
   manager.buildCache(repo);
 }
 
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/zypp/data/RepoManager").asString();
-    cout << "repomanager_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  std::string const params[] = { datadir };
-    //set_log_stream( std::cout );
-  test_suite* test= BOOST_TEST_SUITE( "RepoManagerTest" );
-  test->add(BOOST_PARAM_TEST_CASE( &repomanager_test,
-                              (std::string const*)params, params+1));
-  return test;
-}
-
index e7138a7..62302f6 100644 (file)
@@ -6,28 +6,16 @@
 #include "zypp/PathInfo.h"
 
 #include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using namespace boost::unit_test::log;
 
 using namespace std;
 using namespace zypp;
 using namespace zypp::filesystem;
 
-void repostatus_test()
+BOOST_AUTO_TEST_CASE(repostatus_test)
 {
   TmpDir tmpPath;
   RepoStatus status;
 }
-
-test_suite*
-init_unit_test_suite( int argc, char* argv[] )
-{
-  test_suite* test= BOOST_TEST_SUITE( "RepoStatus" );
-  test->add( BOOST_TEST_CASE( &repostatus_test ), 0 /* expected zero error */ );
-  return test;
-}
-
index 446cb34..9e8cbbf 100644 (file)
@@ -2,12 +2,11 @@
 #include "zypp/base/Logger.h"
 #include "zypp/ResKind.h"
 
-using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
 using namespace std;
 using namespace zypp;
 
-void dotest()
+BOOST_AUTO_TEST_CASE(reskind_test)
 {
   // Default construced is empty ""
   BOOST_CHECK_EQUAL( ResKind(), "" );
@@ -32,9 +31,3 @@ void dotest()
   BOOST_CHECK_EQUAL( ResKind::compare( "FOO", "foo" ), 0 );
 
 }
-test_suite * init_unit_test_suite( int, char * [] )
-{
-    test_suite * test= BOOST_TEST_SUITE( "ResKind_test" );
-    test->add( BOOST_TEST_CASE( &dotest ), 0 /* expected zero error */ );
-    return test;
-}
index 0c8c846..981983b 100644 (file)
@@ -1,8 +1,3 @@
-// Arch.cc
-//
-// tests for Arch
-//
-
 #include <iostream>
 #include <list>
 #include <string>
 #include "zypp/ZYppFactory.h"
 #include "zypp/ZYpp.h"
 
-// Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
 
 using namespace std;
 using namespace zypp;
 
-void test_tt()
+BOOST_AUTO_TEST_CASE(translatedtext_test)
 {
   ZYpp::Ptr god;
 
@@ -57,10 +49,3 @@ void test_tt()
   BOOST_CHECK_EQUAL( testTT.text(), "default" );
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "TranslatedText" );
-    test->add( BOOST_TEST_CASE( &test_tt ), 0 /* expected zero error */ );
-    return test;
-}
index 0e5535d..d0f0e24 100644 (file)
 #include <cassert>
 
 // Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
 using namespace zypp;
 
-void test_url1(void)
+BOOST_AUTO_TEST_CASE(test_url1)
 {
     std::string str, one, two;
     zypp::Url   url;
@@ -127,7 +123,7 @@ void test_url1(void)
     BOOST_CHECK( zypp::Url(str).isValid());
 }
 
-void test_url2(void)
+BOOST_AUTO_TEST_CASE(test_url2)
 {
   zypp::Url url("http://user:pass@localhost:/path/to;version=1.1?arg=val#frag");
 
@@ -146,7 +142,7 @@ void test_url2(void)
   "http://user:pass@localhost/path/to;version=1.1?arg=val#frag");
 }
 
-void test_url3()
+BOOST_AUTO_TEST_CASE(test_url3)
 {
   zypp::Url   url("http://localhost/path/to#frag");
   std::string key;
@@ -187,7 +183,7 @@ void test_url3()
   }
 }
 
-void test_url4()
+BOOST_AUTO_TEST_CASE( test_url4)
 {
   try
   {
@@ -239,16 +235,5 @@ void test_url4()
   }
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    test_suite* test= BOOST_TEST_SUITE( "Url" );
-    test->add( BOOST_TEST_CASE( &test_url1 ), 0 /* expected zero error */ );
-    test->add( BOOST_TEST_CASE( &test_url2 ), 0 );
-    test->add( BOOST_TEST_CASE( &test_url3 ), 0 );
-    test->add( BOOST_TEST_CASE( &test_url4 ), 0 );
-    return test;
-}
-
 
 // vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/zypp/Vendor1_test.cc b/tests/zypp/Vendor1_test.cc
deleted file mode 100644 (file)
index 888c74e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-
-#include <iostream>
-#include <list>
-#include <string>
-
-// Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
-#include <boost/test/unit_test.hpp>
-
-using boost::unit_test::test_suite;
-using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
-// parameterized test
-// http://www.boost.org/libs/test/example/unit_test_example4.cpp
-
-#include "zypp/base/LogControl.h"
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-#include "zypp/ZYpp.h"
-#include "zypp/VendorAttr.h"
-
-using namespace std;
-using namespace zypp;
-
-
-// most frequently you implement test cases as a free functions
-void vendor_test()
-{
-  // No vendor definition files has been readed. So only suse,opensuse vendors are
-  // equivalent
-  BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") );
-  BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") );
-  BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); 
-  BOOST_REQUIRE( VendorAttr::instance().equivalent("opensuse", "SuSE") );
-  BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") );
-  BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") );
-}
-
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    setenv("ZYPP_CONF", "./../../tests/zypp/data/Vendor/zypp1.conf", 1 );
-    zypp::base::LogControl::instance().logfile( "-" );    
-    test_suite* test= BOOST_TEST_SUITE( "VendorTest" );
-    test->add( BOOST_TEST_CASE( &vendor_test ), 5 /* expected zero error */ , 0);
-    return test;
-}
-
similarity index 62%
rename from tests/zypp/Vendor2_test.cc
rename to tests/zypp/Vendor_test.cc
index 17a0680..0d64fd3 100644 (file)
@@ -4,29 +4,36 @@
 #include <string>
 
 // Boost.Test
-#include <boost/test/floating_point_comparison.hpp>
 #include <boost/test/unit_test.hpp>
 
-using boost::unit_test::test_suite;
-using boost::unit_test::test_case;
-using boost::test_tools::close_at_tolerance;
-
-// parameterized test
-// http://www.boost.org/libs/test/example/unit_test_example4.cpp
-
 #include "zypp/base/LogControl.h"
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
 #include "zypp/ZYpp.h"
 #include "zypp/VendorAttr.h"
 
+using boost::unit_test::test_case;
 using namespace std;
 using namespace zypp;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/Vendor")
+
+BOOST_AUTO_TEST_CASE(vendor_test1)
+{
+  setenv("ZYPP_CONF", (DATADIR + "zypp1.conf").c_str(), 1 );
+  // No vendor definition files has been readed. So only suse,opensuse vendors are
+  // equivalent
+  BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") );
+  BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") );
+  BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); 
+  BOOST_REQUIRE( VendorAttr::instance().equivalent("opensuse", "SuSE") );
+  BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") );
+  BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") );
+}
 
-// most frequently you implement test cases as a free functions
-void vendor_test()
+BOOST_AUTO_TEST_CASE(vendor_test2)
 {
+  setenv("ZYPP_CONF", (DATADIR + "zypp2.conf").c_str(), 1 );
   // No vendor definition files has been readed. So only suse,opensuse vendors are
   // equivalent
   BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") );
@@ -43,13 +50,3 @@ void vendor_test()
   BOOST_REQUIRE( VendorAttr::instance().equivalent("ati_new", "ati") );  
 }
 
-test_suite*
-init_unit_test_suite( int, char* [] )
-{
-    setenv("ZYPP_CONF", "./../../tests/zypp/data/Vendor/zypp2.conf", 1 );
-    zypp::base::LogControl::instance().logfile( "-" );    
-    test_suite* test= BOOST_TEST_SUITE( "VendorTest" );
-    test->add( BOOST_TEST_CASE( &vendor_test ), 5 /* expected zero error */ , 0);
-    return test;
-}
-
index 4bc6fb1..22863f6 100644 (file)
@@ -1,7 +1,2 @@
-ADD_DEFINITIONS( -DBOOST_TEST_DYN_LINK )
 
-FOREACH(  loop_var Sysconfig )
-   ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
-   TARGET_LINK_LIBRARIES( ${loop_var}_test  zypp boost_unit_test_framework )
-   ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
-ENDFOREACH( loop_var )
+ADD_TESTS(Sysconfig)
\ No newline at end of file
index 741c2a4..9468523 100644 (file)
@@ -4,29 +4,28 @@
 #include <map>
 #include <string>
 
+#include <boost/test/unit_test.hpp>
+
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
 #include "zypp/TmpPath.h"
 #include "zypp/PathInfo.h"
 
-
-#include <boost/test/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-#include <boost/test/unit_test_log.hpp>
-
 #include "zypp/base/Sysconfig.h"
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
+using namespace boost::unit_test;
 using namespace boost::unit_test::log;
 
 using namespace std;
 using namespace zypp;
 
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/base/data/Sysconfig")
 
-void sysconfig_test( const string &dir )
+BOOST_AUTO_TEST_CASE(Sysconfig)
 {
-  Pathname file = Pathname(dir) + "proxy";
+  Pathname file = DATADIR + "proxy";
   map<string,string> values = zypp::base::sysconfig::read(file);
   BOOST_CHECK_EQUAL( values.size(), 6 );
   BOOST_CHECK_EQUAL( values["PROXY_ENABLED"], "no");
@@ -34,39 +33,3 @@ void sysconfig_test( const string &dir )
   BOOST_CHECK_EQUAL( values["NO_PROXY"], "localhost, 127.0.0.1");
 }
 
-bool
-init_unit_test_suite( int argc, char* argv[] )
-{
-  string datadir;
-  if (argc < 2)
-  {
-    datadir = TESTS_SRC_DIR;
-    datadir = (Pathname(datadir) + "/zypp/base/data/Sysconfig").asString();
-    cout << "sysconfig_test:"
-      " path to directory with test data required as parameter. Using " << datadir  << endl;
-    //return (test_suite *)0;
-  }
-  else
-  {
-    datadir = argv[1];
-  }
-
-  std::string const params[] = { datadir };
-    //set_log_stream( std::cout );
-  test_suite* test= BOOST_TEST_SUITE( "SysconfigTest" );
-  test->add(BOOST_PARAM_TEST_CASE( &sysconfig_test,
-                              (std::string const*)params, params+1));
-  return test;
-}
-
-//bool init_function() {
-//  framework::master_test_suite().add( BOOST_TEST_CASE( boost::bind( &poolquery_simple_test) ) );
-//  return true;
-//}
-
-int
-main( int argc, char* argv[] )
-{
-  return ::boost::unit_test::unit_test_main( &init_unit_test_suite, argc, argv );
-}
-