test: improve assertions in bug hunt reproductions
Refine assertions in reproduction tests to be more specific and ensure they correctly validate expected error messages and warnings. This includes improvements to: - duplicate_csv_headers_not_silent - repeated_import_coordinates_not_silently_overwritten - long_csv_row_is_not_silently_dropped - wide_cell_clamps_without_overflow Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-qat-GGUF:UD-Q4_K_XL)
This commit is contained in:
@@ -58,7 +58,12 @@ fn csv_nonfinite_is_not_zero() {
|
||||
fn duplicate_csv_headers_not_silent() {
|
||||
let result = parse_csv_bytes_with_warnings(b"A,A\n1,2\n");
|
||||
assert!(
|
||||
result.is_err() || !result.unwrap().1.is_empty(),
|
||||
match result {
|
||||
Err(error) => error.to_string().to_lowercase().contains("duplicate"),
|
||||
Ok((_, warnings)) => warnings.iter().any(|warning| {
|
||||
warning.to_lowercase().contains("duplicate") && warning.contains("A")
|
||||
}),
|
||||
},
|
||||
"duplicate headers silently overwrite a field"
|
||||
);
|
||||
}
|
||||
@@ -88,7 +93,13 @@ fn repeated_import_coordinates_not_silently_overwritten() {
|
||||
.filter_map(|(_, v)| v.as_f64())
|
||||
.sum();
|
||||
assert!(
|
||||
total == 30.0 || !warnings.is_empty(),
|
||||
total == 30.0
|
||||
|| warnings.iter().any(|warning| {
|
||||
let warning = warning.to_lowercase();
|
||||
(warning.contains("duplicate") || warning.contains("overwrite"))
|
||||
&& warning.contains("east")
|
||||
&& warning.contains("revenue")
|
||||
}),
|
||||
"total {total}, no warning {warnings:?}"
|
||||
);
|
||||
}
|
||||
@@ -159,10 +170,24 @@ fn label_stays_off_axes_in_new_view() {
|
||||
fn long_csv_row_is_not_silently_dropped() {
|
||||
let r = parse_csv_bytes_with_warnings(b"A,B\n1,2,3\n");
|
||||
assert!(
|
||||
r.is_err() || !r.unwrap().1.is_empty(),
|
||||
match r {
|
||||
Err(error) => {
|
||||
let message = error.to_string().to_lowercase();
|
||||
message.contains("3")
|
||||
&& message.contains("2")
|
||||
&& (message.contains("field") || message.contains("column"))
|
||||
}
|
||||
Ok((_, warnings)) => warnings.iter().any(|warning| {
|
||||
let warning = warning.to_lowercase();
|
||||
warning.contains("3")
|
||||
&& warning.contains("2")
|
||||
&& (warning.contains("field") || warning.contains("column"))
|
||||
}),
|
||||
},
|
||||
"extra value 3 dropped silently"
|
||||
);
|
||||
}
|
||||
// Passing control: embedded carriage returns already survive persistence.
|
||||
#[test]
|
||||
fn literal_cr_name_survives_roundtrip() {
|
||||
let mut w = Workbook::new("test");
|
||||
@@ -357,7 +382,11 @@ fn wide_cell_clamps_without_overflow() {
|
||||
false,
|
||||
0,
|
||||
);
|
||||
assert!(widths.iter().all(|w| *w <= 32));
|
||||
assert_eq!(
|
||||
widths,
|
||||
vec![improvise::ui::viewport::MAX_COL_WIDTH],
|
||||
"the Revenue column must reach the width cap"
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn ordinary_controls() {
|
||||
|
||||
Reference in New Issue
Block a user