[PR #8715] Add some tests for TextBuffer::Reflow #27278

Closed
opened 2026-01-31 09:21:01 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/8715

State: closed
Merged: Yes


This is by no means comprehensive. It will be unmarked as draft when it
is more comprehensive.

This pull request adds some tests for resizing a TextBuffer and
reflowing its contents. Each test takes the form of an initial state and
a number of buffers of different sizes. The initial state is used to
seed the first TextBuffer, and the subsequent buffers are only used to
compare.

I manually reimplemented some of the DBCS logic to ensure that the
buffers contain exactly what they're supposed to. I know this is
non-ideal. After some of the CharRow changes in #8446 land, this will
need to be updated.

There's a cool bit of TAEF gore in here: the IDataSource. An IDataSource
allows us to programmatically return test cases. It's a code-only
version of its support for parameterized tests of the form Data:x = {0, 1, 2} .

The only downsides are...

  1. It looks like COM (it is not using COM under the hood, just the COM
    ABI)
  2. Property values must be returned as strings.

To best support rich test types, I used IDataSource to produce a lit of
array indices
and nothing more. The test is run once for array member,
and it is the test's responsibility to look up the object to which that
index refers.

Works great though! Each reflow test is its own unit, and a failure in
an earlier reflow test will not tank a later one.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/8715 **State:** closed **Merged:** Yes --- This is by no means comprehensive. It will be unmarked as draft when it is more comprehensive. This pull request adds some tests for resizing a TextBuffer and reflowing its contents. Each test takes the form of an initial state and a number of buffers of different sizes. The initial state is used to seed the first TextBuffer, and the subsequent buffers are only used to compare. I manually reimplemented some of the DBCS logic to ensure that the buffers contain _exactly_ what they're supposed to. I know this is non-ideal. After some of the CharRow changes in #8446 land, this will need to be updated. There's a cool bit of TAEF gore in here: the IDataSource. An IDataSource allows us to programmatically return test cases. It's a code-only version of its support for parameterized tests of the form `Data:x = {0, 1, 2}` . The only downsides are... 1. It looks like COM (it is not using COM under the hood, just the COM ABI) 2. Property values must be returned as strings. To best support rich test types, I used IDataSource to produce _a lit of array indices_ and nothing more. The test is run once for array member, and it is the test's responsibility to look up the object to which that index refers. Works great though! Each reflow test is its own unit, and a failure in an earlier reflow test will not tank a later one.
claunia added the pull-request label 2026-01-31 09:21:01 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27278