X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/8c515d6281328e490673b8dc94a7d69987d5a027..fe58cbc86638e214fa137166a704fbff798c546a:/test/versiontest.cc diff --git a/test/versiontest.cc b/test/versiontest.cc index d3bfe18fe..5438eb4de 100644 --- a/test/versiontest.cc +++ b/test/versiontest.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: versiontest.cc,v 1.1 1998/11/26 23:29:20 jgg Exp $ +// $Id: versiontest.cc,v 1.5 2003/08/18 15:55:19 mdz Exp $ /* ###################################################################### Version Test - Simple program to run through a file and comare versions. @@ -17,10 +17,13 @@ #include #include #include -#include -#include +#include +#include +#include -static int verrevcmp(const char *val, const char *ref) +using namespace std; + + static int verrevcmp(const char *val, const char *ref) { int vc, rc; long vl, rl; @@ -131,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; @@ -172,19 +175,32 @@ 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); + _error->Error("Comparison failed on line %u. '%s' ? '%s' %i != %i",CurLine,B.c_str(),A.c_str(),Res,Expected); } }