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

Feature/issue 465 coverage for hash table and tim sorter #500

Conversation

gmottajr
Copy link
Contributor

@gmottajr gmottajr commented Dec 4, 2024

Added tests for HashTable to improve coverage of key behaviors

  1. **Add_ShouldTriggerResize_WhenThresholdExceeded:** Verifies that the HashTable triggers a resize when the number of elements exceeds the initial capacity.
    
  2. **Add_ThrowsException_WhenKeyIsDefault:** Ensures that adding a key with the default value (e.g., 0 for integers) throws an ArgumentNullException, as per the Add method’s validation.
    
  3. **Add_ThrowsException_WhenValueIsDefault:** Verifies that adding a value with the default value (e.g., null for reference types) throws an ArgumentNullException.
    
  4. **Add_StoresValueCorrectly:** Confirms that values are correctly stored and can be retrieved via the key after an Add operation.
    
  5. **Get_ReturnsCorrectValue_ForExistingKey:** Ensures that the correct value is returned when querying for an existing key.
    
  6. **Get_ThrowsException_WhenKeyDoesNotExist:** Verifies that accessing a non-existent key throws a KeyNotFoundException, maintaining expected behavior.
    
  7. **Capacity_Increases_WhenResizeOccurs:** Checks that the HashTable increases its capacity when the number of items exceeds the threshold, ensuring proper resizing.
    

These tests aim to cover edge cases, resizing logic, and ensure correct behavior of the Add and Get methods, improving overall robustness and stability.

  • [X ] I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • [X ] I have added tests that prove my fix is effective or that my feature works
  • [X ] New and existing unit tests pass locally with my changes
  • [X ] Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

GersonJr and others added 6 commits November 25, 2024 22:57
    Add_ShouldTriggerResize_WhenThresholdExceeded: Verifies that the HashTable triggers a resize when the number of elements exceeds the initial capacity.
    Add_ThrowsException_WhenKeyIsDefault: Ensures that adding a key with the default value (e.g., 0 for integers) throws an ArgumentNullException, as per the Add method’s validation.
    Add_ThrowsException_WhenValueIsDefault: Verifies that adding a value with the default value (e.g., null for reference types) throws an ArgumentNullException.
    Add_StoresValueCorrectly: Confirms that values are correctly stored and can be retrieved via the key after an Add operation.
    Get_ReturnsCorrectValue_ForExistingKey: Ensures that the correct value is returned when querying for an existing key.
    Get_ThrowsException_WhenKeyDoesNotExist: Verifies that accessing a non-existent key throws a KeyNotFoundException, maintaining expected behavior.
    Capacity_Increases_WhenResizeOccurs: Checks that the HashTable increases its capacity when the number of items exceeds the threshold, ensuring proper resizing.

These tests aim to cover edge cases, resizing logic, and ensure correct behavior of the Add and Get methods, improving overall robustness and stability.
@gmottajr gmottajr requested a review from siriak as a code owner December 4, 2024 20:32
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.16%. Comparing base (0ef9849) to head (41a421f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #500      +/-   ##
==========================================
+ Coverage   95.11%   95.16%   +0.04%     
==========================================
  Files         267      267              
  Lines       10848    10848              
  Branches     1527     1527              
==========================================
+ Hits        10318    10323       +5     
+ Misses        403      400       -3     
+ Partials      127      125       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

You can also see in coverage report that coverage also fluctuates in FastSearcher
image

@siriak siriak merged commit 046f26e into TheAlgorithms:master Dec 4, 2024
4 checks passed
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.

2 participants