Skip to content

improve flat_map specific coverage for GH-6045#6247

Open
mahtab04 wants to merge 1 commit intomicrosoft:mainfrom
mahtab04:gh-6045/flat-map-comprehensive-tests
Open

improve flat_map specific coverage for GH-6045#6247
mahtab04 wants to merge 1 commit intomicrosoft:mainfrom
mahtab04:gh-6045/flat-map-comprehensive-tests

Conversation

@mahtab04
Copy link
Copy Markdown

Fixes GH-6045.

This PR adds comprehensive test coverage for flat_map member functions:

  • operator[]
  • at() (both success and exception cases)
  • emplace()
  • try_emplace() (including hint and transparent forms)
  • replace()

@mahtab04 mahtab04 requested a review from a team as a code owner April 11, 2026 17:10
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Apr 11, 2026
@mahtab04
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@mahtab04 mahtab04 changed the title improve flat_map-specific coverage for GH-6045 improve flat_map specific coverage for GH-6045 Apr 11, 2026
@StephanTLavavej StephanTLavavej added test Related to test code flat_meow C++23 container adaptors labels Apr 11, 2026
@StephanTLavavej StephanTLavavej self-assigned this Apr 12, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member

I'll try to review this soon but I am absolutely slammed with work right now so it might take a while.

@StephanTLavavej StephanTLavavej requested a review from Copilot April 29, 2026 06:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted tests to increase coverage for std::flat_map element access and insertion/modification APIs in the STL test suite, addressing GH-6045.

Changes:

  • Added new test functions for operator[], at() (success + throwing), emplace/emplace_hint, try_emplace (including hint + transparent forms), and replace().
  • Hooked the new tests into run_normal_tests() so they execute in the standard test pass.
Show a summary per file
File Description
tests/std/tests/P0429R9_flat_map/test.cpp Adds new flat_map tests for access/modifier APIs and wires them into the normal test run.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment on lines +1450 to +1454
flat_map<int, string> fm;
fm[1] = "hello";
assert(fm[1] == "hello");
assert(fm[2].empty());
assert(fm.size() == 2);
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

This test uses std::string but the file doesn't include <string> directly. Relying on transitive includes (e.g., via other standard headers) is brittle and can break when headers change; add an explicit #include <string> in the include list for this test file.

Copilot uses AI. Check for mistakes.
Comment on lines +1504 to +1508
try {
(void) fm.at(42);
} catch (const out_of_range&) {
caught = true;
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

This code catches out_of_range, but the file doesn't include <stdexcept> directly. Please add an explicit #include <stdexcept> to avoid depending on transitive includes for the exception type declaration.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flat_meow C++23 container adaptors test Related to test code

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

<flat_map>: Missing test coverage

3 participants