How we test the calculators
Every formula is a plain TypeScript function with unit tests. The page only displays what those functions return.
We do not copy competitor code. We write the geometry (area × depth, circle from diameter, triangle as base × height ÷ 2), convert cubic feet to yards by dividing by 27, and apply waste as a separate line. Yards and tons round to two decimals. Bags and tiles round up to a whole count.
Tests live in lib/calculators/ and run with Vitest. A change that breaks a known job fails the build.
Worked examples we keep green
These jobs are in the test suite. Each calculator page uses the same function, so the default result on the page should match.
| Calculator | Job | Expected |
|---|---|---|
| Gravel | 10 × 20 ft at 4 in, 1.40 t/yd³ | 2.47 yd³, 3.46 tons |
| Pea gravel | 10 × 10 ft at 3 in, 1.25 t/yd³ | 0.93 yd³, 1.16 tons |
| Cubic yards | 10 ft diameter circle at 3 in | 19.63 cu ft, 0.73 yd³ |
| Topsoil | 20 × 30 ft at 6 in, 1.10 t/yd³ | 11.11 yd³, 12.22 tons, 400 bags of 0.75 cu ft |
| Tile | 10 × 12 ft, 12 × 12 in, 10% waste | 120 sq ft, 132 tiles |
What we treat as typical, not law
Density starts at 1.40 tons per cubic yard for gravel, 1.25 for pea gravel, and 1.10 for loose topsoil. Tile waste starts at 10% for a straight layout and 15% for diagonal or herringbone. Bag sizes start at 0.5, 0.75, and 1.0 cubic feet for gravel, pea gravel, and topsoil. You can change those on the page. Typical does not mean your quarry uses the same number.
What a test does not prove
A green test does not inspect your subgrade, your grout joint, or a wet pile of soil. It proves that 10 × 20 × 4 in, run through our function, still equals 2.47 cubic yards. If you find a job where the page disagrees with that kind of arithmetic, email the link from the contact page. We add a failing test before we change the formula.
Last reviewed October 22, 2026.