Debian Codegraph @

tests/select.rs

raw symbols SCIP
1 // Copyright 2019 the SimpleCSS Authors
2 // SPDX-License-Identifier: Apache-2.0 OR MIT
3
4 //! Select
5
6 use simplecssrust-analyzer cargo simplecss 0.2.2 crate/::*;
7
8 struct XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#<'a, 'input: 'a>(roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Noderust-analyzer cargo roxmltree 0.20.0 Node#<'a, 'input>);
9
10 impl<'a, 'input: 'a> XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#<'a, 'input> {
11 fn selectrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'a, 'input>`]select().(&self, text: &str) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Noderust-analyzer cargo roxmltree 0.20.0 Node#<'a, 'input>> {
12 let selectors = Selectorrust-analyzer cargo simplecss 0.2.2 selector/Selector#::parserust-analyzer cargo simplecss 0.2.2 selector/impl#[`Selector<'a>`]parse().(text).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
13 let mut nodes = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
14 for node in self.0rust-analyzer cargo simplecss 0.2.2 XmlNode#0..descendantsrust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]descendants().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|n| n.is_elementrust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]is_element().()) {
15 if selectors.matchesrust-analyzer cargo simplecss 0.2.2 selector/impl#[`Selector<'a>`]matches().(&XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#(node)) {
16 nodes.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(node);
17 }
18 }
19
20 nodes
21 }
22 }
23
24 impl Elementrust-analyzer cargo simplecss 0.2.2 selector/Element# for XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#<'_, '_> {
25 fn parent_elementrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]parent_element().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]> {
26 self.0rust-analyzer cargo simplecss 0.2.2 XmlNode#0..parent_elementrust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]parent_element().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#)
27 }
28
29 fn prev_sibling_elementrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]prev_sibling_element().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]> {
30 self.0rust-analyzer cargo simplecss 0.2.2 XmlNode#0..prev_sibling_elementrust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]prev_sibling_element().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#)
31 }
32
33 fn has_local_namerust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]has_local_name().(&self, local_name: &str) -> bool {
34 self.0rust-analyzer cargo simplecss 0.2.2 XmlNode#0..tag_namerust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]tag_name().().namerust-analyzer cargo roxmltree 0.20.0 impl#[`ExpandedName<'a, 'b>`]name().() 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().local_name
35 }
36
37 fn attribute_matchesrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]attribute_matches().(&self, local_name: &str, operator: AttributeOperatorrust-analyzer cargo simplecss 0.2.2 selector/AttributeOperator#<'_>) -> bool {
38 match self.0rust-analyzer cargo simplecss 0.2.2 XmlNode#0..attributerust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]attribute().(local_name) {
39 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) => operator.matchesrust-analyzer cargo simplecss 0.2.2 selector/impl#[`AttributeOperator<'_>`]matches().(value),
40 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => false,
41 }
42 }
43
44 fn pseudo_class_matchesrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]pseudo_class_matches().(&self, class: PseudoClassrust-analyzer cargo simplecss 0.2.2 selector/PseudoClass#<'_>) -> bool {
45 match class {
46 PseudoClassrust-analyzer cargo simplecss 0.2.2 selector/PseudoClass#::FirstChildrust-analyzer cargo simplecss 0.2.2 selector/PseudoClass#FirstChild# => self.prev_sibling_elementrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'_, '_>`][Element]prev_sibling_element().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().(),
47 _ => false,
48 }
49 }
50 }
51
52 macro_rules! match_singlerust-analyzer cargo simplecss 0.2.2 match_single! {
53 ($doc:expr, $selector:expr) => {{
54 let nodes = XmlNode($doc.root_element()).select($selector);
55 assert_eq!(nodes.len(), 1);
56 nodes[0].attribute("id").unwrap()
57 }};
58 }
59
60 macro_rules! match_nonerust-analyzer cargo simplecss 0.2.2 match_none! {
61 ($doc:expr, $selector:expr) => {{
62 assert_eq!(XmlNode($doc.root_element()).select($selector).len(), 0);
63 }};
64 }
65
66 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
67 fn select_01rust-analyzer cargo simplecss 0.2.2 select_01().() {
68 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().("<div id='div1'/>").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "*"), "div1");
70 }
71
72 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
73 fn select_02rust-analyzer cargo simplecss 0.2.2 select_02().() {
74 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().("<div id='div1'/>").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div"), "div1");
76 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "p");
77 }
78
79 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
80 fn select_03rust-analyzer cargo simplecss 0.2.2 select_03().() {
81 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().("<div id='div1'/>").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "#div1"), "div1");
83 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "#d1");
84 }
85
86 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
87 fn select_04rust-analyzer cargo simplecss 0.2.2 select_04().() {
88 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().("<div id='div1'/>").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
89 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "p#div1");
90 }
91
92 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
93 fn select_05rust-analyzer cargo simplecss 0.2.2 select_05().() {
94 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
95 "\
96 <div id='div1'>
97 <p id='p1'/>
98 </div>
99 ",
100 )
101 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
102
103 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p"), "p1");
104 }
105
106 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
107 fn select_06rust-analyzer cargo simplecss 0.2.2 select_06().() {
108 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
109 "\
110 <div id='div1'>
111 <g id='g1'>
112 <p id='p1'/>
113 </g>
114 </div>
115 ",
116 )
117 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
118
119 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p"), "p1");
120 }
121
122 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
123 fn select_07rust-analyzer cargo simplecss 0.2.2 select_07().() {
124 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
125 "\
126 <div id='div1'>
127 <div id='div2'>
128 <g id='g1'>
129 <p id='p1'/>
130 </g>
131 </div>
132 </div>
133 ",
134 )
135 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
136
137 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p"), "p1");
138 }
139
140 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
141 fn select_08rust-analyzer cargo simplecss 0.2.2 select_08().() {
142 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
143 "\
144 <div id='div1'>
145 <g id='g1'>
146 <p id='p1'>
147 <div/>
148 </p>
149 </g>
150 </div>
151 ",
152 )
153 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
154
155 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p"), "p1");
156 }
157
158 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
159 fn select_09rust-analyzer cargo simplecss 0.2.2 select_09().() {
160 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
161 "\
162 <div id='div1'>
163 <g id='g1'>
164 <p id='p1'/>
165 </g>
166 </div>
167 ",
168 )
169 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
170
171 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div g p"), "p1");
172 }
173
174 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
175 fn select_10rust-analyzer cargo simplecss 0.2.2 select_10().() {
176 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
177 "\
178 <div id='div1'>
179 <q id='g1'>
180 <p id='p1'/>
181 </q>
182 </div>
183 ",
184 )
185 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
186
187 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "div g p");
188 }
189
190 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
191 fn select_11rust-analyzer cargo simplecss 0.2.2 select_11().() {
192 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
193 "\
194 <div id='div1'>
195 <g id='g1'>
196 <p id='p1'/>
197 </g>
198 </div>
199 ",
200 )
201 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
202
203 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div * p"), "p1");
204 }
205
206 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
207 fn select_12rust-analyzer cargo simplecss 0.2.2 select_12().() {
208 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
209 "\
210 <div id='div1'>
211 <p id='p1'>
212 <rect id='rect1'/>
213 <rect id='rect2' color='green'/>
214 </p>
215 </div>
216 ",
217 )
218 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
219
220 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p *[color]"), "rect2");
221 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div p [color]"), "rect2");
222 }
223
224 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
225 fn select_13rust-analyzer cargo simplecss 0.2.2 select_13().() {
226 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
227 "\
228 <div id='div1'>
229 <p id='p1'/>
230 </div>
231 ",
232 )
233 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
234
235 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div > p"), "p1");
236 }
237
238 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
239 fn select_14rust-analyzer cargo simplecss 0.2.2 select_14().() {
240 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
241 "\
242 <p id='p1'/>
243 ",
244 )
245 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
246
247 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "div > p");
248 }
249
250 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
251 fn select_15rust-analyzer cargo simplecss 0.2.2 select_15().() {
252 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
253 "\
254 <div id='div1'>
255 <g id='g1'>
256 <p id='p1'/>
257 </g>
258 </div>
259 ",
260 )
261 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
262
263 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "div > p");
264 }
265
266 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
267 fn select_16rust-analyzer cargo simplecss 0.2.2 select_16().() {
268 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
269 "\
270 <div id='div1'>
271 <p>
272 <ol>
273 <li>
274 <g>
275 <p id='p1'/>
276 </g>
277 </li>
278 </ol>
279 </p>
280 </div>
281 ",
282 )
283 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
284
285 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "div ol>li p"), "p1");
286 }
287
288 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
289 fn select_17rust-analyzer cargo simplecss 0.2.2 select_17().() {
290 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
291 "\
292 <div id='div1'>
293 <p>
294 <ol>
295 <g>
296 <li>
297 <g>
298 <p id='p1'/>
299 </g>
300 </li>
301 </g>
302 </ol>
303 </p>
304 </div>
305 ",
306 )
307 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
308
309 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "div ol>li p");
310 }
311
312 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
313 fn select_18rust-analyzer cargo simplecss 0.2.2 select_18().() {
314 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
315 "\
316 <div id='div1'>
317 <g/>
318 <p id='p1'/>
319 </div>
320 ",
321 )
322 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
323
324 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "g + p"), "p1");
325 }
326
327 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
328 fn select_19rust-analyzer cargo simplecss 0.2.2 select_19().() {
329 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
330 "\
331 <div id='div1'>
332 <test/>
333 <g/>
334 <p id='p1'/>
335 </div>
336 ",
337 )
338 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
339
340 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "g + p"), "p1");
341 }
342
343 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
344 fn select_20rust-analyzer cargo simplecss 0.2.2 select_20().() {
345 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
346 "\
347 <div id='div1'>
348 <p id='p1'/>
349 <g/>
350 </div>
351 ",
352 )
353 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
354
355 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "g + p");
356 }
357
358 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
359 fn select_21rust-analyzer cargo simplecss 0.2.2 select_21().() {
360 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
361 "\
362 <div id='div1'>
363 <p id='p1'/>
364 </div>
365 ",
366 )
367 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
368
369 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "div + p");
370 }
371
372 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
373 fn select_22rust-analyzer cargo simplecss 0.2.2 select_22().() {
374 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
375 "\
376 <div id='div1'>
377 <p id='p1'/>
378 </div>
379 ",
380 )
381 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
382
383 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[id=p1]"), "p1");
384 }
385
386 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
387 fn select_23rust-analyzer cargo simplecss 0.2.2 select_23().() {
388 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
389 "\
390 <div id='div1'>
391 <p id='p1' class='test warn'/>
392 </div>
393 ",
394 )
395 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
396
397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[class~=warn]"), "p1");
398 }
399
400 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
401 fn select_24rust-analyzer cargo simplecss 0.2.2 select_24().() {
402 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
403 "\
404 <div id='div1'>
405 <p id='p1' class='test warn'/>
406 </div>
407 ",
408 )
409 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
410
411 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "[class~='test warn']");
412 }
413
414 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
415 fn select_25rust-analyzer cargo simplecss 0.2.2 select_25().() {
416 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
417 "\
418 <div id='div1'>
419 <p id='p1' lang='en'/>
420 </div>
421 ",
422 )
423 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
424
425 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[lang=en]"), "p1");
426 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[lang|=en]"), "p1");
427 }
428
429 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
430 fn select_26rust-analyzer cargo simplecss 0.2.2 select_26().() {
431 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
432 "\
433 <div id='div1'>
434 <p id='p1' lang='en-US'/>
435 </div>
436 ",
437 )
438 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
439
440 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[lang='en-US']"), "p1");
441 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "[lang|=en]"), "p1");
442 }
443
444 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
445 fn select_27rust-analyzer cargo simplecss 0.2.2 select_27().() {
446 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
447 "\
448 <div id='div1'>
449 <p id='p1' class='pastoral blue aqua marine'/>
450 </div>
451 ",
452 )
453 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
454
455 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, ".marine.pastoral"), "p1");
456 }
457
458 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
459 fn select_28rust-analyzer cargo simplecss 0.2.2 select_28().() {
460 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
461 "\
462 <div id='div1'>
463 <p id='p1'/>
464 </div>
465 ",
466 )
467 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
468
469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(match_singlerust-analyzer cargo simplecss 0.2.2 match_single!!(doc, "p:first-child"), "p1");
470 }
471
472 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
473 fn select_29rust-analyzer cargo simplecss 0.2.2 select_29().() {
474 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
475 "\
476 <div id='div1'>
477 <rect/>
478 <p id='p1'/>
479 </div>
480 ",
481 )
482 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
483
484 match_nonerust-analyzer cargo simplecss 0.2.2 match_none!!(doc, "p:first-child");
485 }
486
487 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
488 fn select_30rust-analyzer cargo simplecss 0.2.2 select_30().() {
489 let doc = roxmltreerust-analyzer cargo roxmltree 0.20.0 crate/::Documentrust-analyzer cargo roxmltree 0.20.0 Document#::parserust-analyzer cargo roxmltree 0.20.0 parse/impl#[`Document<'input>`]parse().(
490 "\
491 <div id='div1'>
492 <p id='p1'/>
493 <p id='p2'/>
494 </div>
495 ",
496 )
497 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
498
499 let nodes = XmlNoderust-analyzer cargo simplecss 0.2.2 XmlNode#(doc.root_elementrust-analyzer cargo roxmltree 0.20.0 impl#[`Document<'input>`]root_element().()).selectrust-analyzer cargo simplecss 0.2.2 impl#[`XmlNode<'a, 'input>`]select().(":first-child");
500 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nodes.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
501 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nodes[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..attributerust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]attribute().("id").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "div1");
502 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nodes[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..attributerust-analyzer cargo roxmltree 0.20.0 impl#[`Node<'a, 'input>`]attribute().("id").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "p1");
503 }
504
505 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
506 fn to_stringrust-analyzer cargo simplecss 0.2.2 to_string().() {
507 let selectors = Selectorrust-analyzer cargo simplecss 0.2.2 selector/Selector#::parserust-analyzer cargo simplecss 0.2.2 selector/impl#[`Selector<'a>`]parse().("a > b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
508 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(selectors.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a > b");
509 }