Merge pull request #143 from fiddlerwoaroof/fix/a36c-count-exact
test(core): count_aggregation asserts the count, not that it is at least one (improvise-a36c)
This commit is contained in:
@@ -1217,3 +1217,29 @@ view a fresh workbook creates. Making `Workbook::create_view` refuse or rename
|
||||
a name it already holds passes this test and breaks records mode, because both
|
||||
rebuilders depend on the replacement — which is why the fix is a helper beside
|
||||
`create_view` and not a change to it.
|
||||
|
||||
### model::types::formula_tests::count_aggregation
|
||||
|
||||
improvise-a36c. The test asserted `val >= 1.0` for `COUNT(Sales)` at
|
||||
`Region=East`, where the fixture's answer is exactly `1.0` — so every inflated
|
||||
count cleared the bar. The ticket's own fault injection (`values.len() + 999.0`
|
||||
in `eval_agg`) is not the worst case: it fails one *other* test,
|
||||
`model::types::agg_helper_tests::eval_agg_over_no_rows_is_zero_only_where_an_identity_exists`,
|
||||
which sees the empty case move from `0` to `999`. Preserve the empty case
|
||||
(`if values.is_empty() { 0.0 } else { len + 999.0 }`) and the **entire
|
||||
workspace of 1699 tests passes** while `COUNT` over any non-empty set is wrong
|
||||
by 999. That measurement, not the ticket's, is what this entry exists to record:
|
||||
the only thing standing between a wrong `COUNT` and a green suite was a check on
|
||||
the identity element, which is the one input `COUNT` gets right by accident.
|
||||
|
||||
Two assertions, because one does not separate the neighbouring question.
|
||||
`assert_eq!(at East, 1.0)` answers *is the count inflated* — it fails the
|
||||
`+999` rival at `left: Some(1000.0)`. It does **not** answer *does `COUNT` count
|
||||
anything*: a `Count` arm returning a constant `1.0` satisfies it, and at a
|
||||
fixture whose expected value is `1` that rival is invisible by construction.
|
||||
The second assertion, `COUNT` unscoped over all three regions being `3.0`,
|
||||
is what fails it, at `left: Some(1.0)`. Both rivals were injected and both fail,
|
||||
at different assertions — the first at the East count, the second at the total.
|
||||
|
||||
The fixture is deliberately asymmetric: one matching cell under the scoped key
|
||||
and three under the unscoped one, so no single constant can satisfy both.
|
||||
|
||||
@@ -1765,11 +1765,12 @@ mod formula_tests {
|
||||
);
|
||||
}
|
||||
m.add_formula(parse_formula("Count = COUNT(Sales)", "_Measure").unwrap());
|
||||
let val = m
|
||||
.evaluate(&coord(&[("_Measure", "Count"), ("Region", "East")]))
|
||||
.and_then(|v| v.as_f64())
|
||||
.unwrap();
|
||||
assert!(val >= 1.0);
|
||||
let count_at = |k: CellKey| m.evaluate(&k).and_then(|v| v.as_f64());
|
||||
assert_eq!(
|
||||
count_at(coord(&[("_Measure", "Count"), ("Region", "East")])),
|
||||
Some(1.0)
|
||||
);
|
||||
assert_eq!(count_at(coord(&[("_Measure", "Count")])), Some(3.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user