Skip to content

Conversation

@continue
Copy link

@continue continue bot commented Oct 21, 2025

Summary

This PR adds complete unit test coverage for all functions in src/utils/math.ts, including comprehensive edge case testing.

Changes

  • ✅ Added 60+ test cases covering all 8 math utility functions
  • ✅ Complete test coverage for: add, subtract, multiply, divide, factorial, isPrime, average, findMax
  • ✅ Fixed factorial function to throw error for negative inputs
  • ✅ Documented behavior for edge cases

Edge Cases Tested

Division by Zero

  • divide(10, 0) returns Infinity
  • divide(-10, 0) returns -Infinity
  • divide(0, 0) returns NaN

Factorial Negative Numbers

  • Now throws Error for negative inputs
  • Prevents stack overflow from infinite recursion

Empty Arrays

  • average([]) returns NaN (division by zero)
  • findMax([]) returns -Infinity (Math.max behavior)

Test Coverage Includes

  • ✅ Positive numbers
  • ✅ Negative numbers
  • ✅ Zero values
  • ✅ Decimal numbers
  • ✅ Empty arrays
  • ✅ Single element arrays
  • ✅ Mixed positive/negative values
  • ✅ Error conditions

This agent session was co-authored by bekah-hawrot-weigel and Continue.

- Added complete test coverage for all functions in src/utils/math.ts
- Included edge case tests for division by zero (Infinity/-Infinity/NaN)
- Added tests for negative numbers in factorial (now throws error)
- Added tests for empty arrays in average (returns NaN)
- Added tests for empty arrays in findMax (returns -Infinity)
- Fixed factorial function to throw error for negative inputs
- Tests cover positive, negative, zero, decimal, and edge cases
- Total of 60+ test cases across 8 function test suites

Co-authored-by: Username <[email protected]>

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <[email protected]>
@BekahHW BekahHW closed this Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants