diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-02-01 19:09:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 19:09:25 +0100 |
commit | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (patch) | |
tree | b97fcd7d0433ca76468a7a9dd9b41a0f77f5c2bd /test_util/src/lib.rs | |
parent | 84f8b87f1b0fc6b7ec3a7f157f99d7f098d43101 (diff) |
refactor: Reorganise integration tests (#9282)
This commit reorganises cli/tests/integration_tests.rs.
All integration tests had been moved into integration module,
which allows to run only integration tests by "cargo test integration".
Additionally some tests were further grouped under nested modules
like "inspector", "file_watcher" or "repl".
Diffstat (limited to 'test_util/src/lib.rs')
-rw-r--r-- | test_util/src/lib.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 14ec723f2..da7c8703e 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1559,6 +1559,70 @@ mod tests { } #[test] + fn test_pattern_match() { + // foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, plugh, xyzzy + + let wildcard = "[BAR]"; + assert!(pattern_match("foo[BAR]baz", "foobarbaz", wildcard)); + assert!(!pattern_match("foo[BAR]baz", "foobazbar", wildcard)); + + let multiline_pattern = "[BAR] +foo: +[BAR]baz[BAR]"; + + fn multi_line_builder(input: &str, leading_text: Option<&str>) -> String { + // If there is leading text add a newline so it's on it's own line + let head = match leading_text { + Some(v) => format!("{}\n", v), + None => "".to_string(), + }; + format!( + "{}foo: +quuz {} corge +grault", + head, input + ) + } + + // Validate multi-line string builder + assert_eq!( + "QUUX=qux +foo: +quuz BAZ corge +grault", + multi_line_builder("BAZ", Some("QUUX=qux")) + ); + + // Correct input & leading line + assert!(pattern_match( + multiline_pattern, + &multi_line_builder("baz", Some("QUX=quux")), + wildcard + )); + + // Correct input & no leading line + assert!(pattern_match( + multiline_pattern, + &multi_line_builder("baz", None), + wildcard + )); + + // Incorrect input & leading line + assert!(!pattern_match( + multiline_pattern, + &multi_line_builder("garply", Some("QUX=quux")), + wildcard + )); + + // Incorrect input & no leading line + assert!(!pattern_match( + multiline_pattern, + &multi_line_builder("garply", None), + wildcard + )); + } + + #[test] fn max_mem_parse() { const TEXT: &str = include_str!("./testdata/time.out"); let size = parse_max_mem(TEXT); |