Skip to content

Commit

Permalink
Add unit test covering multiline wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Jun 1, 2024
1 parent 706c17d commit 2e4521f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class ScreenBufferTests
TEST_METHOD(CopyDoubleWidthRectangularArea);

TEST_METHOD(DelayedWrapReset);
TEST_METHOD(MultilineWrap);

TEST_METHOD(EraseColorMode);

Expand Down Expand Up @@ -8323,6 +8324,39 @@ void ScreenBufferTests::DelayedWrapReset()
}
}

void ScreenBufferTests::MultilineWrap()
{
auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
auto& si = gci.GetActiveOutputBuffer().GetActiveBuffer();
auto& stateMachine = si.GetStateMachine();
const auto bufferAttr = si.GetTextBuffer().GetCurrentAttributes();
const auto width = si.GetTextBuffer().GetSize().Width();
const auto bottomRow = si.GetViewport().BottomInclusive();

// Starting on the bottom row.
si.GetTextBuffer().GetCursor().SetPosition({ 0, bottomRow });

// Write out enough text to wrap over four lines.
auto fourLines = std::wstring{};
fourLines += L"1";
fourLines += std::wstring(width - 1, L' ');
fourLines += L"2";
fourLines += std::wstring(width - 1, L' ');
fourLines += L"3";
fourLines += std::wstring(width - 1, L' ');
fourLines += L"4";
stateMachine.ProcessString(fourLines);

Log::Comment(L"Cursor should have moved down three rows");
VERIFY_ARE_EQUAL(bottomRow + 3, si.GetTextBuffer().GetCursor().GetPosition().y);

Log::Comment(L"Bottom four rows should have the content 1, 2, 3, and 4");
VERIFY_IS_TRUE(_ValidateLineContains(bottomRow + 0, L"1", bufferAttr));
VERIFY_IS_TRUE(_ValidateLineContains(bottomRow + 1, L"2", bufferAttr));
VERIFY_IS_TRUE(_ValidateLineContains(bottomRow + 2, L"3", bufferAttr));
VERIFY_IS_TRUE(_ValidateLineContains(bottomRow + 3, L"4", bufferAttr));
}

void ScreenBufferTests::EraseColorMode()
{
BEGIN_TEST_METHOD_PROPERTIES()
Expand Down

0 comments on commit 2e4521f

Please sign in to comment.