Skip to content

score/containers: Extend unit tests#264

Open
crimson11 wants to merge 1 commit into
eclipse-score:mainfrom
crimson11:mf_extend_container_tests
Open

score/containers: Extend unit tests#264
crimson11 wants to merge 1 commit into
eclipse-score:mainfrom
crimson11:mf_extend_container_tests

Conversation

@crimson11

Copy link
Copy Markdown
Contributor

Added test infrastructure for allocater/
pointer mocking/spying.
Added unit tests for handling of bounds-checking
support.

@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

@crimson11 crimson11 force-pushed the mf_extend_container_tests branch from e8fe2ce to 2052bf6 Compare June 10, 2026 21:21
@crimson11 crimson11 requested a deployment to workflow-approval June 10, 2026 21:21 — with GitHub Actions Waiting
@crimson11 crimson11 requested a deployment to workflow-approval June 10, 2026 21:21 — with GitHub Actions Waiting
Added test infrastructure for allocater/
pointer mocking/spying.
Added unit tests for handling of bounds-checking
support.
@crimson11 crimson11 force-pushed the mf_extend_container_tests branch from 2052bf6 to 7da90c1 Compare June 10, 2026 21:32
@crimson11 crimson11 temporarily deployed to workflow-approval June 10, 2026 21:32 — with GitHub Actions Inactive
@crimson11 crimson11 temporarily deployed to workflow-approval June 10, 2026 21:32 — with GitHub Actions Inactive
@4og 4og requested a review from Copilot June 12, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends score/containers unit test capabilities by introducing a new “mockable” allocator/pointer infrastructure that can spy on fancy-pointer operations (useful for validating bounds-checking related behavior), and adds targeted tests for NonRelocatableVector pointer interactions.

Changes:

  • Added MockableAllocator, MockablePointer, and PointerSpyMock test utilities (plus an RAII guard) to support pointer-operation spying in tests.
  • Replaced/removes the previous custom_allocator_mock test helper and updates Bazel targets/deps accordingly.
  • Added new NonRelocatableVector tests that assert first/last element address checks are performed via fancy-pointer operations.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
score/containers/test/pointer_spy_mock.h Adds gMock-based spy interface for recording pointer operations.
score/containers/test/pointer_spy_mock.cpp TU wrapper include for the new spy header.
score/containers/test/mockable_pointer.h Adds a fancy-pointer wrapper that can report operations to the spy.
score/containers/test/mockable_pointer.cpp TU wrapper include for the new mockable pointer header.
score/containers/test/mockable_pointer_mock_guard.h Adds RAII guard to set/clear the global spy pointer during a scope.
score/containers/test/mockable_pointer_mock_guard.cpp TU wrapper include for the new guard header.
score/containers/test/mockable_allocator.h Adds allocator wrapper returning MockablePointer<T> for allocator-aware container tests.
score/containers/test/mockable_allocator.cpp Updates TU wrapper to include mockable_allocator.h.
score/containers/test/custom_allocator_mock.h Removes legacy custom allocator mock helper.
score/containers/test/BUILD Replaces custom_allocator_mock with mockable_allocator library target and updates sources/headers.
score/containers/non_relocatable_vector.h Removes an unused <iostream> include.
score/containers/non_relocatable_vector_test.cpp Adds pointer-interaction tests using the new spy infrastructure.
score/containers/dynamic_array_test.cpp Removes legacy custom allocator mock include and adjusts comment formatting.
score/containers/BUILD Switches unit tests from custom_allocator_mock to mockable_allocator dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +263 to +264
score::memory::shared::test::MyMemoryResource memory_resource_{};
std::unique_ptr<NonRelocatableVector<ElementType, Allocator>> unit_{nullptr};
Comment on lines +57 to +61
/// \brief Clear the spy mock. Operations revert to pure pointer behavior (no recording).
static void ClearMock() noexcept
{
mock_ = nullptr;
}
Comment on lines +28 to +46
template <typename T>
class MockablePointerMockGuard
{
public:
explicit MockablePointerMockGuard(PointerSpyMock<T>* mock) noexcept
{
MockablePointer<T>::SetMock(mock);
}

~MockablePointerMockGuard() noexcept
{
MockablePointer<T>::ClearMock();
}

MockablePointerMockGuard(const MockablePointerMockGuard&) = delete;
MockablePointerMockGuard& operator=(const MockablePointerMockGuard&) = delete;
MockablePointerMockGuard(MockablePointerMockGuard&&) = delete;
MockablePointerMockGuard& operator=(MockablePointerMockGuard&&) = delete;
};
Comment on lines +28 to +29
/// By default, MockablePointer behaves identically to a raw pointer. All arithmetic, compare and dereference
/// operations are forwarded to the underlying raw pointer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants