Skip to content

Commit c8113d3

Browse files
committed
refactor(test): Move compare tests into a mod
1 parent 17b52b0 commit c8113d3

File tree

1 file changed

+81
-76
lines changed

1 file changed

+81
-76
lines changed

crates/cargo-test-support/src/compare.rs

Lines changed: 81 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -822,129 +822,134 @@ impl fmt::Debug for WildStr<'_> {
822822
}
823823
}
824824

825-
#[test]
826-
fn wild_str_cmp() {
827-
for (a, b) in &[
828-
("a b", "a b"),
829-
("a[..]b", "a b"),
830-
("a[..]", "a b"),
831-
("[..]", "a b"),
832-
("[..]b", "a b"),
833-
] {
834-
assert_eq!(WildStr::new(a), WildStr::new(b));
835-
}
836-
for (a, b) in &[("[..]b", "c"), ("b", "c"), ("b", "cb")] {
837-
assert_ne!(WildStr::new(a), WildStr::new(b));
825+
#[cfg(test)]
826+
mod test {
827+
use super::*;
828+
829+
#[test]
830+
fn wild_str_cmp() {
831+
for (a, b) in &[
832+
("a b", "a b"),
833+
("a[..]b", "a b"),
834+
("a[..]", "a b"),
835+
("[..]", "a b"),
836+
("[..]b", "a b"),
837+
] {
838+
assert_eq!(WildStr::new(a), WildStr::new(b));
839+
}
840+
for (a, b) in &[("[..]b", "c"), ("b", "c"), ("b", "cb")] {
841+
assert_ne!(WildStr::new(a), WildStr::new(b));
842+
}
838843
}
839-
}
840844

841-
#[test]
842-
fn dirty_msvc() {
843-
let case = |expected: &str, wild: &str, msvc: bool| {
844-
assert_eq!(expected, &replace_dirty_msvc_impl(wild, msvc));
845-
};
845+
#[test]
846+
fn dirty_msvc() {
847+
let case = |expected: &str, wild: &str, msvc: bool| {
848+
assert_eq!(expected, &replace_dirty_msvc_impl(wild, msvc));
849+
};
846850

847-
// no replacements
848-
case("aa", "aa", false);
849-
case("aa", "aa", true);
851+
// no replacements
852+
case("aa", "aa", false);
853+
case("aa", "aa", true);
850854

851-
// with replacements
852-
case(
853-
"\
855+
// with replacements
856+
case(
857+
"\
854858
[DIRTY] a",
855-
"\
859+
"\
856860
[DIRTY-MSVC] a",
857-
true,
858-
);
859-
case(
860-
"",
861-
"\
861+
true,
862+
);
863+
case(
864+
"",
865+
"\
862866
[DIRTY-MSVC] a",
863-
false,
864-
);
865-
case(
866-
"\
867+
false,
868+
);
869+
case(
870+
"\
867871
[DIRTY] a
868872
[COMPILING] a",
869-
"\
873+
"\
870874
[DIRTY-MSVC] a
871875
[COMPILING] a",
872-
true,
873-
);
874-
case(
875-
"\
876+
true,
877+
);
878+
case(
879+
"\
876880
[COMPILING] a",
877-
"\
881+
"\
878882
[DIRTY-MSVC] a
879883
[COMPILING] a",
880-
false,
881-
);
884+
false,
885+
);
882886

883-
// test trailing newline behavior
884-
case(
885-
"\
887+
// test trailing newline behavior
888+
case(
889+
"\
886890
A
887891
B
888892
", "\
889893
A
890894
B
891895
", true,
892-
);
896+
);
893897

894-
case(
895-
"\
898+
case(
899+
"\
896900
A
897901
B
898902
", "\
899903
A
900904
B
901905
", false,
902-
);
906+
);
903907

904-
case(
905-
"\
908+
case(
909+
"\
906910
A
907911
B", "\
908912
A
909913
B", true,
910-
);
914+
);
911915

912-
case(
913-
"\
916+
case(
917+
"\
914918
A
915919
B", "\
916920
A
917921
B", false,
918-
);
922+
);
919923

920-
case(
921-
"\
924+
case(
925+
"\
922926
[DIRTY] a
923927
",
924-
"\
928+
"\
925929
[DIRTY-MSVC] a
926930
",
927-
true,
928-
);
929-
case(
930-
"\n",
931-
"\
931+
true,
932+
);
933+
case(
934+
"\n",
935+
"\
932936
[DIRTY-MSVC] a
933937
",
934-
false,
935-
);
938+
false,
939+
);
936940

937-
case(
938-
"\
941+
case(
942+
"\
939943
[DIRTY] a",
940-
"\
944+
"\
941945
[DIRTY-MSVC] a",
942-
true,
943-
);
944-
case(
945-
"",
946-
"\
946+
true,
947+
);
948+
case(
949+
"",
950+
"\
947951
[DIRTY-MSVC] a",
948-
false,
949-
);
952+
false,
953+
);
954+
}
950955
}

0 commit comments

Comments
 (0)