oxedyne/fe2o3/fe2o3_text/tests/pattern.rs
768 bytes, 11 runs
created by r1870400018:1121, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use oxedyne_fe2o3_text::{ |
| 2 | pattern::{ |
| 3 | SacssNode, |
| 4 | SacssOp, |
| 5 | Sacss, |
| 6 | }, |
| 7 | }; |
| 8 | |
| 9 | use oxedyne_fe2o3_core::{ |
| 10 | prelude::*, |
| 11 | test::test_it, |
| 12 | }; |
| 13 | |
| 14 | |
| 15 | pub fn test_pattern(filter: &'static str) -> Outcome<()> { |
| 16 | |
| 17 | res!(test_it(filter, &["Starts with", "all", "match"], || { |
| 18 | |
| 19 | let root = SacssNode::new_leaf(SacssOp::StartsWith("he".to_string())); |
| 20 | let mut matcher = Sacss::new(root); |
| 21 | |
| 22 | let input = "hello world hello"; |
| 23 | let mut all_results = Vec::new(); |
| 24 | |
| 25 | for c in input.chars() { |
| 26 | let results = matcher.process_char(c); |
| 27 | all_results.extend(results); |
| 28 | } |
| 29 | |
| 30 | test!("Buffer: {}", matcher.buffer); |
| 31 | test!("Results: {:?}", all_results); |
| 32 | |
| 33 | Ok(()) |
| 34 | |
| 35 | })); |
| 36 | |
| 37 | Ok(()) |
| 38 | } |