Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unit Test for Negative Hash Codes in HashTable and Note on TimSort Test Limitations #466

Commits on Aug 24, 2024

  1. Add Unit Test for Handling Negative Hash Codes in Custom HashTable Im…

    …plementation
    
    This commit introduces a new unit test and a supporting class to validate the handling of negative hash codes within our custom HashTable implementation.
    
    Changes:
    
    Unit Test: Test_NegativeHashKey_ReturnsCorrectValue
    
    Purpose: The test ensures that the HashTable correctly handles keys with negative hash codes. This scenario is important for robustness, as real-world use cases might involve hash codes that are negative, especially when custom GetHashCode implementations are involved.
    Implementation:
    A new HashTable is instantiated with a small initial capacity (4) to ensure hash collisions and proper management of entries.
    The test adds a key-value pair to the HashTable where the key (NegativeHashKey) intentionally generates a negative hash code.
    The test then asserts that the value can be correctly retrieved using a key that generates the same negative hash code, verifying the integrity of the HashTable under these conditions.
    Supporting Class: NegativeHashKey
    
    Purpose: The NegativeHashKey class is designed to simulate keys that produce negative hash codes, which is essential for triggering the edge case being tested.
    Implementation:
    The class contains an integer id used to generate a negative hash code by returning the negation of id in the GetHashCode method.
    The Equals method is overridden to ensure correct key comparison based on the id field, allowing the HashTable to manage and compare instances of NegativeHashKey accurately.
    Kalkwst committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    840fc9b View commit details
    Browse the repository at this point in the history
  2. Merge branch 'master' into bug/issue-465-CoverageIssueforHashTableand…

    …TimSorterReducingOverallCodeCoverage
    Kalkwst authored Aug 24, 2024
    Configuration menu
    Copy the full SHA
    af9eb69 View commit details
    Browse the repository at this point in the history

Commits on Sep 22, 2024

  1. Add TimSorterSettings for configuration and flexibility

    Refactored TimSorter to introduce a TimSorterSettings class, which encapsulates configuration parameters like minMerge and minGallop. This change separates configuration concerns from the sorting logic, improving code readability, maintainability, and testability.
    
    - Introduced TimSorterSettings class with minMerge and minGallop parameters.
    - Updated TimSorter constructor to accept a settings object for configuration.
    - Enhanced testability by allowing customizable settings for different test scenarios.
    - Simplified TimSorter’s constructor and reduced parameter clutter.
    - Facilitated future scalability by allowing easy extension of configuration options.
    
    This change adheres to the Single Responsibility Principle (SRP) and improves flexibility in sorting behavior across different contexts.
    Kalkwst committed Sep 22, 2024
    Configuration menu
    Copy the full SHA
    9439ee2 View commit details
    Browse the repository at this point in the history
  2. Extract galloping methods into static GallopingStrategy class

    - Moved galloping logic (GallopLeft, GallopRight, LeftRun, RightRun, FinalOffset) from TimSorter to a new GallopingStrategy static class.
    - Simplified the code by removing the interface and making all methods static since there's no need for instance-specific behavior.
    - The refactored GallopingStrategy class now encapsulates galloping functionality, improving modularity and testability.
    - Updated TimSorter to use GallopingStrategy for gallop operations, enhancing code clarity and separation of concerns.
    Kalkwst committed Sep 22, 2024
    Configuration menu
    Copy the full SHA
    d97a99f View commit details
    Browse the repository at this point in the history
  3. Merge branch 'master' into bug/issue-465-CoverageIssueforHashTableand…

    …TimSorterReducingOverallCodeCoverage
    siriak authored Sep 22, 2024
    Configuration menu
    Copy the full SHA
    d7034a8 View commit details
    Browse the repository at this point in the history