|
@@ -1,6 +1,6 @@
|
|
|
// -*- mode: cpp; mode: fold -*-
|
|
// -*- mode: cpp; mode: fold -*-
|
|
|
// Description /*{{{*/
|
|
// 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.
|
|
Version Test - Simple program to run through a file and comare versions.
|
|
@@ -14,13 +14,15 @@
|
|
|
|
|
|
|
|
##################################################################### */
|
|
##################################################################### */
|
|
|
/*}}}*/
|
|
/*}}}*/
|
|
|
-#define APT_COMPATIBILITY 1
|
|
|
|
|
#include <system.h>
|
|
#include <system.h>
|
|
|
#include <apt-pkg/error.h>
|
|
#include <apt-pkg/error.h>
|
|
|
#include <apt-pkg/version.h>
|
|
#include <apt-pkg/version.h>
|
|
|
|
|
+#include <apt-pkg/debversion.h>
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
#include <fstream>
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
+using namespace std;
|
|
|
|
|
+
|
|
|
static int verrevcmp(const char *val, const char *ref)
|
|
static int verrevcmp(const char *val, const char *ref)
|
|
|
{
|
|
{
|
|
|
int vc, rc;
|
|
int vc, rc;
|
|
@@ -132,7 +134,7 @@ static int verrevcmp(const char *val, const char *ref)
|
|
|
|
|
|
|
|
bool RunTest(const char *File)
|
|
bool RunTest(const char *File)
|
|
|
{
|
|
{
|
|
|
- ifstream F(File,ios::in | ios::nocreate);
|
|
|
|
|
|
|
+ ifstream F(File,ios::in);
|
|
|
if (!F != 0)
|
|
if (!F != 0)
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
@@ -173,17 +175,30 @@ bool RunTest(const char *File)
|
|
|
// Result
|
|
// Result
|
|
|
I++;
|
|
I++;
|
|
|
int Expected = atoi(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());
|
|
int Res2 = verrevcmp(A.c_str(),B.c_str());
|
|
|
cout << "'" << A << "' ? '" << B << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
|
|
cout << "'" << A << "' ? '" << B << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
|
|
|
|
|
+
|
|
|
|
|
+ if (Res < 0)
|
|
|
|
|
+ Res = -1;
|
|
|
|
|
+ else if (Res > 0)
|
|
|
|
|
+ Res = 1;
|
|
|
|
|
+
|
|
|
if (Res != Expected)
|
|
if (Res != Expected)
|
|
|
_error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),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
|
|
// Check the reverse as well
|
|
|
Expected = -1*Expected;
|
|
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());
|
|
Res2 = verrevcmp(B.c_str(),A.c_str());
|
|
|
|
|
+
|
|
|
cout << "'" << B << "' ? '" << A << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
|
|
cout << "'" << B << "' ? '" << A << "' = " << Res << " (= " << Expected << ") " << Res2 << endl;
|
|
|
|
|
+
|
|
|
|
|
+ if (Res < 0)
|
|
|
|
|
+ Res = -1;
|
|
|
|
|
+ else if (Res > 0)
|
|
|
|
|
+ Res = 1;
|
|
|
|
|
+
|
|
|
if (Res != Expected)
|
|
if (Res != Expected)
|
|
|
_error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected);
|
|
_error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,A.c_str(),B.c_str(),Res,Expected);
|
|
|
}
|
|
}
|