score/containers: Extend test cases#318
Open
crimson11 wants to merge 1 commit into
Open
Conversation
|
The created documentation from the pull request is available at: docu-html |
Unit test have been extended to also verify begin/end pointer dereferencing to support bounds-checking.
f3fa393 to
b7cd6b3
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the NonRelocatableVector unit tests to explicitly verify that data(), begin(), and end() exercise begin/end address resolution (via to_address / operator->()), which is important for allocator pointer types that perform bounds-checking. It also replaces the previous custom allocator mock approach with a spy-based “mockable pointer/allocator” test utility.
Changes:
- Added
MockablePointer/MockableAllocatortest utilities plus aPointerSpyMockand RAII guard to record pointer-ops without altering pointer arithmetic behavior. - Extended
non_relocatable_vector_test.cppwith new pointer-interaction tests fordata(),begin(), andend(). - Cleaned up test/build plumbing: removed the old
custom_allocator_mockand updated Bazel targets; removed an unused<iostream>include.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| score/containers/test/pointer_spy_mock.h | New gMock spy interface for recording pointer operations (arrow/deref/arithmetic). |
| score/containers/test/pointer_spy_mock.cpp | TU wrapper including the new spy header for Bazel compilation. |
| score/containers/test/mockable_pointer.h | New fancy-pointer wrapper around T* that forwards real behavior while optionally recording operations. |
| score/containers/test/mockable_pointer.cpp | TU wrapper including the new mockable pointer header for Bazel compilation. |
| score/containers/test/mockable_pointer_mock_guard.h | RAII helper to register/unregister the pointer spy during scoped test sections. |
| score/containers/test/mockable_pointer_mock_guard.cpp | TU wrapper including the new guard header for Bazel compilation. |
| score/containers/test/mockable_allocator.h | New allocator wrapper returning MockablePointer<T> to enable spy-based verification in containers. |
| score/containers/test/mockable_allocator.cpp | Updated TU wrapper to include mockable_allocator.h. |
| score/containers/test/custom_allocator_mock.h | Removed old allocator mock header that is no longer referenced. |
| score/containers/test/BUILD | Replaced custom_allocator_mock library with mockable_allocator library and updated sources/headers. |
| score/containers/non_relocatable_vector.h | Removed unused <iostream> include. |
| score/containers/non_relocatable_vector_test.cpp | Added new tests validating begin/end address resolution via pointer-operation spying. |
| score/containers/dynamic_array_test.cpp | Removed now-unused include and reformatted a long comment line. |
| score/containers/BUILD | Updated test deps to drop custom_allocator_mock and add mockable_allocator where needed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unit test have been extended to also verify
begin/end pointer dereferencing to support
bounds-checking.