MCPcopy Create free account
hub / github.com/SpartanJ/eepp / UTEST

Function UTEST

src/tests/unit_tests/textdocument.cpp:9–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace EE::System;
8
9UTEST( TextDocument, multicursor ) {
10 FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
11 TextDocument doc;
12 doc.loadFromFile( "assets/textformat/english.utf8.lf.nobom.txt" );
13 EXPECT_EQ( doc.linesCount() > 0, true );
14
15 // Same line delete
16 for ( int op = 0; op < 2; op++ ) {
17 doc.setSelection( { { 0, 4 }, { 0, 5 } } );
18
19 EXPECT_STRINGEQ( "a", doc.getSelectedText() );
20
21 // Select all "a" from first line
22 doc.selectWord();
23 doc.selectWord();
24 doc.selectWord();
25
26 switch ( op ) {
27 case 0:
28 doc.deleteToPreviousChar();
29 break;
30 case 1:
31 doc.deleteToNextChar();
32 break;
33 }
34
35 EXPECT_STRINGEQ( "It ws bright cold dy in April, nd the clocks were striking thirteen.\n",
36 doc.line( 0 ).getText() );
37
38 doc.resetSelection( TextRange{ { 0, 0 }, { 0, 0 } } );
39 doc.undo();
40 }
41
42 // Multi-line delete
43 for ( int op = 0; op < 4; op++ ) {
44 TextRanges ranges(
45 { TextRange( { 3, 65 }, { 4, 11 } ), TextRange( { 17, 66 }, { 18, 67 } ) } );
46
47 if ( op >= 2 )
48 for ( auto& range : ranges )
49 range.reverse();
50
51 doc.resetSelection( ranges );
52
53 switch ( op % 2 ) {
54 case 0:
55 doc.deleteToPreviousChar();
56 break;
57 case 1:
58 doc.deleteToNextChar();
59 break;
60 }
61
62 EXPECT_STRINGEQ( "though not quickly enough to prevent a swirl of gritty dust from him.\n",
63 doc.line( 3 ).getText() );
64 EXPECT_STRINGEQ( "one of those pictures which are so contrived that the eyes follow ran.\n",
65 doc.line( 16 ).getText() );
66 EXPECT_STDSTREQ( TextRange( { 3, 65 }, { 3, 65 } ).toString(),

Callers

nothing calls this directly

Calls 15

formatFunction · 0.85
TextPositionFunction · 0.85
linesCountMethod · 0.80
getSelectedTextMethod · 0.80
selectWordMethod · 0.80
deleteToPreviousCharMethod · 0.80
deleteToNextCharMethod · 0.80
resetSelectionMethod · 0.80
getSelectionIndexMethod · 0.80
resetUndoRedoMethod · 0.80
c_strMethod · 0.80
setIndentTypeMethod · 0.80

Tested by

no test coverage detected