Skip to content

test: GoogleTest suites — algorithms, ranges, iterators, utilities, concepts #45

Closed

Description

@homer6

Part of #41. Depends on #43. Write GoogleTest tests for every page in: docs/examples/algorithms, ranges, iterators, utilities, concepts.

  • One tests/<area>/<page>_test.cpp per page; test names reference the page section (TEST(Vector, ReserveDoesNotChangeSize)).
  • Every concrete claim on the page becomes an assertion: documented output (capture and EXPECT_EQ), values in comments, static_assert for type/trait claims, EXPECT_THROW for documented exceptions, invalidation and complexity claims where observable.
  • Implementation-defined behaviour: assert per toolchain or GTEST_SKIP with the reason. Missing library features: skip via feature-test macros, never silently drop.
  • If a test shows a page is wrong, fix the page in the same PR and list each fix.
  • Run on GCC 15 and Clang 22 + libc++; C++26 tests on Docker GCC 16.

Acceptance: every page in these folders has a test file; all presets green or skipped with reasons; page fixes listed in the PR.

Activity

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

    @homer6
    OwnerAuthor

    Delivered in #67.

    What changed

    • tests/algorithms/: new tests for execution-and-ranges, modifying, non-modifying, numeric and partition-heap-minmax. sorting-searching_test.cpp is extended from 4 to 11 tests. They cover:
      • results on each page's own inputs
      • complexity, by counting comparisons: nth_element is linear, lower_bound logarithmic, make_heap at most 3n
      • stability of stable_sort and stable_partition
      • the dangling and projection claims
      • "won't compile" claims, as negated concepts
      • a death test showing that an exception thrown from an element op terminates
    • tests/ranges/: new tests for factories and range-concepts. views_test.cpp is extended from 3 to 13 tests and covers laziness, filter_view caching begin(), and the C++23 adaptors.
    • tests/iterators/: new tests for adaptors and categories. operations_test.cpp is extended from 5 to 8 tests; the new ones check how many steps advance takes per category and that stream iterators consume their input.
    • tests/concepts/standard-concepts_test.cpp is extended from 3 to 9 tests.
    • tests/utilities/: new tests for any, bitset, expected, functional, pair, tuple, utility and variant. optional_test.cpp is extended from 5 to 9 tests.
    • Page fixes:
      • algorithms/execution-and-ranges.md: an exception thrown from an element op calls std::terminate under every standard policy, seq included, not only the parallel ones.
      • algorithms/sorting-searching.md: partial_sort sorts the 10 smallest, not the "top 10".
      • ranges/views.md: the Gotchas bullet now names the C++23 adaptors that libc++ in Clang 22 still lacks.
      • utilities/bitset.md: the to_string() comment had a wrong value. It is now "11100101".

    Why

    • This covers the whole issue: every page in the five folders has a test file, and every concrete claim is an assertion. That includes the observable stability and complexity claims.
    • Run with tools/run_tests.sh after rebasing on origin/main. On gcc-15, clang-22 and gcc-16 (Docker) the summary line was 100% tests passed, 0 tests failed out of 270.
    • On clang-22 / libc++, features the library lacks skip and name the macro: __cpp_lib_execution, __cpp_lib_parallel_algorithm, __cpp_lib_move_only_function, and __cpp_lib_ranges_{enumerate,chunk,stride,as_const}.
    • The snippet checker against the baseline exits 0.

    Still open

    • Some claims are hard compile errors that a requires expression can't detect: get<T> with a repeated type, a visitor that doesn't handle every alternative, and std::function from a move-only callable. I checked them by hand only.
    • Toolchain-dependent claims are not asserted: floating-point reordering by reduce, small-buffer and allocation behaviour, and the parallel backend.
    • The UB claims are not executed.
    • docs(examples): bring the thinnest library pages up to the house skeleton #57 is expanding bitset.md, pair.md and any.md. Their tests may need updating after it lands.
  3. homer6 commented on Oct 31, 2026

    @homer6
    OwnerAuthor

    Merged in #67 (d98d733) on the owner's approval.

    What changed

    • Since the PR was opened: rebased onto main. No other changes.

    Why

    • Approved by the owner; checks re-run after the rebase (snippets, links).

    Still open

    • Nothing for this issue.
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