Skip to content

Commit 934a06d

Browse files
committed
Fix unit tests
1 parent 3c5c3d4 commit 934a06d

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

src/host/ut_host/TextBufferTests.cpp

+27-20
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TextBufferTests
147147

148148
TEST_METHOD(TestBurrito);
149149
TEST_METHOD(TestOverwriteChars);
150-
TEST_METHOD(TestRowWrite);
150+
TEST_METHOD(TestRowReplaceText);
151151

152152
TEST_METHOD(TestAppendRTFText);
153153

@@ -2047,46 +2047,53 @@ void TextBufferTests::TestOverwriteChars()
20472047
#undef complex1
20482048
}
20492049

2050-
void TextBufferTests::TestRowWrite()
2050+
void TextBufferTests::TestRowReplaceText()
20512051
{
20522052
til::size bufferSize{ 10, 3 };
20532053
UINT cursorSize = 12;
20542054
TextAttribute attr{ 0x7f };
20552055
TextBuffer buffer{ bufferSize, attr, cursorSize, false, _renderer };
20562056
auto& row = buffer.GetRowByOffset(0);
2057-
std::wstring_view str;
2058-
til::CoordType pos = 0;
2057+
RowWriteState state;
20592058

20602059
#define complex L"\U0001F41B"
20612060

20622061
// Not enough space -> early exit
2063-
str = complex;
2064-
pos = row.Write(2, 2, str);
2065-
VERIFY_ARE_EQUAL(2, pos);
2066-
VERIFY_ARE_EQUAL(complex, str);
2062+
state.text = complex;
2063+
state.columnBegin = 2;
2064+
state.columnLimit = 2;
2065+
row.ReplaceText(state);
2066+
VERIFY_ARE_EQUAL(2, state.columnEndDirty);
2067+
VERIFY_ARE_EQUAL(complex, state.text);
20672068
VERIFY_ARE_EQUAL(L" ", row.GetText());
20682069

20692070
// Writing with the exact right amount of space
2070-
str = complex;
2071-
pos = row.Write(2, 4, str);
2072-
VERIFY_ARE_EQUAL(4, pos);
2073-
VERIFY_ARE_EQUAL(L"", str);
2071+
state.text = complex;
2072+
state.columnBegin = 2;
2073+
state.columnLimit = 4;
2074+
row.ReplaceText(state);
2075+
VERIFY_ARE_EQUAL(4, state.columnEndDirty);
2076+
VERIFY_ARE_EQUAL(L"", state.text);
20742077
VERIFY_ARE_EQUAL(L" " complex L" ", row.GetText());
20752078

20762079
// Overwrite a wide character, but with not enough space left
2077-
str = complex complex;
2078-
pos = row.Write(0, 3, str);
2080+
state.text = complex complex;
2081+
state.columnBegin = 0;
2082+
state.columnLimit = 3;
2083+
row.ReplaceText(state);
20792084
// It's not quite clear what Write() should return in that case,
20802085
// so this simply asserts on what it happens to return right now.
2081-
VERIFY_ARE_EQUAL(4, pos);
2082-
VERIFY_ARE_EQUAL(complex, str);
2086+
VERIFY_ARE_EQUAL(4, state.columnEndDirty);
2087+
VERIFY_ARE_EQUAL(complex, state.text);
20832088
VERIFY_ARE_EQUAL(complex L" ", row.GetText());
20842089

20852090
// Various text, too much to fit into the row
2086-
str = L"a" complex L"b" complex L"c" complex L"foo";
2087-
pos = row.Write(1, til::CoordTypeMax, str);
2088-
VERIFY_ARE_EQUAL(10, pos);
2089-
VERIFY_ARE_EQUAL(L"foo", str);
2091+
state.text = L"a" complex L"b" complex L"c" complex L"foo";
2092+
state.columnBegin = 1;
2093+
state.columnLimit = til::CoordTypeMax;
2094+
row.ReplaceText(state);
2095+
VERIFY_ARE_EQUAL(10, state.columnEndDirty);
2096+
VERIFY_ARE_EQUAL(L"foo", state.text);
20902097
VERIFY_ARE_EQUAL(L" a" complex L"b" complex L"c" complex, row.GetText());
20912098

20922099
#undef complex

0 commit comments

Comments
 (0)