Skip to content

Tighten geometry input validation and add triangle boundary tests#1

Merged
amartinsmg merged 1 commit intomainfrom
codex/verify-algorithm-implementations
Feb 11, 2026
Merged

Tighten geometry input validation and add triangle boundary tests#1
amartinsmg merged 1 commit intomainfrom
codex/verify-algorithm-implementations

Conversation

@amartinsmg
Copy link
Owner

Motivation

  • Strengthen mathematical preconditions to avoid undefined or invalid computations (division by zero, invalid square-root inputs, and degenerate polygons).

Description

  • Require nOfSides >= 3 for polygon helpers and regularPolygonArea to prevent degenerate polygon cases (changed in src/geometry.h and src/area_shape.h).
  • Make slopeOfLine explicitly reject vertical lines by asserting x1 != x2 to avoid division by zero (changed in src/geometry.h).
  • Tighten sideRightTriangle precondition to hypotenuse > sideA to prevent negative arguments to sqrt (changed in src/trigonometry.h).
  • Add boundary tests that cover the 3-side (triangle) case for diagonals and interior/exterior angle helper functions (changed in src/test/main.c).

Testing

  • Ran make test && ./debug/test and the full test suite completed with all tests passing.

Codex Task

@amartinsmg amartinsmg merged commit ebbd919 into main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant