arch and basearch working
[platform/upstream/libzypp.git] / tests / repo / RepoVariables_test.cc
1 #include <stdio.h>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 #include <list>
6 #include <boost/test/unit_test.hpp>
7 #include <boost/test/parameterized_test.hpp>
8 #include <boost/test/unit_test_log.hpp>
9
10 #include "zypp/ZYppFactory.h"
11 #include "zypp/Url.h"
12 #include "zypp/PathInfo.h"
13 #include "zypp/TmpPath.h"
14 #include "zypp/ZConfig.h"
15 #include "zypp/repo/RepoVariables.h"
16
17 using std::cout;
18 using std::endl;
19 using std::string;
20 using namespace zypp;
21 using namespace boost::unit_test;
22
23 using namespace zypp::repo;
24
25 void replace_test(const string &dir)
26 {
27   RepoVariablesStringReplacer replacer;
28   
29   BOOST_CHECK_EQUAL(replacer("http://foo/$arch/bar"),
30                     "http://foo/"+ ZConfig::instance().systemArchitecture().asString() + "/bar");
31
32   getZYpp()->setArchitecture(Arch("i686"));
33   BOOST_CHECK_EQUAL(replacer("http://foo/$arch/bar/$basearch"),
34                     "http://foo/i686/bar/i386");
35 }
36
37 test_suite*
38 init_unit_test_suite( int argc, char *argv[] )
39 {
40   string datadir;
41   if (argc < 2)
42   {
43     datadir = TESTS_SRC_DIR;
44     datadir = (Pathname(datadir) + "/repo/yum/data").asString();
45     cout << "RepoVariables_test:"
46       " path to directory with test data required as parameter. Using " << datadir  << endl;
47     //return (test_suite *)0;
48     
49   }
50   else
51   {
52     datadir = argv[1];
53   }
54   
55   test_suite* test= BOOST_TEST_SUITE("RepoVariables");
56   
57   std::string const params[] = { datadir };
58   test->add(BOOST_PARAM_TEST_CASE(&replace_test,
59                                  (std::string const*)params, params+1));
60   return test;
61 }
62
63 // vim: set ts=2 sts=2 sw=2 ai et: