use googletest::prelude::*;
use std::fmt::{Display, Write};
fn build_text<T: Display>(mut collection: impl Iterator<Item = T>) -> String {
let mut text = String::new();
write!(&mut text, "{}", collection.next().expect("Provided collection without elements"))
.unwrap();
for item in collection {
write!(&mut text, "\n{}", item).unwrap();
}
text
}
#[test]
fn colors_suppressed_when_both_no_color_and_force_color_are_set() -> Result<()> {
std::env::set_var("NO_COLOR", "1");
std::env::set_var("FORCE_COLOR", "1");
let result = verify_that!(build_text(1..50), eq(&build_text(1..51)));
verify_that!(
result,
err(displays_as(contains_substring(
"
Difference(-actual / +expected):
1
2
<---- 45 common lines omitted ---->
48
49
+50"
)))
)
}