Skip to content

Commit

Permalink
Add some tests for TextBuffer::Reflow (#8715)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DHowett authored Jan 18, 2021
1 parent 3c044f2 commit fa0cd8c
Show file tree
Hide file tree
Showing 5 changed files with 888 additions and 7 deletions.
32 changes: 25 additions & 7 deletions .github/actions/spell-check/expect/expect.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
AAAAA
AAAAAABBBBBBCCC
AAAAABBBBBBBCCC
AAAAABBBBBBCCC
AAAAABCCCCCCCCC
AAAAADCCCCCCCCC
ABANDONFONT
abcd
ABCDEFGHIJKLMNO
ABCG
abf
Expand Down Expand Up @@ -129,6 +132,7 @@ backstory
Batang
baz
Bazz
BBBBBCCC
BBBBCCCCC
BBDM
bbwe
Expand Down Expand Up @@ -290,6 +294,7 @@ CNTRL
codebase
Codeflow
codepage
codepath
codepoint
codeproject
COINIT
Expand Down Expand Up @@ -755,6 +760,7 @@ FFrom
FGCOLOR
fgetc
fgetwc
FGHIJ
fgidx
FILEDESCRIPTION
fileno
Expand Down Expand Up @@ -892,6 +898,9 @@ GFEh
Gfun
gfx
gh
GHIJK
GHIJKL
GHIJKLM
gitfilters
github
gitlab
Expand Down Expand Up @@ -1198,6 +1207,7 @@ KILLFOCUS
kinda
KJ
KLF
KLMNO
KLMNOPQRST
KLMNOPQRSTQQQQQ
KU
Expand Down Expand Up @@ -1244,6 +1254,7 @@ lld
llvm
llx
LMENU
LMNOP
lnk
lnkd
lnkfile
Expand Down Expand Up @@ -1286,6 +1297,7 @@ LPFNADDPROPSHEETPAGE
LPINT
lpl
LPMEASUREITEMSTRUCT
LPMINMAXINFO
lpmsg
LPNEWCPLINFO
LPNEWCPLINFOA
Expand Down Expand Up @@ -1317,6 +1329,7 @@ lsproj
lss
lstatus
lstrcmp
lstrcmpi
LTEXT
LTLTLTLTL
ltype
Expand Down Expand Up @@ -1383,6 +1396,7 @@ mindbogglingly
mingw
minimizeall
minkernel
MINMAXINFO
minwin
minwindef
Mip
Expand All @@ -1392,6 +1406,8 @@ mmcc
MMCPL
mmsystem
MNC
MNOPQ
MNOPQR
MODALFRAME
modelproj
MODERNCORE
Expand Down Expand Up @@ -1487,9 +1503,9 @@ Nls
NLSMODE
NOACTIVATE
NOAPPLYNOW
NOCOMM
NOCLIP
NOCOLOR
NOCOMM
NOCONTEXTHELP
NOCOPYBITS
nodiscard
Expand All @@ -1513,6 +1529,7 @@ NONPREROTATED
nonspace
NOOWNERZORDER
NOPAINT
NOPQRST
noprofile
NOREDRAW
NOREMOVE
Expand Down Expand Up @@ -1866,6 +1883,7 @@ pythonw
qi
QJ
qo
QRSTU
qsort
queryable
QUESTIONMARK
Expand Down Expand Up @@ -2213,6 +2231,7 @@ strrev
strsafe
strtok
structs
STUVWX
STX
stylecop
SUA
Expand Down Expand Up @@ -2506,6 +2525,8 @@ utr
uuid
uuidof
uuidv
UVWX
UVWXY
UWA
uwp
uxtheme
Expand Down Expand Up @@ -2573,6 +2594,7 @@ VTRGBTo
vtseq
vtterm
vttest
VWX
waaay
waitable
waivable
Expand Down Expand Up @@ -2812,6 +2834,8 @@ YVIRTUALSCREEN
Yw
YWalk
yx
YZ
yzx
Zc
ZCmd
ZCtrl
Expand All @@ -2822,9 +2846,3 @@ zsh
zu
zxcvbnm
zy
AAAAABBBBBBCCC
BBBBBCCC
abcd
LPMINMAXINFO
MINMAXINFO
lstrcmpi
2 changes: 2 additions & 0 deletions src/buffer/out/CharRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ class CharRow final
// iterators
iterator begin() noexcept;
const_iterator cbegin() const noexcept;
const_iterator begin() const noexcept { return cbegin(); }

iterator end() noexcept;
const_iterator cend() const noexcept;
const_iterator end() const noexcept { return cend(); }

UnicodeStorage& GetUnicodeStorage() noexcept;
const UnicodeStorage& GetUnicodeStorage() const noexcept;
Expand Down
Loading

0 comments on commit fa0cd8c

Please sign in to comment.