Debian Codegraph @

src/widgets/process_table/query.rs

raw symbols SCIP
1 //! How we query processes.
2 //!
3 //! Yes, this is a hand-rolled parser. I originally wrote this back in uni where
4 //! writing a parser was basically a thing I did every year, and parsing crate
5 //! options were not as good as they are now. This will be rewritten as time
6 //! goes on, though.
7
8 mod andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/;
9 mod attributerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/attribute/;
10 mod errorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/;
11 mod orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/;
12 mod prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/;
13
14 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#, timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#};
15
16 use andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/::Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#;
17 use attributerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/attribute/::ProcessAttributerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/attribute/ProcessAttribute#;
18 use errorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/::{QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#, QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#};
19 use orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/::Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#;
20 use prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/::Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#;
21 use regexrust-analyzer cargo regex 1.13.1 crate/::Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#;
22
23 use craterust-analyzer cargo bottom 0.14.9 crate/::{collectionrust-analyzer cargo bottom 0.14.9 collection/::processesrust-analyzer cargo bottom 0.14.9 collection/processes/::ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#, multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!};
24
25 const DELIMITER_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/DELIMITER_LIST.: [char; 7] = ['=', '>', '<', '!', '(', ')', '\"'];
26 const COMPARISON_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/COMPARISON_LIST.: [&str; 4] = [">", "=", "<", "!="];
27
28 /// A node type that can take a query and read it, advancing the current read
29 /// state and returning an instance of the node.
30 trait QueryProcessorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor# {
31 fn processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor#process().(query: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, regex_options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<Self>
32 where
33 Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#;
34 }
35
36 /// Process a new regex given a `base` string and some settings.
37 ///
38 /// TODO: Push this into a struct so I don't have to throw the options around so
39 /// much.
40 fn new_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/new_regex().(base: &str, regex_options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#> {
41 let QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
42 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: is_searching_whole_word,
43 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: is_ignoring_case,
44 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: is_searching_with_regex,
45 } = regex_options;
46 let escaped_regex: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; // Needed for ownership reasons.
47
48 let final_regex_string = &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
49 "{}{}{}{}",
50 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_searching_whole_word { "^" } else { "" },
51 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_ignoring_case { "(?i)" } else { "" },
52 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_searching_with_regex) {
53 escaped_regex = regexrust-analyzer cargo regex 1.13.1 crate/::escaperust-analyzer cargo regex 1.13.1 escape().(base);
54 &escaped_regex
55 } else {
56 base
57 },
58 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_searching_whole_word { "$" } else { "" },
59 );
60
61 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#::newrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]new().(final_regex_string)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
62 }
63
64 /// Options when creating a new query.
65 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
66 pub struct QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
67 /// Whether we only allow matches on the entire word.
68 pub whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: bool,
69
70 /// Whether to ignore case-sensitivity when searching. On by default.
71 pub ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: bool,
72
73 /// Whether we should use regex syntax when searching. If not set, then it
74 /// should treat everything as a literal string.
75 pub use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: bool,
76 }
77
78 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
79 fn defaultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[QueryOptions][Default]default().() -> Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[QueryOptions][Default] {
80 Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[QueryOptions][Default] {
81 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: true,
82 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: false,
83 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: false,
84 }
85 }
86 }
87
88 /// In charge of parsing the given query, case-insensitive, possibly marked
89 /// by a prefix. For example:
90 ///
91 /// - Process names: No prefix required, can use regex, match word, or case.
92 /// Enclosing anything, including prefixes, in quotes, means we treat it as an
93 /// entire process rather than a prefix.
94 /// - PIDs: Use prefix `pid`, can use regex or match word.
95 /// - CPU: Use prefix `cpu`.
96 /// - MEM: Use prefix `mem`.
97 /// - STATE: Use prefix `state`.
98 /// - USER: Use prefix `user`.
99 /// - Read/s: Use prefix `r`.
100 /// - Write/s: Use prefix `w`.
101 /// - Total read: Use prefix `read`.
102 /// - Total write: Use prefix `write`.
103 ///
104 /// For queries, whitespaces are our delimiters. We will merge together any
105 /// adjacent non-prefixed or quoted elements after splitting to treat as process
106 /// names. Furthermore, we want to support boolean joiners like AND and OR, and
107 /// brackets.
108 pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(search_query: &str, options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#> {
109 fn process_string_to_filterrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/process_string_to_filter().(
110 query: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#,
111 ) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#> {
112 let lhs = Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
113 let mut list_of_ors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![lhs];
114
115 while query.frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
116 list_of_ors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
117 }
118
119 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery# { queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#query.: list_of_ors })
120 }
121
122 let mut split_query = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]new().();
123 let mut in_quotes = false;
124
125 search_query.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().().for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(|s| {
126 // From https://stackoverflow.com/a/56923739 get a split but include the parentheses
127 let mut last = 0;
128 for (index, matched) in s.match_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]match_indices().(|x| DELIMITER_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/DELIMITER_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&x)) {
129 if matched rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."\"" {
130 // Always split on quote delimiters to open/close quoted sections.
131 if last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().index {
132 split_query.push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().last..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
133 }
134 split_query.push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(matched.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
135 last = index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().matched.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
136 in_quotes = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_quotes;
137 } else if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_quotes {
138 // Only split on other delimiters when outside a quoted section,
139 // so that special chars like `<` and `>` in `"Thread<15>"` are
140 // preserved as literals.
141 if last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().index {
142 split_query.push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().last..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
143 }
144 split_query.push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(matched.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
145 last = index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().matched.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
146 }
147 }
148 if last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
149 split_query.push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().last..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
150 }
151 });
152
153 // Merge adjacent "!" and "=" tokens into a single "!=" token.
154 let mut i = 0;
155 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().split_query.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]len().() {
156 if split_query[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."!" && split_query[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."=" {
157 split_query[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut(). = "!=".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
158 split_query.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]remove().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1);
159 }
160 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
161 }
162
163 process_string_to_filterrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/process_string_to_filter().(&mut split_query, options)
164 }
165
166 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
167 pub struct ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery# {
168 /// Remember, AND > OR, but AND must come after OR when we parse.
169 queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#query.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#>,
170 }
171
172 impl ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery# {
173 pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&self, process: &ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#, is_using_command: bool) -> bool {
174 self.queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#query.
175 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
176 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|ok| ok.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/impl#[Or]check().(process, is_using_command))
177 }
178 }
179
180 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
181 enum PrefixTyperust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType# {
182 Pidrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Pid#,
183 CpuPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#CpuPercentage#,
184 MemBytesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#MemBytes#,
185 MemPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#MemPercentage#,
186 ReadPerSecondrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#ReadPerSecond#,
187 WritePerSecondrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#WritePerSecond#,
188 TotalReadrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#TotalRead#,
189 TotalWriterust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#TotalWrite#,
190 Namerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Name#,
191 Staterust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#State#,
192 Userrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#User#,
193 Timerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Time#,
194 #[cfg(unix)]
195 Nicerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Nice#,
196 Priorityrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Priority#,
197 #[cfg(feature = "gpu")]
198 GpuPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuPercentage#,
199 #[cfg(feature = "gpu")]
200 GpuMemoryBytesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuMemoryBytes#,
201 #[cfg(feature = "gpu")]
202 GpuMemoryPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuMemoryPercentage#,
203 }
204
205 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PrefixTyperust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType# {
206 type Errrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[PrefixType][FromStr]Err# = QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#;
207
208 fn from_strrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[PrefixType][FromStr]from_str().(s: &str) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[PrefixType][FromStr]> {
209 use PrefixTyperust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#::*;
210
211 // TODO: Didn't add mem_bytes, total_read, and total_write
212 // for now as it causes help to be clogged.
213
214 // TODO: Add a `name` keyword alias so something like `name = blah` is valid.
215
216 let mut result = Namerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Name#;
217 if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "cpu" | "cpu%") {
218 result = CpuPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#CpuPercentage#;
219 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "mem" | "mem%") {
220 result = MemPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#MemPercentage#;
221 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "memb") {
222 result = MemBytesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#MemBytes#;
223 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "read" | "r/s" | "rps") {
224 result = ReadPerSecondrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#ReadPerSecond#;
225 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "write" | "w/s" | "wps") {
226 result = WritePerSecondrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#WritePerSecond#;
227 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "tread" | "t.read") {
228 result = TotalReadrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#TotalRead#;
229 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "twrite" | "t.write") {
230 result = TotalWriterust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#TotalWrite#;
231 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "pid") {
232 result = Pidrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Pid#;
233 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "state") {
234 result = Staterust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#State#;
235 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "user") {
236 result = Userrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#User#;
237 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "time") {
238 result = Timerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Time#;
239 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "nice") {
240 #[cfg(unix)]
241 {
242 result = Nicerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Nice#;
243 }
244 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "priority") {
245 result = Priorityrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#Priority#;
246 }
247 #[cfg(feature = "gpu")]
248 {
249 if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "gmem") {
250 result = GpuMemoryBytesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuMemoryBytes#;
251 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "gmem%") {
252 result = GpuMemoryPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuMemoryPercentage#;
253 } else if multi_eq_ignore_ascii_caserust-analyzer cargo bottom 0.14.9 utils/strings/multi_eq_ignore_ascii_case!!(s, "gpu%") {
254 result = GpuPercentagerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/PrefixType#GpuPercentage#;
255 }
256 }
257 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result)
258 }
259 }
260
261 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
262 enum QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison# {
263 Equalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Equal#,
264 NotEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#NotEqual#,
265 Lessrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Less#,
266 Greaterrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Greater#,
267 LessOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#LessOrEqual#,
268 GreaterOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#GreaterOrEqual#,
269 }
270
271 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
272 struct NumericalQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery# {
273 conditionrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery#condition.: QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#,
274 valuerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery#value.: f64,
275 }
276
277 impl NumericalQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery# {
278 /// Compare `lhs` to the value in the query as `rhs`.
279 fn checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[NumericalQuery]check().<I: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64>>(&self, lhs: I) -> bool {
280 let lhs: f64 = lhs.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
281 let rhs: f64 = self.valuerust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery#value.;
282
283 match self.conditionrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/NumericalQuery#condition. {
284 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Equalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Equal# => (lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().rhs).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().f64::EPSILONrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]EPSILON.,
285 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::NotEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#NotEqual# => (lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().rhs).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().f64::EPSILONrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]EPSILON.,
286 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Lessrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Less# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().rhs,
287 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Greaterrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Greater# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().rhs,
288 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::LessOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#LessOrEqual# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]le().rhs,
289 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::GreaterOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#GreaterOrEqual# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().rhs,
290 }
291 }
292 }
293
294 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
295 struct TimeQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery# {
296 conditionrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery#condition.: QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#,
297 durationrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery#duration.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#,
298 }
299
300 impl TimeQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery# {
301 /// Compare `lhs` to the value in the query as `rhs`.
302 fn checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[TimeQuery]check().(&self, lhs: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) -> bool {
303 let rhs = self.durationrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery#duration.;
304
305 match self.conditionrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/TimeQuery#condition. {
306 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Equalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Equal# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`PartialEq<Self>`]eq().rhs,
307 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::NotEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#NotEqual# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().rhs,
308 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Lessrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Less# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().rhs,
309 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::Greaterrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#Greater# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().rhs,
310 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::LessOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#LessOrEqual# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().rhs,
311 QueryComparisonrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#::GreaterOrEqualrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryComparison#GreaterOrEqual# => lhs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().rhs,
312 }
313 }
314 }
315
316 #[cfg(test)]
317 mod testsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/ {
318 use superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/::*;
319
320 fn simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().(name: &str) -> ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest# {
321 ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest# {
322 namerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
323 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 collection/processes/impl#[ProcessHarvest][Default]default().()
324 }
325 }
326
327 fn parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(query: &str) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<ProcessQueryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/ProcessQuery#> {
328 parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(
329 query,
330 &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
331 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: false,
332 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: false,
333 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: false,
334 },
335 )
336 }
337
338 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
339 fn basic_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/basic_query().() {
340 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("test").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
341
342 let exact_match = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
343 let contains = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test string");
344 let invalid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("no");
345
346 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&exact_match, false));
347 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&contains, false));
348 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&invalid, false));
349 }
350
351 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
352 fn basic_or_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/basic_or_query().() {
353 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a or b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
354
355 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
356 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
357 let invalid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
358
359 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
360 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
361 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&invalid, false));
362 }
363
364 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
365 fn basic_and_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/basic_and_query().() {
366 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a and b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
367
368 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
369 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
370 let c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
371 let a_and_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a and b");
372
373 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
374 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
375 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
376 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_and_b, false));
377 }
378
379 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
380 fn implied_and_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/implied_and_query().() {
381 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a b c").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
382
383 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
384 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
385 let c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
386 let all = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a b c");
387
388 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
389 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
390 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
391 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&all, false));
392 }
393
394 /// Ensure that quoted keywords are treated as strings. In this case, rather
395 /// than `"a" OR "b"`, it should be treated as the string `"a or b"`.
396 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
397 fn quoted_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_query().() {
398 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a \"or\" b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
399
400 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
401 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
402 let or = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("or");
403 let valid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a \"or\" b"); // This is valid as the query is "match a word with a, or, and b".
404 let valid_2 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a or b");
405 let valid_3 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a \"or\" b \"or\" c");
406
407 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
408 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
409 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&or, false));
410 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&valid, false));
411 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&valid_2, false));
412 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&valid_3, false));
413 }
414
415 /// Ensure that multi-word quoted keywords are treated as strings. In this
416 /// case, rather than `"a" OR "b"`, it should be treated as the string
417 /// `"a or b"`.
418 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
419 fn quoted_multi_word_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_multi_word_query().() {
420 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"a or b\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
421
422 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
423 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
424 let or = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("or");
425 let valid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a or b");
426 let valid_2 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a or b \"or\" c");
427 let invalid_no_regex = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a \"or\" b"); // Invalid now as the query is one big string!
428
429 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
430 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
431 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&or, false));
432 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&valid, false));
433 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&valid_2, false));
434 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&invalid_no_regex, false));
435 }
436
437 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
438 fn basic_cpu_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/basic_cpu_query().() {
439 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu > 50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
440
441 let mut over = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
442 over.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 60.0;
443
444 let mut under = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
445 under.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 40.0;
446
447 let mut exact = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
448 exact.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
449
450 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&over, false));
451 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&under, false));
452 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&exact, false));
453 }
454
455 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
456 fn basic_mem_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/basic_mem_query().() {
457 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("memb > 1 GiB").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
458
459 let mut over = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
460 over.mem_usagerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#mem_usage. = 2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024;
461
462 let mut under = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
463 under.mem_usagerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#mem_usage. = 0;
464
465 let mut exact = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
466 exact.mem_usagerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#mem_usage. = 1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024;
467
468 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&over, false));
469 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&under, false));
470 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&exact, false));
471 }
472
473 /// This test sees if parentheses work.
474 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
475 fn nested_query_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/nested_query_1().() {
476 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("(a or b) and (c or a)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
477
478 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
479 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
480 let c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
481 let d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("d");
482
483 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
484 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
485 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
486 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&d, false));
487 }
488
489 /// This test sees if parentheses and mixed query types work.
490 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
491 fn nested_query_2rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/nested_query_2().() {
492 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("(cpu > 10 or cpu < 5) and (c or a)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
493
494 let mut a_valid_1 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
495 a_valid_1.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 100.0;
496
497 let mut a_valid_2 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
498 a_valid_2.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 1.0;
499
500 let mut a_invalid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
501 a_invalid.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 6.0;
502
503 let mut c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
504 c.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
505
506 let mut b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
507 b.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
508
509 let mut d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("d");
510 d.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 6.0;
511
512 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_valid_1, false));
513 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_valid_2, false));
514 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
515
516 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_invalid, false));
517 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
518 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&d, false));
519 }
520
521 /// This test adds a further layer of nesting to consider.
522 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
523 fn nested_query_3rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/nested_query_3().() {
524 let query =
525 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("((cpu > 10 or cpu < 5) or d) and ((c or a) or d)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
526
527 let mut a_valid_1 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
528 a_valid_1.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 100.0;
529
530 let mut a_valid_2 = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
531 a_valid_2.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 1.0;
532
533 let mut a_invalid = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
534 a_invalid.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 6.0;
535
536 let mut c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
537 c.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
538
539 let mut b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
540 b.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
541
542 let mut d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("d");
543 d.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 6.0;
544
545 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_valid_1, false));
546 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_valid_2, false));
547 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
548 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&d, false));
549
550 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a_invalid, false));
551 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
552 }
553
554 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
555 fn ambiguous_precedence_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/ambiguous_precedence_1().() {
556 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a and b or c").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
557
558 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
559 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
560 let c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
561
562 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
563 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
564 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
565 }
566
567 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
568 fn ambiguous_precedence_2rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/ambiguous_precedence_2().() {
569 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a or b and c").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
570
571 let a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
572 let b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
573 let c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
574
575 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&a, false));
576 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&b, false));
577 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&c, false));
578 }
579
580 /// Test if a complicated query even parses.
581 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
582 fn parse_complicated_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_complicated_query().() {
583 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(
584 "cpu > 10.5 AND (memb = 1 MiB || state = sleeping) and (a or b) and (read >= 0 or write >= 0)",
585
586 )
587 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
588 }
589
590 /// Test empty quotes works.
591 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
592 fn parse_empty_quotesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_empty_quotes().() {
593 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
594 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"\"\"\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
595 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"\" OR \"\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
596 }
597
598 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
599 fn search_empty_quotesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/search_empty_quotes().() {
600 let a = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
601 let b = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"\" OR test").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
602
603 let process = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
604
605 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(a.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process, false));
606 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(b.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process, false));
607 }
608
609 /// Test unfinished quotes error.
610 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
611 fn parse_unfinished_quotesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_unfinished_quotes().() {
612 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
613 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"asdf").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
614 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("asdf\"").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
615 }
616
617 /// Test a fix for a bug with closing quotations. The problem seems to arise
618 /// from quotes being used as an argument to a prefix... but this should
619 /// probably be valid.
620 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
621 fn parse_nested_closing_quotesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_nested_closing_quotes().() {
622 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state = \"test\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
623 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state = \"2 words\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
624 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("(memb = 1 MiB || state = \"test\")").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
625 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("(memb = 1 MiB || state = \"2 words\")").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
626 }
627
628 // TODO: Add this after fixed.
629 // /// Test if units can ignore spaces from their preceding value.
630 // #[test]
631 // fn units_with_and_without_spaces() {}
632
633 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
634 fn invalid_uncompleted_queries_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_uncompleted_queries_1().() {
635 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state =").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
636 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a or").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
637 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("a >").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
638 }
639
640 #[track_caller]
641 fn invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().(op: &str) {
642 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("a {op} asdf = 100")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
643 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("asdf = 100 {op} b")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
644 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("a {op} asdf = 100 {op} b")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
645
646 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("asdf = 100 {op} bsdf = \"")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
647 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("a {op} bsdf = \"")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
648 }
649
650 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
651 fn invalid_orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_or().() {
652 invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().("OR");
653 invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().("||");
654 }
655
656 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
657 fn invalid_andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_and().() {
658 invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().("AND");
659 invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().("&&");
660 invalid_lhs_rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/invalid_lhs_rhs().("");
661 }
662
663 // /// Test keywords.
664 // ///
665 // /// TODO: Should these be invalid...?
666 // #[test]
667 // fn invalid_query_x() {
668 // parse_query_no_options("or").unwrap_err();
669 // parse_query_no_options("and").unwrap_err();
670 // parse_query_no_options("a or >").unwrap_err();
671 // parse_query_no_options("a and >").unwrap_err();
672 // }
673
674 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
675 fn test_command_checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_command_check().() {
676 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("command").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
677
678 let mut process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
679 process_a.commandrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#command. = "command".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
680
681 let mut process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
682 process_b.commandrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#command. = "no".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
683
684 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, true));
685 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, true));
686 }
687
688 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
689 fn test_non_ascii_only_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_non_ascii_only_1().() {
690 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("食").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
691
692 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("施氏食獅史");
693 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("沒有");
694
695 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
696 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
697 }
698
699 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
700 fn test_non_ascii_only_2rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_non_ascii_only_2().() {
701 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("परीक्षा").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
702
703 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("परीक्षा");
704 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("उपलब्ध नहीं है");
705
706 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
707 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
708 }
709
710 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
711 fn test_non_ascii_only_3rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_non_ascii_only_3().() {
712 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("🇨🇦").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
713
714 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("🇨🇦");
715 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("❤️🇨🇦❤️");
716 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("❤️");
717
718 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
719 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
720 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
721 }
722
723 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
724 fn test_non_ascii_only_4rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_non_ascii_only_4().() {
725 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("獅 or 狮").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
726
727 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("施氏食獅史");
728 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("施氏食狮史");
729 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("沒有");
730
731 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
732 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
733 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
734 }
735
736 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
737 fn test_invalid_non_asciirust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_invalid_non_ascii().() {
738 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu = 食").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
739 }
740
741 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
742 fn test_mixed_unicoderust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_mixed_unicode().() {
743 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("食 or test").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
744
745 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("施氏食獅史");
746 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
747 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("施氏食獅史test");
748 let process_d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("沒有");
749 let process_e = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("nope");
750
751 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
752 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
753 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
754 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_d, false));
755 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_e, false));
756 }
757
758 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
759 fn test_regex_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_regex_1().() {
760 let query = parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(
761 "(a|b)",
762 &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
763 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: false,
764 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: true,
765 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: true,
766 },
767 )
768 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
769
770 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("abc");
771 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
772
773 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
774 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
775 }
776
777 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
778 fn test_regex_2rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_regex_2().() {
779 let query = parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(
780 "^a.*z$",
781 &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
782 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: false,
783 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: true,
784 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: true,
785 },
786 )
787 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
788
789 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("atoz");
790 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("atob");
791 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("ytoz");
792 let process_d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("atozoops");
793
794 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
795 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
796 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
797 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_d, false));
798 }
799
800 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
801 fn test_whole_word_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_whole_word_1().() {
802 let query = parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(
803 "test",
804 &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
805 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: true,
806 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: true,
807 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: false,
808 },
809 )
810 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
811
812 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
813 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("testa");
814 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("atest");
815
816 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
817 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
818 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
819 }
820
821 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
822 fn test_case_sensitive_1rust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_case_sensitive_1().() {
823 let query = parse_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/parse_query().(
824 "tEsT",
825 &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions# {
826 whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word.: false,
827 ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case.: false,
828 use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex.: false,
829 },
830 )
831 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
832
833 let process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("tEsT");
834 let process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("tEsT a");
835 let process_c = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a tEsT");
836
837 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
838 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
839 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_c, false));
840
841 let process_d = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
842 let process_e = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test a");
843 let process_f = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a test");
844
845 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_d, false));
846 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_e, false));
847 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_f, false));
848 }
849
850 #[cfg(feature = "gpu")]
851 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
852 fn test_gpu_queriesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_gpu_queries().() {
853 let mem = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gmem > 50 b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
854 let mem_percent = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gmem% = 50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
855 let use_percent = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gpu% = 50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
856
857 let mut process_a = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
858 process_a.gpu_memrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_mem. = 100;
859 process_a.gpu_mem_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_mem_percent. = 50.0;
860 process_a.gpu_utilrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_util. = 50;
861
862 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mem.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
863 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mem_percent.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
864 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(use_percent.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_a, false));
865
866 let mut process_b = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("test");
867 process_b.gpu_memrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_mem. = 0;
868 process_b.gpu_mem_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_mem_percent. = 10.0;
869 process_b.gpu_utilrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#gpu_util. = 10;
870
871 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().mem.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
872 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().mem_percent.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
873 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().use_percent.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&process_b, false));
874 }
875
876 /// Test GPU queries that involve invalid string comparisons.
877 #[cfg(feature = "gpu")]
878 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
879 fn test_invalid_gpu_queriesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/test_invalid_gpu_queries().() {
880 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gmem = \"what\"").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
881 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gmem% = \"the\"").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
882 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("gpu% = \"heck\"").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
883 }
884
885 // TODO: Test all attribute keywords (e.g. cpu, mem, etc.)
886 // #[test]
887 // fn test_all_attribute_keywords() {}
888
889 // TODO: Support 'bytes' or similar
890 // #[test]
891 // fn test_bytes_keyword() {
892 // let mem = parse_query_no_options("mem > 50 bytes").unwrap();
893 // let mut process_a = simple_process("test");
894 // process_a.mem_usage = 100;
895
896 // assert!(mem.check(&process_a, false));
897 // }
898
899 /// Basic numerical non-equality operator test.
900 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
901 fn numerical_not_equal_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/numerical_not_equal_query().() {
902 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu != 50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
903
904 let mut equal = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
905 equal.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 50.0;
906
907 let mut other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
908 other.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 40.0;
909
910 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&equal, false));
911 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
912 }
913
914 /// `!=` should tokenize the same whether written as `foo!=bar` or
915 /// `foo != bar`.
916 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
917 fn not_equal_tokenizes_without_spacesrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/not_equal_tokenizes_without_spaces().() {
918 let spaced = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu != 50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
919 let joined = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu!=50").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
920
921 let mut proc = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
922 proc.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 40.0;
923
924 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(spaced.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&proc, false));
925 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(joined.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&proc, false));
926 }
927
928 /// Test the non-equality operator with time.
929 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
930 fn time_not_equal_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/time_not_equal_query().() {
931 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("time != 1h").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
932
933 let mut equal = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
934 equal.timerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#time. = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(3600);
935
936 let mut other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
937 other.timerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#time. = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(60);
938
939 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&equal, false));
940 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
941 }
942
943 /// Test state queries with the non-equality operator. This also tests that string comparisons.
944 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
945 fn state_not_equal_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/state_not_equal_query().() {
946 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state != sleeping").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
947
948 let mut sleeping = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
949 sleeping.process_staterust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#process_state..0 = "sleeping";
950
951 let mut running = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
952 running.process_staterust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#process_state..0 = "running";
953
954 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&sleeping, false));
955 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&running, false));
956 }
957
958 /// Test byte unit searches work with the non-equality operator.
959 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
960 fn mem_bytes_not_equal_with_unitrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/mem_bytes_not_equal_with_unit().() {
961 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("memb != 1 GiB").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
962
963 let mut equal = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
964 equal.mem_usagerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#mem_usage. = 1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().1024;
965
966 let mut other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
967 other.mem_usagerust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#mem_usage. = 0;
968
969 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&equal, false));
970 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
971 }
972
973 /// `!(...)` negates a whole group.
974 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
975 fn negate_group_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/negate_group_query().() {
976 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!(cpu > 5 or a)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
977
978 let mut high_cpu = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
979 high_cpu.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 10.0;
980
981 let name_match = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
982
983 let mut low_cpu_no_match = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("b");
984 low_cpu_no_match.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 1.0;
985
986 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&high_cpu, false));
987 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&name_match, false));
988 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&low_cpu_no_match, false));
989 }
990
991 /// `!name` negates a bare-name match.
992 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
993 fn negate_bare_name_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/negate_bare_name_query().() {
994 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!firefox").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
995
996 let firefox = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("firefox");
997 let other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("btm");
998
999 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&firefox, false));
1000 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
1001 }
1002
1003 /// `!"..."` negates a quoted-name match.
1004 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1005 fn negate_quoted_name_queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/negate_quoted_name_query().() {
1006 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!\"a or b\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1007
1008 let exact = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a or b");
1009 let other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("c");
1010
1011 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&exact, false));
1012 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
1013 }
1014
1015 /// `!!x` is double negation, which should behave like `x`.
1016 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1017 fn double_negate_query_arust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/double_negate_query_a().() {
1018 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!!firefox").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1019
1020 let firefox = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("firefox");
1021 let other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("btm");
1022
1023 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&firefox, false));
1024 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
1025 }
1026
1027 /// `!!(cpu > 5)` is double negation, which should behave like `cpu > 5`.
1028 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1029 fn double_negate_query_brust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/double_negate_query_b().() {
1030 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!!(cpu > 5) ").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1031
1032 let mut big = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("big");
1033 big.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 10.0;
1034 let mut small = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("small");
1035 small.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 1.0;
1036
1037 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&big, false));
1038 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&small, false));
1039 }
1040
1041 /// `!` composes with `and`/`or`.
1042 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1043 fn negate_with_boolean_operatorsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/negate_with_boolean_operators().() {
1044 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!firefox and cpu > 5").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1045
1046 let mut firefox = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("firefox");
1047 firefox.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 10.0;
1048
1049 let mut other_high = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("btm");
1050 other_high.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 10.0;
1051
1052 let mut other_low = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("btm");
1053 other_low.cpu_usage_percentrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#cpu_usage_percent. = 1.0;
1054
1055 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&firefox, false));
1056 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other_high, false));
1057 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other_low, false));
1058 }
1059
1060 /// A bare `!` with nothing parseable after it must be rejected so that it
1061 /// doesn't silently become `name = "!"`. The literal form `"!"` still
1062 /// works.
1063 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1064 fn lone_bang_is_rejectedrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/lone_bang_is_rejected().() {
1065 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1066 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("! ").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1067 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!)").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1068 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("(!)").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1069 }
1070
1071 /// A quoted `"!"` as the RHS of a prefixed string query should match the
1072 /// literal `!`, not be treated as an operator.
1073 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1074 fn user_equals_quoted_bangrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/user_equals_quoted_bang().() {
1075 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("user = \"!\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1076
1077 let mut with_bang = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
1078 with_bang.userrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#user. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("!".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1079
1080 let mut other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
1081 other.userrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#user. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("root".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1082
1083 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&with_bang, false));
1084 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
1085 }
1086
1087 /// A quoted `"!"` as the RHS of a prefixed string query with "!=" should not match the
1088 /// literal `!`, nor should it be treated as an operator.
1089 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1090 fn user_negated_equals_quoted_bangrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/user_negated_equals_quoted_bang().() {
1091 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("user != \"!\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1092
1093 let mut with_bang = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
1094 with_bang.userrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#user. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("!".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1095
1096 let mut other = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a");
1097 other.userrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#user. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("root".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1098
1099 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&with_bang, false));
1100 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&other, false));
1101 }
1102
1103 /// A quoted `"!"` should remain a valid literal-name match.
1104 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1105 fn quoted_bang_matches_literalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_bang_matches_literal().() {
1106 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"!\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1107
1108 let with_bang = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("foo!");
1109 let without = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("foo");
1110
1111 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&with_bang, false));
1112 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&without, false));
1113 }
1114
1115 /// Quoted angle brackets should be treated as literal characters in name matches.
1116 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1117 fn quoted_angle_brackets_match_literalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_angle_brackets_match_literal().() {
1118 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"Thread<15>\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1119
1120 let matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("Thread<15>");
1121 let non_matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("Thread");
1122
1123 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&matching, false));
1124 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&non_matching, false));
1125 }
1126
1127 /// A quoted `=` should be treated as a literal character in name matches.
1128 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1129 fn quoted_equals_matches_literalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_equals_matches_literal().() {
1130 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"a=b\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1131
1132 let matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a=b");
1133 let non_matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("ab");
1134
1135 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&matching, false));
1136 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&non_matching, false));
1137 }
1138
1139 /// A quoted `!=` should be treated as a literal character sequence in name matches.
1140 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1141 fn quoted_not_equals_matches_literalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_not_equals_matches_literal().() {
1142 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"a!=b\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1143
1144 let matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a!=b");
1145 let non_matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("ab");
1146
1147 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&matching, false));
1148 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&non_matching, false));
1149 }
1150
1151 /// Quoted parentheses should be treated as literal characters in name matches.
1152 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1153 fn quoted_parens_match_literalrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/quoted_parens_match_literal().() {
1154 let query = parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("\"a(b)\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1155
1156 let matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("a(b)");
1157 let non_matching = simple_processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/simple_process().("ab");
1158
1159 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&matching, false));
1160 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().query.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/impl#[ProcessQuery]check().(&non_matching, false));
1161 }
1162
1163 /// Trailing operators with no RHS must error.
1164 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1165 fn not_equal_missing_value_is_rejectedrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/not_equal_missing_value_is_rejected().() {
1166 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("user !=").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1167 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state !=").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1168 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("time !=").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1169 }
1170
1171 /// Some miscellaneous invalid string searches involving negation (`!`) parsing.
1172 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1173 fn misc_invalid_bang_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/misc_invalid_bang_search().() {
1174 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("user = !").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1175 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("user != !").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1176 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("pid = !").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1177 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("state !").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1178 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("!cpu > 5").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1179 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("! cpu > 5").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1180 }
1181
1182 /// `=!` is not a valid operator.
1183 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1184 fn reversed_bang_equal_is_rejectedrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/reversed_bang_equal_is_rejected().() {
1185 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu =!").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1186 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu = !").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1187 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu = ! 5").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1188 }
1189
1190 /// `!=` with a non-numeric RHS should fail.
1191 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1192 fn not_equal_non_numeric_rhs_is_rejectedrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/not_equal_non_numeric_rhs_is_rejected().() {
1193 parse_query_no_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/tests/parse_query_no_options().("cpu != abc").unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
1194 }
1195 }