From 5a8748f187da8fa666e28ee24360ca9842e35b3c Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 17:03:13 +0000 Subject: * Get self-tests compiling again, updated for latest li... Author: mdz Date: 2003-08-18 15:32:37 GMT * Get self-tests compiling again, updated for latest library API and g++ 3.3 --- test/conf.cc | 2 ++ test/extract-control.cc | 2 ++ test/rpmver.cc | 2 ++ test/scratch.cc | 6 ++++-- test/testextract.cc | 6 ++++-- test/versions.lst | 6 ++++++ test/versiontest.cc | 25 ++++++++++++++++++++----- 7 files changed, 40 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/conf.cc b/test/conf.cc index c44161426..340647b5f 100644 --- a/test/conf.cc +++ b/test/conf.cc @@ -1,6 +1,8 @@ #include #include +using namespace std; + int main(int argc,const char *argv[]) { Configuration Cnf; diff --git a/test/extract-control.cc b/test/extract-control.cc index 125088896..29dcbf371 100644 --- a/test/extract-control.cc +++ b/test/extract-control.cc @@ -4,6 +4,8 @@ #include #include +using namespace std; + bool ExtractMember(const char *File,const char *Member) { FileFd Fd(File,FileFd::ReadOnly); diff --git a/test/rpmver.cc b/test/rpmver.cc index c76c77bd1..9fc807de8 100644 --- a/test/rpmver.cc +++ b/test/rpmver.cc @@ -8,6 +8,8 @@ #define xisalpha(x) isalpha(x) #define xisalnum(x) (isdigit(x) || isalpha(x)) +using namespace std; + int rpmvercmp(const char * a, const char * b) { char oldch1, oldch2; diff --git a/test/scratch.cc b/test/scratch.cc index b52608150..d638c7097 100644 --- a/test/scratch.cc +++ b/test/scratch.cc @@ -1,4 +1,3 @@ -#define APT_COMPATIBILITY 1 #include #include #include @@ -8,9 +7,12 @@ #include #include +using namespace std; + int main(int argc,char *argv[]) { - pkgInitialize(*_config); + pkgInitConfig(*_config); + pkgInitSystem(*_config,_system); // cout << flNoLink(argv[1]) << endl; diff --git a/test/testextract.cc b/test/testextract.cc index 41a197068..1c738aab9 100644 --- a/test/testextract.cc +++ b/test/testextract.cc @@ -1,4 +1,3 @@ -#define APT_COMPATIBILITY 1 #include #include #include @@ -11,6 +10,8 @@ #include #include +using namespace std; + bool Go(int argc,char *argv[]) { // Init the database @@ -83,7 +84,8 @@ bool Go(int argc,char *argv[]) int main(int argc,char *argv[]) { - pkgInitialize(*_config); + pkgInitConfig(*_config); + pkgInitSystem(*_config,_system); _config->Set("Dir::State::status","/tmp/testing/status"); Go(argc,argv); diff --git a/test/versions.lst b/test/versions.lst index da8428449..008a0f2d7 100644 --- a/test/versions.lst +++ b/test/versions.lst @@ -36,3 +36,9 @@ z . -1 0.4a6-2 0.4-1 1 1:3.0.5-2 1:3.0.5.1 -1 + +# #194327 +III-alpha9.8 III-alpha9.8-1.5 -1 + +# #205960 +3.0~rc1-1 3.0-1 -1 diff --git a/test/versiontest.cc b/test/versiontest.cc index 3f90adf05..7ce32e20b 100644 --- a/test/versiontest.cc +++ b/test/versiontest.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: versiontest.cc,v 1.3 2002/03/26 07:38:58 jgg Exp $ +// $Id: versiontest.cc,v 1.4 2003/08/18 15:32:38 mdz Exp $ /* ###################################################################### Version Test - Simple program to run through a file and comare versions. @@ -14,13 +14,15 @@ ##################################################################### */ /*}}}*/ -#define APT_COMPATIBILITY 1 #include #include #include +#include #include #include +using namespace std; + static int verrevcmp(const char *val, const char *ref) { int vc, rc; @@ -132,7 +134,7 @@ static int verrevcmp(const char *val, const char *ref) bool RunTest(const char *File) { - ifstream F(File,ios::in | ios::nocreate); + ifstream F(File,ios::in); if (!F != 0) return false; @@ -173,17 +175,30 @@ bool RunTest(const char *File) // Result I++; int Expected = atoi(I); - int Res = pkgVersionCompare(A.c_str(),B.c_str()); + int Res = debVS.CmpVersion(A.c_str(), B.c_str()); int Res2 = verrevcmp(A.c_str(),B.c_str()); cout << "'" << A << "' ? '" << B << "' = " << Res << " (= " << Expected << ") " << Res2 << endl; + + if (Res < 0) + Res = -1; + else if (Res > 0) + Res = 1; + if (Res != Expected) _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected); // Check the reverse as well Expected = -1*Expected; - Res = pkgVersionCompare(B.c_str(),A.c_str()); + Res = debVS.CmpVersion(B.c_str(), A.c_str()); Res2 = verrevcmp(B.c_str(),A.c_str()); + cout << "'" << B << "' ? '" << A << "' = " << Res << " (= " << Expected << ") " << Res2 << endl; + + if (Res < 0) + Res = -1; + else if (Res > 0) + Res = 1; + if (Res != Expected) _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected); } -- cgit v1.2.3