--- jupyter: description: 'How planex2d is tested: tests written by hand against formulas, agentic testing, and fuzz tests with random shapes against identities, shapely and OpenCASCADE.' --- # How planex2d is tested planex2d is tested in three ways: tests written by hand, agentic testing, and fuzz tests with random inputs. Each test checks against something independent of planex2d. That is a formula or an identity wherever one exists, shapely otherwise, and OpenCASCADE as referee where planex2d and shapely disagree. ## Tests written by hand Every feature has its pytest tests, covering Boolean operations, offsets, cleanup and fitting, sketches and constraints, measuring, and import and export. They check exact properties: an area against its formula, a solved sketch against its dimensions, a mechanism against its closed form, and a shape written to OpenCASCADE and read back against the original. Every bug that is found becomes a test of its own. The examples in these docs are checked the same way. Each one prints the comparison of its result with a formula or a measured property, and the docs are rebuilt with the code. ## Agentic testing AI agents test planex2d in campaigns. Some try to break a given area, others work like users who know only these docs and try what they would expect from other CAD or FEM software. What they find becomes tests in the suite, and fixes to the code or to the docs. ## Fuzz tests Fuzz tests generate shapes at random: stars, rounded polygons, discs, faces with holes and spline outlines. They pair them with copies that are moved, turned, mirrored, shifted along an edge or nudged by tiny amounts. Then they check what must hold for any input: - the areas of union, common part and differences agree: area(a ∪ b) = area(a) + area(b) − area(a ∩ b); - Boolean operations are commutative, and a shape combined with itself gives itself; - the results match shapely's, and a point lies in a result exactly when it lies in the operands the operation asks for; - offsets there and back give the closing and opening of the shape; - shapes survive the round trip through OpenCASCADE and shapely; - solved sketches meet their dimensions. The random cases are seeded, so a run can be repeated. A failure prints its case as a tuple of numbers, and that tuple is pinned as a test of its own.