Download this file
| 1 | package calc |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // A formula whose range exceeds maxRangeCells still evaluates (as a |
| 6 | // single #REF! argument — see TestEvalCallArgOverCapRangeIsRefError), but |
| 7 | // SetFormula must not build hundreds of thousands of precedent edges for |
| 8 | // it: collectRefs leaves an over-cap range untracked rather than |
| 9 | // expanding it. |
| 10 | func TestCollectRefsLeavesOverCapRangeUntracked(t *testing.T) { |
| 11 | overCap := &Range{From: &Ref{RowPos: 0, ColPos: 0}, To: &Ref{RowPos: maxRangeCells, ColPos: 0}} |
| 12 | refs := collectRefs(overCap) |
| 13 | if len(refs) != 0 { |
| 14 | t.Fatalf("collectRefs on an over-cap range returned %d refs, want 0 (untracked, not partially expanded)", len(refs)) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | // A range at exactly the cap is still tracked in full. |
| 19 | func TestCollectRefsTracksRangeAtCap(t *testing.T) { |
| 20 | atCap := &Range{From: &Ref{RowPos: 0, ColPos: 0}, To: &Ref{RowPos: maxRangeCells - 1, ColPos: 0}} |
| 21 | refs := collectRefs(atCap) |
| 22 | if len(refs) != maxRangeCells { |
| 23 | t.Fatalf("collectRefs on a range at the cap returned %d refs, want %d", len(refs), maxRangeCells) |
| 24 | } |
| 25 | } |
| 26 | |