summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 17:03:13 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 17:03:13 +0000
commit5a8748f187da8fa666e28ee24360ca9842e35b3c (patch)
tree489cb5bd416487af9daae39059b482700fbc30be /test
parent70dd8bf416532654626ac693a145fd275bb8092a (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/conf.cc2
-rw-r--r--test/extract-control.cc2
-rw-r--r--test/rpmver.cc2
-rw-r--r--test/scratch.cc6
-rw-r--r--test/testextract.cc6
-rw-r--r--test/versions.lst6
-rw-r--r--test/versiontest.cc25
7 files changed, 40 insertions, 9 deletions
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 <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
+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 <iostream>
#include <unistd.h>
+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 <apt-pkg/dpkgdb.h>
#include <apt-pkg/debfile.h>
#include <apt-pkg/error.h>
@@ -8,9 +7,12 @@
#include <apt-pkg/init.h>
#include <apt-pkg/fileutl.h>
+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 <apt-pkg/dpkgdb.h>
#include <apt-pkg/debfile.h>
#include <apt-pkg/error.h>
@@ -11,6 +10,8 @@
#include <stdio.h>
#include <stdlib.h>
+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 <system.h>
#include <apt-pkg/error.h>
#include <apt-pkg/version.h>
+#include <apt-pkg/debversion.h>
#include <iostream>
#include <fstream>
+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);
}