]> git.saurik.com Git - apt.git/commitdiff
Do not swap required and important in pkgCache::Priority()
authorJulian Andres Klode <jak@debian.org>
Thu, 10 Dec 2015 08:48:21 +0000 (09:48 +0100)
committerJulian Andres Klode <jak@debian.org>
Thu, 10 Dec 2015 09:02:21 +0000 (10:02 +0100)
required and important were swapped, leading to wrong
output.

Closes: #807523
Thanks: Manuel A. Fernandez Montecelo for discovering this

apt-pkg/orderlist.cc
apt-pkg/pkgcache.cc
test/libapt/priority_test.cc [new file with mode: 0644]

index a61c2b06aa4d02472e381fd13bda546b92453e5f..bfdc50e6cc2265bfebca0e3f07f6d8c3ce9dc4c2 100644 (file)
@@ -328,7 +328,7 @@ int pkgOrderList::Score(PkgIterator Pkg)
         break;
       }
 
-   // Important Required Standard Optional Extra
+   // Required Important Standard Optional Extra
    if (Cache[Pkg].InstVerIter(Cache)->Priority <= 5)
    {
       signed short PrioMap[] = {0,5,4,3,1,0};
index 0750a20806064daf75a1d4b166f5fbeedaf31fb9..2196da03c233d8fd8a163793c60475a8b519780f 100644 (file)
@@ -309,7 +309,7 @@ const char *pkgCache::DepType(unsigned char Type)
 /* */
 const char *pkgCache::Priority(unsigned char Prio)
 {
-   const char *Mapping[] = {0,_("important"),_("required"),_("standard"),
+   const char *Mapping[] = {0,_("required"),_("important"),_("standard"),
                             _("optional"),_("extra")};
    if (Prio < _count(Mapping))
       return Mapping[Prio];
diff --git a/test/libapt/priority_test.cc b/test/libapt/priority_test.cc
new file mode 100644 (file)
index 0000000..ef1941c
--- /dev/null
@@ -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)));
+}