-
Notifications
You must be signed in to change notification settings - Fork 23
Claude/add stl container tests #220
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
Claude/add stl container tests #220
Conversation
…collision bug - Add tests for hash-based lookups in unordered_map (find, count, at) - Add tests for membership checks in unordered_set (count, find) - Add lookup tests for wrapped class containers (map, unordered_map, unordered_set) - Fix bug where loop variables 'key'/'value' could shadow function parameters of the same name in StdMapConverter and StdUnorderedMapConverter The new tests verify that dict/set operations actually use hashing for O(1) lookups rather than just iterating through all items.
- Update Item hash function to combine both value_ and name_ members - Add test verifying that items with same value_ but different name_ are treated as distinct (tests proper multi-field hashing)
- Rename test files: new_stl_test.* -> cpp17_stl_test.* - Rename test module: test_code_generator_new_stl.py -> test_code_generator_cpp17_stl.py - Rename class: NewSTLTest -> Cpp17STLTest - Add user-centric documentation with container mappings and usage examples - Document Python types for each C++ container (dict, set, list, T|None, bytes) - Include example syntax for passing/receiving containers - Document compilation requirements (C++17)
- Add wrap-hash annotation and operator==/!= to Item class for Python hashability - Add getHashValue() method that combines both value_ and name_ for proper hashing - Update tests to use Python d[key] and 'in' operator instead of iteration - Remove unnecessary C++ lookup functions (lookupMapIntToItem, hasKeyMapIntToItem, etc.) - Tests now verify that wrapped classes work correctly as Python dict keys This enables Python code like: result = t.createMapItemToInt(3) item = m.Item(1) assert result[item] == 10 # Direct Python dict lookup!
|
Warning Rate limit exceeded@timosachsenberg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 40 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe changes add hash and equality comparison support to the wrapped Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| # Direct Python dict lookup with wrapped class key - NOT iteration! | ||
| key0 = m.Item(0) | ||
| key1 = m.Item(1) | ||
| key2 = m.Item(2) | ||
| assert result[key0] == 0 | ||
| assert result[key1] == 10 | ||
| assert result[key2] == 20 | ||
|
|
||
| # Test 'in' operator | ||
| assert key1 in result | ||
| missing = m.Item(999) | ||
| assert missing not in result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpfeuffer like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isso!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
darauf nen Caipi. :) Danke!
Test verifies that Python dict d[key] lookup works correctly when keys are wrapped classes with multiple members (value_ and name_). Both members must match for the lookup to succeed.
Two-member hash function test
Tests that hash uses both value_ AND name_ members:
item_alice = m.Item(100, b"alice")
item_bob = m.Item(100, b"bob") # Same value_, different name_
items = {item_alice, item_bob}
assert len(items) == 2 # Both are distinct!
Bug fix: Variable name collision
Fixed ConversionProvider.py where for key, value in m.items(): could overwrite function parameters named key.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.