improve flat_map specific coverage for GH-6045#6247
improve flat_map specific coverage for GH-6045#6247mahtab04 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…lace(), try_emplace(), and replace()
|
@microsoft-github-policy-service agree |
|
I'll try to review this soon but I am absolutely slammed with work right now so it might take a while. |
There was a problem hiding this comment.
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), andreplace(). - 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
| flat_map<int, string> fm; | ||
| fm[1] = "hello"; | ||
| assert(fm[1] == "hello"); | ||
| assert(fm[2].empty()); | ||
| assert(fm.size() == 2); |
There was a problem hiding this comment.
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.
| try { | ||
| (void) fm.at(42); | ||
| } catch (const out_of_range&) { | ||
| caught = true; | ||
| } |
There was a problem hiding this comment.
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.
Fixes GH-6045.
This PR adds comprehensive test coverage for flat_map member functions: