refactor: remove dead code, replace sum_matching tests with evaluate()
Removes unused methods (sum_matching, get_mut, item_by_name, item_index, top_level_groups, is_group_collapsed, show_item) and unused constants (LABEL_THRESHOLD, MIN_COL_WIDTH). The sum_matching tests in model.rs were bypassing the formula evaluator entirely. Replaced them with equivalent tests that call evaluate() against the existing Total = SUM(Revenue) formula, exercising the real aggregation code path. Also fixes a compile error in view.rs prop_tests where View/Axis imports and a doc comment were incorrectly commented out. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -933,11 +933,11 @@ mod five_category {
|
||||
#[test]
|
||||
fn sum_revenue_for_east_region() {
|
||||
let m = build_model();
|
||||
let partial = vec![
|
||||
("Measure".to_string(), "Revenue".to_string()),
|
||||
let key = CellKey::new(vec![
|
||||
("Measure".to_string(), "Total".to_string()),
|
||||
("Region".to_string(), "East".to_string()),
|
||||
];
|
||||
let total = m.data.sum_matching(&partial);
|
||||
]);
|
||||
let total = m.evaluate(&key).and_then(|v| v.as_f64()).unwrap();
|
||||
let expected: f64 = DATA.iter().filter(|&&(r, _, _, _, _, _)| r == "East").map(|&(_, _, _, _, rev, _)| rev).sum();
|
||||
assert!(approx(total, expected), "expected {expected}, got {total}");
|
||||
}
|
||||
@ -945,11 +945,11 @@ mod five_category {
|
||||
#[test]
|
||||
fn sum_revenue_for_online_channel() {
|
||||
let m = build_model();
|
||||
let partial = vec![
|
||||
let key = CellKey::new(vec![
|
||||
("Channel".to_string(), "Online".to_string()),
|
||||
("Measure".to_string(), "Revenue".to_string()),
|
||||
];
|
||||
let total = m.data.sum_matching(&partial);
|
||||
("Measure".to_string(), "Total".to_string()),
|
||||
]);
|
||||
let total = m.evaluate(&key).and_then(|v| v.as_f64()).unwrap();
|
||||
let expected: f64 = DATA.iter().filter(|&&(_, _, ch, _, _, _)| ch == "Online").map(|&(_, _, _, _, rev, _)| rev).sum();
|
||||
assert!(approx(total, expected), "expected {expected}, got {total}");
|
||||
}
|
||||
@ -957,12 +957,12 @@ mod five_category {
|
||||
#[test]
|
||||
fn sum_revenue_for_shirts_q1() {
|
||||
let m = build_model();
|
||||
let partial = vec![
|
||||
("Measure".to_string(), "Revenue".to_string()),
|
||||
let key = CellKey::new(vec![
|
||||
("Measure".to_string(), "Total".to_string()),
|
||||
("Product".to_string(), "Shirts".to_string()),
|
||||
("Time".to_string(), "Q1".to_string()),
|
||||
];
|
||||
let total = m.data.sum_matching(&partial);
|
||||
]);
|
||||
let total = m.evaluate(&key).and_then(|v| v.as_f64()).unwrap();
|
||||
let expected: f64 = DATA.iter().filter(|&&(_, p, _, t, _, _)| p == "Shirts" && t == "Q1").map(|&(_, _, _, _, rev, _)| rev).sum();
|
||||
assert!(approx(total, expected), "expected {expected}, got {total}");
|
||||
}
|
||||
@ -970,8 +970,10 @@ mod five_category {
|
||||
#[test]
|
||||
fn sum_all_revenue_equals_grand_total() {
|
||||
let m = build_model();
|
||||
let partial = vec![("Measure".to_string(), "Revenue".to_string())];
|
||||
let total = m.data.sum_matching(&partial);
|
||||
let key = CellKey::new(vec![
|
||||
("Measure".to_string(), "Total".to_string()),
|
||||
]);
|
||||
let total = m.evaluate(&key).and_then(|v| v.as_f64()).unwrap();
|
||||
let expected: f64 = DATA.iter().map(|&(_, _, _, _, rev, _)| rev).sum();
|
||||
assert!(approx(total, expected), "expected {expected}, got {total}");
|
||||
}
|
||||
@ -1193,4 +1195,3 @@ mod prop_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user