@@ -147,7 +147,7 @@ class TextBufferTests
147
147
148
148
TEST_METHOD (TestBurrito);
149
149
TEST_METHOD (TestOverwriteChars);
150
- TEST_METHOD (TestRowWrite );
150
+ TEST_METHOD (TestRowReplaceText );
151
151
152
152
TEST_METHOD (TestAppendRTFText);
153
153
@@ -2047,46 +2047,53 @@ void TextBufferTests::TestOverwriteChars()
2047
2047
#undef complex1
2048
2048
}
2049
2049
2050
- void TextBufferTests::TestRowWrite ()
2050
+ void TextBufferTests::TestRowReplaceText ()
2051
2051
{
2052
2052
til::size bufferSize{ 10 , 3 };
2053
2053
UINT cursorSize = 12 ;
2054
2054
TextAttribute attr{ 0x7f };
2055
2055
TextBuffer buffer{ bufferSize, attr, cursorSize, false , _renderer };
2056
2056
auto & row = buffer.GetRowByOffset (0 );
2057
- std::wstring_view str;
2058
- til::CoordType pos = 0 ;
2057
+ RowWriteState state;
2059
2058
2060
2059
#define complex L" \U0001F41B "
2061
2060
2062
2061
// 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 );
2067
2068
VERIFY_ARE_EQUAL (L" " , row.GetText ());
2068
2069
2069
2070
// 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 );
2074
2077
VERIFY_ARE_EQUAL (L" " complex L" " , row.GetText ());
2075
2078
2076
2079
// 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);
2079
2084
// It's not quite clear what Write() should return in that case,
2080
2085
// 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 );
2083
2088
VERIFY_ARE_EQUAL (complex L" " , row.GetText ());
2084
2089
2085
2090
// 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 );
2090
2097
VERIFY_ARE_EQUAL (L" a" complex L" b" complex L" c" complex, row.GetText ());
2091
2098
2092
2099
#undef complex
0 commit comments