Debian Codegraph @

tests/sort.rs

raw symbols SCIP
1 mod sortrust-analyzer cargo rust-apt 0.8.0 sort/ {
2 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::cacherust-analyzer cargo rust-apt 0.8.0 cache/::*;
3 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!;
4
5 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
6 fn defaultsrust-analyzer cargo rust-apt 0.8.0 sort/defaults().() {
7 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
8 let mut installed = false;
9 let mut auto_installed = false;
10
11 // Test defaults and ensure there are no virtual packages.
12 // And that we have any packages at all.
13 let mut real_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
14 let mut virtual_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
15
16 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().();
17
18 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
19 if pkg.is_auto_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_auto_installed().() {
20 auto_installed = true;
21 }
22 if pkg.is_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_installed().() {
23 installed = true;
24 }
25
26 if pkg.has_versionsrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]has_versions().() {
27 real_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
28 continue;
29 }
30 virtual_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
31 }
32 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().real_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
33 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(virtual_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
34 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(auto_installed);
35 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(installed)
36 }
37
38 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
39 fn include_virtualrust-analyzer cargo rust-apt 0.8.0 sort/include_virtual().() {
40 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
41
42 // Check that we have virtual and real packages after sorting.
43 let mut real_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
44 let mut virtual_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
45
46 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().include_virtualrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]include_virtual().().namesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]names().();
47
48 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
49 if pkg.has_versionsrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]has_versions().() {
50 real_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
51 continue;
52 }
53 virtual_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
54 }
55 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().real_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
56 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().virtual_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
57 }
58
59 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
60 fn only_virtualrust-analyzer cargo rust-apt 0.8.0 sort/only_virtual().() {
61 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
62
63 // Check that we have only virtual packages.
64 let mut real_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
65 let mut virtual_pkgs = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
66
67 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().only_virtualrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]only_virtual().();
68
69 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
70 if pkg.has_versionsrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]has_versions().() {
71 real_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
72 continue;
73 }
74 virtual_pkgs.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
75 }
76 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(real_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
77 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().virtual_pkgs.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
78 }
79
80 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
81 fn upgradablerust-analyzer cargo rust-apt 0.8.0 sort/upgradable().() {
82 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
83
84 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().upgradablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]upgradable().();
85 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
86 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pkg.is_upgradablerust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_upgradable().())
87 }
88
89 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().not_upgradablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_upgradable().();
90 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
91 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.is_upgradablerust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_upgradable().())
92 }
93 }
94
95 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
96 fn installedrust-analyzer cargo rust-apt 0.8.0 sort/installed().() {
97 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
98
99 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]installed().();
100 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
101 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pkg.is_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_installed().())
102 }
103
104 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().not_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_installed().();
105 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
106 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.is_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_installed().())
107 }
108 }
109
110 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
111 fn auto_installedrust-analyzer cargo rust-apt 0.8.0 sort/auto_installed().() {
112 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
113
114 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]auto_installed().();
115 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
116 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().());
117 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pkg.is_auto_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_auto_installed().())
118 }
119
120 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().manually_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]manually_installed().();
121 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
122 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.is_auto_installedrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_auto_installed().());
123 }
124 }
125
126 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
127 fn auto_removablerust-analyzer cargo rust-apt 0.8.0 sort/auto_removable().() {
128 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
129
130 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]auto_removable().();
131 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
132 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pkg.is_auto_removablerust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_auto_removable().())
133 }
134
135 let sort = PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#::defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().().not_auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_auto_removable().();
136 for pkg in cache.packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&sort) {
137 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.is_auto_removablerust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]is_auto_removable().())
138 }
139 }
140 }