Skip to content

Conversation

@kail-is
Copy link
Contributor

@kail-is kail-is commented Sep 7, 2025

Summary

Add DoubleCombinableArbitrary for customizable Double value generation following existing CombinableArbitrary pattern with Double-specific enhancements including precision control and special value handling.

Description

Implemented DoubleCombinableArbitrary to provide easy customization of Double value generation, addressing the lack of double-specific constraints in current API with enhanced domain-specific methods and comprehensive special value support.

Added components:

  • DoubleCombinableArbitrary interface with standard constraint methods and domain-specific extensions
  • DoubleCombinableArbitraryDelegator for filter/null injection operations
  • JqwikDoubleCombinableArbitrary implementation
  • KotestDoubleCombinableArbitrary implementation for Kotest integration
  • Factory method CombinableArbitrary.doubles()

Key features:

  • Standard numeric constraints: .positive(), .negative(), .nonZero(), .withRange(double, double)
  • Double-specific precision control: .withPrecision(int) method for decimal place specification
  • Double-specific value type methods: .finite(), .infinite(), .nan() for handling special floating-point values
  • Domain-specific methods:
    • .percentage() - generates values 0-100 for percentage representation
    • .score() - generates values 0-100 for scoring systems
    • .normalized() - generates values 0.0-1.0 for probability and ratio calculations
  • Critical special value injection methods:
    • .withSpecialValue(double) - injects custom edge case values for comprehensive testing coverage
    • .withStandardSpecialValues() - automatically injects Double.NaN, Double.MIN_VALUE, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY for robust floating-point edge case testing
  • Last-method-wins behavior for constraint precedence (domain-specific methods override previous constraints)
  • Full integration with existing filter/map/unique operations

Usage example:

Double nonZeroDouble = CombinableArbitrary.doubles().nonZero().combined();
Double precisionDouble = CombinableArbitrary.doubles().withPrecision(3).combined();
Double positiveDouble = CombinableArbitrary.doubles().withRange(1.0, 1000.0).positive().combined();
Double normalizedDouble = CombinableArbitrary.doubles().normalized().combined();
Double percentageDouble = CombinableArbitrary.doubles().percentage().combined();
Double edgeCaseDouble = CombinableArbitrary.doubles().withStandardSpecialValues().combined();

How Has This Been Tested?

Added comprehensive test suite in DoubleCombinableArbitraryTest:

  • Basic constraint validation (positive, negative, nonZero, finite, infinite, nan)
  • Range constraint testing with various boundaries and precision specifications
  • Domain-specific constraint testing (percentage, score, normalized)
  • Precision control validation for decimal place accuracy
  • Special value injection testing for edge case coverage
  • Method chaining and last-method-wins precedence verification
  • Integration with filter, map, injectNull, unique operations
  • Complex constraint combinations and floating-point operation safety
  • Domain boundary validation (ensuring normalized values are 0.0-1.0, percentage values are 0-100, etc.)
  • Cross-platform compatibility testing with both Jqwik and Kotest implementations

Is the Document updated?

Documentation will be updated to include DoubleCombinableArbitrary usage examples alongside existing numeric arbitrary types, with special emphasis on precision control, special value handling, and domain-specific constraint methods for common Double use cases in scientific and business applications.

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.

1 participant