Skip to content

chore: Gtest migration followups second pass - #7888

Open
godexsoft wants to merge 4 commits into
XRPLF:developfrom
godexsoft:chore/gtest-migration-followups-2
Open

chore: Gtest migration followups second pass#7888
godexsoft wants to merge 4 commits into
XRPLF:developfrom
godexsoft:chore/gtest-migration-followups-2

Conversation

@godexsoft

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Second follow-up PR clearing review comments left open on the merged test-migration PRs
(#7136, #7133, #7046, #7317, #7292). **Stacked on top of the first follow-up PR. **

Closes 10 more review threads with code and answers 4 without a change. Also splits
Buffer.cpp's single 230-line test into per-behaviour cases, taking the suite from
867 to 887 tests.

Context of Change

base_uint.cpp readability

  • 7136.10 — the two
    bool caught + try/catch blocks became
    EXPECT_THAT(lambda, ::testing::ThrowsMessage<E>(msg)). That keeps the message
    assertion the flag version was making, and gives a real failure message instead of
    Value of: caught / Actual: false. First gmock matcher in this TU, so <gmock/gmock.h>
    was added; the target already links GTest::gmock.
  • 7136.9 — renamed the
    single-letter locals in TEST_F(BaseUintTest, base_uint): uascending,
    vcomplement, wrehashed, zzero, texpectedByte, dbyte,
    hhasher, ncounter, xxored, tmpparsed, and the zero variants.
    Scoped to that function only — u, v and h also appear in testComparisons and
    Nonhash, where they mean different things.

IntrusiveShared.cpp style

  • 7136.19 — dropped
    braces on 9 single-statement if/for bodies. .clang-tidy sets
    readability-braces-around-statements.ShortStatementLines: 2, so one-line bodies are
    allowed unbraced, and clang-format leaves them alone.
  • 7136.13 — blank
    lines between TIBase's data members and its member functions.

Benchmarks

  • 7317.8 — the
    auto* b = RegisterBenchmark(...) local is gone; the calls are chained like the other
    registration site 13 lines below. That removes the "can b be null?" question rather
    than answering it with an assert.
  • 7317.11
    RunState::release() now also resets avgPayload, and carries a comment answering "why
    not assignments?": only swap-with-empty is guaranteed to hand back the capacity, and
    these pools are large.
  • 7317.12
    src/benchmarks added to the EXCLUDE list in cmake/XrplCov.cmake. Benchmarks are not
    run by the coverage job, so their lines could only ever report as uncovered.
  • 7317.25 — the
    rocksdb entry in backendConfigs() is now just type=rocksdb, with no tuning keys, so
    there is nothing left to drift. See "Before / After" below — this was worse than a
    drift risk.

libxrpl

  • 7133.9 — added
    Buffer::fill(std::uint8_t) and used it at its one call site, intToVuc in
    shamap/SHAMap.cpp. Covered by three new tests.

Buffer.cpp split into per-behaviour tests

TEST_F(BufferTest, buffer) was a single ~230-line test covering construction, equality,
copy, move, slice conversion and resize/clear in one body, with the distinctions carried by
bare { ... } blocks and comments. A failure anywhere reported as "BufferTest.buffer
failed".

It is now 18 named tests (default_constructed_is_empty, move_assign_empty_to_non_empty,
assignment_from_slice, …) plus the 3 fill tests. The shared sample data and reference
buffers moved into the fixture — kData, kHalf, emptyBuffer, firstHalf,
secondHalf, whole — which is what let each test shrink to the case it names. sane()
stays a static fixture helper.

This is the #7046.2
theme applied to one file: "this should be applied more thoroughly to tests migrated to
gtest — we still have some places where there is one test that internally splits into
blocks of tests."
The rest of the migrated suite still needs the same treatment.

One deliberate exception: equality_compares_contents keeps EXPECT_TRUE(a != b) rather
than EXPECT_NE, because the comparison operators are what is under test —
EXPECT_EQ/EXPECT_NE would route through the very operator== being verified. The
original carried a comment to this effect; it is now explicit about the reason.

API Impact

  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)

Buffer::fill() is a new method on xrpl::Buffer in include/xrpl/basics/Buffer.h. Purely
additive — no existing signature, layout or behaviour changes.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@godexsoft
godexsoft requested a review from mathbunnyru July 28, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant