---
epic: 13
story: 13.5
title: "Test Suite"
status: draft
---

## Epic 13 — Performance & Reliability
**Goal:** Instant evaluation, never lose work.

### Story 13.5: Test Suite

As a CalcPad developer,
I want a comprehensive test suite with > 95% code coverage on calcpad-engine,
So that regressions are caught early and every function, conversion, and multi-line interaction is verified.

**Acceptance Criteria:**

**Given** the calcpad-engine crate
**When** the full test suite is executed via `cargo test`
**Then** code coverage as measured by `cargo-tarpaulin` or equivalent exceeds 95% of lines in the engine crate
**And** all tests pass with zero failures

**Given** every public function and unit conversion in calcpad-engine
**When** unit tests are written
**Then** each function has at least one test for the happy path
**And** each function has at least one test for error/edge cases (division by zero, overflow, unknown unit, etc.)
**And** every supported unit conversion pair has a dedicated round-trip accuracy test

**Given** multi-line sheets with variables, dependencies, and mixed expressions
**When** integration tests are executed
**Then** end-to-end evaluation of representative sheets produces correct results
**And** integration tests cover: variable assignment and reference, chained dependencies, circular reference detection, unit conversion across lines, and currency conversion

**Given** the engine's parsing and evaluation logic
**When** property-based tests are run via `proptest`
**Then** random valid expressions always produce a result without panicking
**And** random malformed expressions produce a graceful error without panicking
**And** evaluation of `a + b` always equals evaluation of `b + a` for numeric values

**Given** the benchmark suite defined with `criterion`
**When** benchmarks are executed
**Then** benchmarks exist for: single-line evaluation, 100-line sheet evaluation, 500-line sheet evaluation, DAG rebuild, and unit conversion lookup
**And** benchmark results are recorded so regressions can be detected in CI
