mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
refactor(test): Move compare tests into a mod
This commit is contained in:
parent
17b52b0ca1
commit
c8113d3a1c
@ -822,129 +822,134 @@ impl fmt::Debug for WildStr<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn wild_str_cmp() {
|
mod test {
|
||||||
for (a, b) in &[
|
use super::*;
|
||||||
("a b", "a b"),
|
|
||||||
("a[..]b", "a b"),
|
#[test]
|
||||||
("a[..]", "a b"),
|
fn wild_str_cmp() {
|
||||||
("[..]", "a b"),
|
for (a, b) in &[
|
||||||
("[..]b", "a b"),
|
("a b", "a b"),
|
||||||
] {
|
("a[..]b", "a b"),
|
||||||
assert_eq!(WildStr::new(a), WildStr::new(b));
|
("a[..]", "a b"),
|
||||||
|
("[..]", "a b"),
|
||||||
|
("[..]b", "a b"),
|
||||||
|
] {
|
||||||
|
assert_eq!(WildStr::new(a), WildStr::new(b));
|
||||||
|
}
|
||||||
|
for (a, b) in &[("[..]b", "c"), ("b", "c"), ("b", "cb")] {
|
||||||
|
assert_ne!(WildStr::new(a), WildStr::new(b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (a, b) in &[("[..]b", "c"), ("b", "c"), ("b", "cb")] {
|
|
||||||
assert_ne!(WildStr::new(a), WildStr::new(b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dirty_msvc() {
|
fn dirty_msvc() {
|
||||||
let case = |expected: &str, wild: &str, msvc: bool| {
|
let case = |expected: &str, wild: &str, msvc: bool| {
|
||||||
assert_eq!(expected, &replace_dirty_msvc_impl(wild, msvc));
|
assert_eq!(expected, &replace_dirty_msvc_impl(wild, msvc));
|
||||||
};
|
};
|
||||||
|
|
||||||
// no replacements
|
// no replacements
|
||||||
case("aa", "aa", false);
|
case("aa", "aa", false);
|
||||||
case("aa", "aa", true);
|
case("aa", "aa", true);
|
||||||
|
|
||||||
// with replacements
|
// with replacements
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
[DIRTY] a",
|
[DIRTY] a",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a",
|
[DIRTY-MSVC] a",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
case(
|
case(
|
||||||
"",
|
"",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a",
|
[DIRTY-MSVC] a",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
[DIRTY] a
|
[DIRTY] a
|
||||||
[COMPILING] a",
|
[COMPILING] a",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a
|
[DIRTY-MSVC] a
|
||||||
[COMPILING] a",
|
[COMPILING] a",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
[COMPILING] a",
|
[COMPILING] a",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a
|
[DIRTY-MSVC] a
|
||||||
[COMPILING] a",
|
[COMPILING] a",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
// test trailing newline behavior
|
// test trailing newline behavior
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
", "\
|
", "\
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
", true,
|
", true,
|
||||||
);
|
);
|
||||||
|
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
", "\
|
", "\
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
", false,
|
", false,
|
||||||
);
|
);
|
||||||
|
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
A
|
A
|
||||||
B", "\
|
B", "\
|
||||||
A
|
A
|
||||||
B", true,
|
B", true,
|
||||||
);
|
);
|
||||||
|
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
A
|
A
|
||||||
B", "\
|
B", "\
|
||||||
A
|
A
|
||||||
B", false,
|
B", false,
|
||||||
);
|
);
|
||||||
|
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
[DIRTY] a
|
[DIRTY] a
|
||||||
",
|
",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a
|
[DIRTY-MSVC] a
|
||||||
",
|
",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
case(
|
case(
|
||||||
"\n",
|
"\n",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a
|
[DIRTY-MSVC] a
|
||||||
",
|
",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
case(
|
case(
|
||||||
"\
|
"\
|
||||||
[DIRTY] a",
|
[DIRTY] a",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a",
|
[DIRTY-MSVC] a",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
case(
|
case(
|
||||||
"",
|
"",
|
||||||
"\
|
"\
|
||||||
[DIRTY-MSVC] a",
|
[DIRTY-MSVC] a",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user