summaryrefslogtreecommitdiff
path: root/test/libapt/cachefilter_test.cc
blob: 28924b758ae851ad90a26f46934a9c2ad6513047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <config.h>

#include <apt-pkg/cachefilter.h>

#include <string>

#include <gtest/gtest.h>

TEST(CacheFilterTest, ArchitectureSpecification)
{
   {
      SCOPED_TRACE("Pattern is any-armhf");
      APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-armhf");
      EXPECT_TRUE(ams("armhf"));
      EXPECT_FALSE(ams("armel"));
      EXPECT_TRUE(ams("linux-armhf"));
      EXPECT_FALSE(ams("linux-armel"));
      EXPECT_TRUE(ams("kfreebsd-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armhf"));
      EXPECT_FALSE(ams("gnu-linux-armel"));
      EXPECT_TRUE(ams("gnu-kfreebsd-armhf"));
      EXPECT_TRUE(ams("musl-linux-armhf"));
   }
   {
      SCOPED_TRACE("Pattern is linux-any");
      APT::CacheFilter::PackageArchitectureMatchesSpecification ams("linux-any");
      EXPECT_TRUE(ams("armhf"));
      EXPECT_TRUE(ams("armel"));
      EXPECT_TRUE(ams("linux-armhf"));
      EXPECT_TRUE(ams("linux-armel"));
      EXPECT_FALSE(ams("kfreebsd-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armel"));
      EXPECT_FALSE(ams("gnu-kfreebsd-armhf"));
      EXPECT_TRUE(ams("musl-linux-armhf"));
   }
   {
      SCOPED_TRACE("Pattern is gnu-any-any");
      APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnu-any-any"); //really?
      EXPECT_TRUE(ams("armhf"));
      EXPECT_TRUE(ams("armel"));
      EXPECT_TRUE(ams("linux-armhf"));
      EXPECT_TRUE(ams("linux-armel"));
      EXPECT_TRUE(ams("kfreebsd-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armel"));
      EXPECT_TRUE(ams("gnu-kfreebsd-armhf"));
      EXPECT_FALSE(ams("musl-linux-armhf"));
   }
   {
      SCOPED_TRACE("Architecture is armhf");
      APT::CacheFilter::PackageArchitectureMatchesSpecification ams("armhf", false);
      EXPECT_TRUE(ams("armhf"));
      EXPECT_FALSE(ams("armel"));
      EXPECT_TRUE(ams("linux-any"));
      EXPECT_FALSE(ams("kfreebsd-any"));
      EXPECT_TRUE(ams("any-armhf"));
      EXPECT_FALSE(ams("any-armel"));
      EXPECT_TRUE(ams("linux-armhf"));
      EXPECT_FALSE(ams("kfreebsd-armhf"));
      EXPECT_TRUE(ams("gnu-linux-armhf"));
      EXPECT_FALSE(ams("gnu-linux-armel"));
      EXPECT_FALSE(ams("gnu-kfreebsd-armhf"));
      EXPECT_FALSE(ams("musl-linux-armhf"));
   }
}