Skip to content

test: GoogleTest suite that checks every reference page's claims #41

Closed

Description

@homer6

The snippet checker proves every ```cpp block compiles; nothing proves the examples do what the pages say (printed output, values in comments, which overload is chosen, iterator invalidation rules, exception behaviour). Several wrong comments were only found by running code by hand (e.g. localization.md promised `1,234,567.89` but printed `1.23457e+06`; a wrong `byteswap` value).

Build a full GoogleTest unit-test suite that turns the reference's claims into assertions.

Proposed

  • tests/ with a CMake project (CMakePresets.json: gcc-15, clang-22-libc++, and a Docker gcc-16 preset for C++26 features), fetching GoogleTest via FetchContent (pinned release tag).
  • One test file per reference page, mirroring docs/examples/ (tests/containers/vector_test.cpp, …). Each test names the page and section it checks, e.g. TEST(Vector, PushBackInvalidatesOnReallocation).
  • Every concrete claim on a page becomes an assertion: documented outputs (EXPECT_EQ on formatted strings), values in comments, static_assert for type/trait claims, EXPECT_THROW for documented exceptions, invalidation/complexity claims where observable. Behaviour that's implementation-defined is asserted per toolchain or skipped with a reason (GTEST_SKIP).
  • Features missing on a toolchain are gated on feature-test macros (__cpp_lib_*) and reported as skipped, not silently dropped.
  • Wrong claims found by the tests get fixed on the page in the same PR, and listed.
  • A tools/run_tests.sh (no CI — Actions is disabled; run locally) and a section in CLAUDE.md/README on running it.

Split

One sub-issue/PR per area, matching the snippet work: containers + strings + text-processing; algorithms + ranges + iterators + utilities + concepts; memory … diagnostics + language-support; language; plus the harness (CMake, presets, GoogleTest, runner) first.

Acceptance

  • cmake --workflow --preset gcc-15 builds and runs all tests green; Clang 22 + libc++ green or skipped with reasons; GCC 16 (Docker) runs the C++26 tests.
  • Every reference page has a test file; the README index notes coverage.

Sub-issues

This issue closes when all sub-issues are delivered.

Activity

  1. self-assigned this
    on Oct 31, 2026
  2. homer6 commented on Oct 31, 2026

    @homer6
    OwnerAuthor

    All sub-issues delivered:

    Sub-issue PR State
    #43 harness (CMake, presets, support helpers, runner) #52 merged
    #44 containers, strings, text-processing #72 merged
    #45 algorithms, ranges, iterators, utilities, concepts #67 merged
    #46 memory … diagnostics, language support, named requirements #78 open for review
    #47 language #73 open for review (needs a rebase)

    What changed

    Why

    • The snippet checker proves blocks compile; the tests prove the pages' claims at run time on GCC 15, Clang 22 + libc++ and GCC 16.

    Still open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions