Skip to content

Conversation

cybersmeashish
Copy link
Contributor

Overview

This PR adds comprehensive test coverage for the Redis command, covering various edge cases and scenarios that were not previously tested.

Test Cases Added

  • Negative increment values - Testing decrements using IncrByFloat
  • Zero increment - Verifying it returns the current value without modification
  • High precision floating point operations - Testing precision with small increments
  • Non-existent key behavior - Ensuring it starts from 0 as expected
  • Integer values stored as strings - Testing conversion from integer strings
  • Scientific notation - Both positive and negative scientific notation
  • Error handling - Testing behavior with non-numeric values
  • Very large numbers - Testing near float64 limits
  • Very small numbers - Testing precision near zero

Technical Details

  • Uses Gomega's matcher for proper floating point comparisons
  • Handles precision issues appropriately with tolerance values
  • Tests both success and error scenarios
  • Follows existing test patterns and conventions

Benefits

  • Improves test coverage for the IncrByFloat command
  • Ensures robust behavior across different numeric formats
  • Catches potential edge case bugs
  • Provides better confidence in floating point operations

Testing

The test follows the existing Ginkgo/Gomega testing framework used throughout the project and integrates seamlessly with the current test suite.

All test cases are designed to be deterministic and handle floating point precision appropriately.

This commit adds extensive test coverage for the IncrByFloat Redis command,
covering various edge cases and scenarios that were not previously tested.

Test cases added:
- Negative increment values
- Zero increment (should return current value)
- High precision floating point operations
- Non-existent key behavior (should start from 0)
- Integer values stored as strings
- Scientific notation (both positive and negative)
- Error handling for non-numeric values
- Very large numbers (near float64 limits)
- Very small numbers (near zero precision)

These tests ensure robust behavior of the IncrByFloat command across
different numeric formats and edge conditions, improving the overall
reliability and test coverage of the go-redis library.

The tests use Gomega's BeNumerically matcher for floating point
comparisons to handle precision issues appropriately.
Copy link
Member

@ndyakov ndyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution.

@ndyakov ndyakov merged commit ff4d63e into redis:master Aug 18, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants