Debian Codegraph @

src/tests/test_utils.rs

raw symbols SCIP
1 #![cfg(test)]
2 /// Return true iff `s` contains exactly one occurrence of substring `t`.
3 pub fn contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().(s: &str, t: &str) -> bool {
4 match (s.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().(t), s.rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rfind().(t)) {
5 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(j)) => i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().j,
6 _ => false,
7 }
8 }
9
10 #[allow(dead_code)]
11 pub fn print_with_line_numbersrust-analyzer cargo git-delta 0.19.2 tests/test_utils/print_with_line_numbers().(s: &str) {
12 for (i, t) in s.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
13 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:>2}│ {}", i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1, t);
14 }
15 }
16
17 #[cfg(test)]
18 mod testsrust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/ {
19 use craterust-analyzer cargo git-delta 0.19.2 crate/::testsrust-analyzer cargo git-delta 0.19.2 tests/::test_utilsrust-analyzer cargo git-delta 0.19.2 tests/test_utils/::*;
20
21 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
22 fn test_contains_once_1rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_1().() {
23 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("", ""));
24 }
25
26 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
27 fn test_contains_once_2rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_2().() {
28 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("a", "a"));
29 }
30
31 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
32 fn test_contains_once_3rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_3().() {
33 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().contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("", "a"));
34 }
35
36 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
37 fn test_contains_once_4rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_4().() {
38 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().contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("a", "b"));
39 }
40
41 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
42 fn test_contains_once_5rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_5().() {
43 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().contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("a a", "a"));
44 }
45
46 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
47 fn test_contains_once_6rust-analyzer cargo git-delta 0.19.2 tests/test_utils/tests/test_contains_once_6().() {
48 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(contains_oncerust-analyzer cargo git-delta 0.19.2 tests/test_utils/contains_once().("a b", "b"));
49 }
50 }