Parcourir la source

Do not swap required and important in pkgCache::Priority()

required and important were swapped, leading to wrong
output.

Closes: #807523
Thanks: Manuel A. Fernandez Montecelo for discovering this
Julian Andres Klode il y a 10 ans
Parent
commit
2fcd25a9e2
3 fichiers modifiés avec 18 ajouts et 2 suppressions
  1. 1 1
      apt-pkg/orderlist.cc
  2. 1 1
      apt-pkg/pkgcache.cc
  3. 16 0
      test/libapt/priority_test.cc

+ 1 - 1
apt-pkg/orderlist.cc

@@ -328,7 +328,7 @@ int pkgOrderList::Score(PkgIterator Pkg)
 	 break;
 	 break;
       }
       }
 
 
-   // Important Required Standard Optional Extra
+   // Required Important Standard Optional Extra
    if (Cache[Pkg].InstVerIter(Cache)->Priority <= 5)
    if (Cache[Pkg].InstVerIter(Cache)->Priority <= 5)
    {
    {
       signed short PrioMap[] = {0,5,4,3,1,0};
       signed short PrioMap[] = {0,5,4,3,1,0};

+ 1 - 1
apt-pkg/pkgcache.cc

@@ -309,7 +309,7 @@ const char *pkgCache::DepType(unsigned char Type)
 /* */
 /* */
 const char *pkgCache::Priority(unsigned char Prio)
 const char *pkgCache::Priority(unsigned char Prio)
 {
 {
-   const char *Mapping[] = {0,_("important"),_("required"),_("standard"),
+   const char *Mapping[] = {0,_("required"),_("important"),_("standard"),
                             _("optional"),_("extra")};
                             _("optional"),_("extra")};
    if (Prio < _count(Mapping))
    if (Prio < _count(Mapping))
       return Mapping[Prio];
       return Mapping[Prio];

+ 16 - 0
test/libapt/priority_test.cc

@@ -0,0 +1,16 @@
+#include <config.h>
+#include <apt-pkg/pkgcache.h>
+#include <string>
+#include <gtest/gtest.h>
+
+using std::string;
+
+// Tests for Bug#807523
+TEST(PriorityTest, PriorityPrinting)
+{
+   EXPECT_EQ("required", string(pkgCache::Priority(pkgCache::State::Required)));
+   EXPECT_EQ("important", string(pkgCache::Priority(pkgCache::State::Important)));
+   EXPECT_EQ("standard", string(pkgCache::Priority(pkgCache::State::Standard)));
+   EXPECT_EQ("optional", string(pkgCache::Priority(pkgCache::State::Optional)));
+   EXPECT_EQ("extra", string(pkgCache::Priority(pkgCache::State::Extra)));
+}