notepad-plus-plus/scintilla/test/unit/testRunStyles.cxx

382 lines
9.6 KiB
C++
Raw Normal View History

/** @file testRunStyles.cxx
** Unit Tests for Scintilla internal data structures
**/
2019-05-04 18:14:48 +00:00
#include <cstddef>
#include <cstring>
#include <stdexcept>
2019-05-04 18:14:48 +00:00
#include <string_view>
#include <vector>
#include <optional>
#include <algorithm>
2019-05-04 18:14:48 +00:00
#include <memory>
#include "Debugging.h"
2019-05-04 18:14:48 +00:00
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
#include "catch.hpp"
using namespace Scintilla::Internal;
2019-05-04 18:14:48 +00:00
// Test RunStyles.
using UniqueInt = std::unique_ptr<int>;
TEST_CASE("CompileCopying RunStyles") {
// These are compile-time tests to check that basic copy and move
// operations are defined correctly.
SECTION("CopyingMoving") {
RunStyles<int, int> s;
RunStyles<int, int> s2;
// Copy constructor
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const RunStyles<int, int> sa(s);
// Copy assignment fails
RunStyles<int, int> sb;
sb = s;
// Move constructor
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const RunStyles<int, int> sc(std::move(s));
// Move assignment
RunStyles<int, int> sd;
sd = (std::move(s2));
}
#if defined(SHOW_COPY_BUILD_FAILURES)
// It should be reasonable to instantiate RunStyles where STYLE is move-only but fails
SECTION("MoveOnly") {
RunStyles<int, UniqueInt> s;
// Copy is not defined for std::unique_ptr
// Copy constructor fails
RunStyles<int, UniqueInt> sa(s);
// Copy assignment fails
RunStyles<int, UniqueInt> sb;
sb = s;
// Move constructor fails
RunStyles<int, UniqueInt> sc(std::move(s));
// Move assignment fails
RunStyles<int, UniqueInt> sd;
sd = (std::move(s));
}
#endif
}
namespace Scintilla::Internal { // Xcode clang 9.0 doesn't like this when in the unnamed namespace
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
bool operator==(const FillResult<int> &fra, const FillResult<int> &frb) noexcept {
2019-05-04 18:14:48 +00:00
return fra.changed == frb.changed &&
fra.position == frb.position &&
fra.fillLength == frb.fillLength;
}
}
TEST_CASE("RunStyles") {
2019-05-04 18:14:48 +00:00
RunStyles<int, int> rs;
SECTION("IsEmptyInitially") {
REQUIRE(0 == rs.Length());
REQUIRE(1 == rs.Runs());
}
SECTION("SimpleInsert") {
rs.InsertSpace(0, 1);
REQUIRE(1 == rs.Length());
REQUIRE(1 == rs.Runs());
REQUIRE(0 == rs.ValueAt(0));
REQUIRE(1 == rs.FindNextChange(0, rs.Length()));
REQUIRE(2 == rs.FindNextChange(1, rs.Length()));
}
SECTION("TwoRuns") {
rs.InsertSpace(0, 2);
REQUIRE(2 == rs.Length());
REQUIRE(1 == rs.Runs());
rs.SetValueAt(0, 2);
REQUIRE(2 == rs.Runs());
REQUIRE(2 == rs.ValueAt(0));
REQUIRE(0 == rs.ValueAt(1));
REQUIRE(1 == rs.FindNextChange(0, rs.Length()));
REQUIRE(2 == rs.FindNextChange(1, rs.Length()));
REQUIRE(3 == rs.FindNextChange(2, rs.Length()));
}
SECTION("LongerRuns") {
rs.InsertSpace(0, 5);
rs.SetValueAt(0, 3);
rs.SetValueAt(1, 3);
REQUIRE(3 == rs.ValueAt(0));
REQUIRE(3 == rs.ValueAt(1));
REQUIRE(0 == rs.ValueAt(2));
REQUIRE(2 == rs.Runs());
REQUIRE(0 == rs.StartRun(0));
REQUIRE(2 == rs.EndRun(0));
REQUIRE(0 == rs.StartRun(1));
REQUIRE(2 == rs.EndRun(1));
REQUIRE(2 == rs.StartRun(2));
REQUIRE(5 == rs.EndRun(2));
REQUIRE(2 == rs.StartRun(3));
REQUIRE(5 == rs.EndRun(3));
REQUIRE(2 == rs.StartRun(4));
REQUIRE(5 == rs.EndRun(4));
// At end
REQUIRE(2 == rs.StartRun(5));
REQUIRE(5 == rs.EndRun(5));
// After end is same as end
REQUIRE(2 == rs.StartRun(6));
REQUIRE(5 == rs.EndRun(6));
REQUIRE(2 == rs.FindNextChange(0, rs.Length()));
REQUIRE(5 == rs.FindNextChange(2, rs.Length()));
REQUIRE(6 == rs.FindNextChange(5, rs.Length()));
}
SECTION("FillRange") {
rs.InsertSpace(0, 5);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 3;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 1, 3} == fr);
REQUIRE(0 == rs.ValueAt(0));
REQUIRE(99 == rs.ValueAt(1));
REQUIRE(99 == rs.ValueAt(2));
REQUIRE(99 == rs.ValueAt(3));
REQUIRE(0 == rs.ValueAt(4));
REQUIRE(0 == rs.StartRun(0));
REQUIRE(1 == rs.EndRun(0));
REQUIRE(1 == rs.StartRun(1));
REQUIRE(4 == rs.EndRun(1));
}
SECTION("FillRangeAlreadyFilled") {
rs.InsertSpace(0, 5);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 3;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 1, 3} == fr);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill2 = 2;
const int lengthFill2 = 1;
// Compiler warnings if 'false' used instead of '0' as expected value:
2019-05-04 18:14:48 +00:00
const auto fr2 = rs.FillRange(startFill2, 99, lengthFill2);
REQUIRE(FillResult<int>{false, 2, 1} == fr2);
REQUIRE(0 == rs.ValueAt(0));
REQUIRE(99 == rs.ValueAt(1));
REQUIRE(99 == rs.ValueAt(2));
REQUIRE(99 == rs.ValueAt(3));
REQUIRE(0 == rs.ValueAt(4));
REQUIRE(3 == rs.Runs());
}
SECTION("FillRangeAlreadyPartFilled") {
rs.InsertSpace(0, 5);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 2;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 1, 2} == fr);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill2 = 2;
const int lengthFill2 = 2;
2019-05-04 18:14:48 +00:00
const auto fr2 = rs.FillRange(startFill2, 99, lengthFill2);
REQUIRE(FillResult<int>{true, 3, 1} == fr2);
REQUIRE(3 == rs.Runs());
}
SECTION("DeleteRange") {
rs.InsertSpace(0, 5);
rs.SetValueAt(0, 3);
REQUIRE(2 == rs.Runs());
rs.SetValueAt(1, 3);
REQUIRE(2 == rs.Runs());
rs.DeleteRange(1, 1);
REQUIRE(4 == rs.Length());
REQUIRE(2 == rs.Runs());
REQUIRE(3 == rs.ValueAt(0));
REQUIRE(0 == rs.ValueAt(1));
REQUIRE(0 == rs.StartRun(0));
REQUIRE(1 == rs.EndRun(0));
REQUIRE(1 == rs.StartRun(1));
REQUIRE(4 == rs.EndRun(1));
REQUIRE(1 == rs.StartRun(2));
REQUIRE(4 == rs.EndRun(2));
}
SECTION("Find") {
rs.InsertSpace(0, 5);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 3;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 1, 3} == fr);
REQUIRE(0 == rs.Find(0,0));
REQUIRE(1 == rs.Find(99,0));
REQUIRE(-1 == rs.Find(3,0));
REQUIRE(4 == rs.Find(0,1));
REQUIRE(1 == rs.Find(99,1));
REQUIRE(-1 == rs.Find(3,1));
REQUIRE(4 == rs.Find(0,2));
REQUIRE(2 == rs.Find(99,2));
REQUIRE(-1 == rs.Find(3, 2));
REQUIRE(4 == rs.Find(0,4));
REQUIRE(-1 == rs.Find(99,4));
REQUIRE(-1 == rs.Find(3,4));
REQUIRE(-1 == rs.Find(0,5));
REQUIRE(-1 == rs.Find(99,5));
REQUIRE(-1 == rs.Find(3,5));
REQUIRE(-1 == rs.Find(0,6));
REQUIRE(-1 == rs.Find(99,6));
REQUIRE(-1 == rs.Find(3,6));
}
SECTION("AllSame") {
REQUIRE(true == rs.AllSame());
rs.InsertSpace(0, 5);
REQUIRE(true == rs.AllSame());
2019-05-04 18:14:48 +00:00
REQUIRE(false == rs.AllSameAs(88));
REQUIRE(true == rs.AllSameAs(0));
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 3;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(true == fr.changed);
REQUIRE(false == rs.AllSame());
REQUIRE(false == rs.AllSameAs(88));
REQUIRE(false == rs.AllSameAs(0));
const auto fr2 = rs.FillRange(startFill, 0, lengthFill);
REQUIRE(true == fr2.changed);
REQUIRE(true == rs.AllSame());
2019-05-04 18:14:48 +00:00
REQUIRE(false == rs.AllSameAs(88));
REQUIRE(true == rs.AllSameAs(0));
}
SECTION("FindWithReversion") {
rs.InsertSpace(0, 5);
REQUIRE(1 == rs.Runs());
int startFill = 1;
int lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 1, 1} == fr);
REQUIRE(3 == rs.Runs());
startFill = 2;
lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr2 = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(FillResult<int>{true, 2, 1} == fr2);
REQUIRE(3 == rs.Runs());
startFill = 1;
lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr3 = rs.FillRange(startFill, 0, lengthFill);
REQUIRE(FillResult<int>{true, 1, 1} == fr3);
REQUIRE(3 == rs.Runs());
startFill = 2;
lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr4 = rs.FillRange(startFill, 0, lengthFill);
REQUIRE(FillResult<int>{true, 2, 1} == fr4);
REQUIRE(1 == rs.Runs());
REQUIRE(-1 == rs.Find(0,6));
}
SECTION("FinalRunInversion") {
REQUIRE(1 == rs.Runs());
rs.InsertSpace(0, 1);
REQUIRE(1 == rs.Runs());
rs.SetValueAt(0, 1);
REQUIRE(1 == rs.Runs());
rs.InsertSpace(1, 1);
REQUIRE(1 == rs.Runs());
rs.SetValueAt(1, 1);
REQUIRE(1 == rs.Runs());
rs.SetValueAt(1, 0);
REQUIRE(2 == rs.Runs());
rs.SetValueAt(1, 1);
REQUIRE(1 == rs.Runs());
}
SECTION("DeleteAll") {
rs.InsertSpace(0, 5);
rs.SetValueAt(0, 3);
rs.SetValueAt(1, 3);
rs.DeleteAll();
REQUIRE(0 == rs.Length());
REQUIRE(0 == rs.ValueAt(0));
REQUIRE(1 == rs.Runs());
}
SECTION("DeleteSecond") {
rs.InsertSpace(0, 3);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(true == fr.changed);
REQUIRE(3 == rs.Length());
REQUIRE(3 == rs.Runs());
rs.DeleteRange(1, 1);
REQUIRE(2 == rs.Length());
REQUIRE(1 == rs.Runs());
}
SECTION("DeleteEndRun") {
rs.InsertSpace(0, 2);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 1;
2019-05-04 18:14:48 +00:00
const auto fr = rs.FillRange(startFill, 99, lengthFill);
REQUIRE(true == fr.changed);
REQUIRE(2 == rs.Length());
REQUIRE(2 == rs.Runs());
REQUIRE(0 == rs.StartRun(0));
REQUIRE(1 == rs.EndRun(0));
REQUIRE(1 == rs.StartRun(1));
REQUIRE(2 == rs.EndRun(1));
rs.DeleteRange(1, 1);
REQUIRE(1 == rs.Length());
REQUIRE(1 == rs.Runs());
REQUIRE(0 == rs.StartRun(0));
REQUIRE(1 == rs.EndRun(0));
REQUIRE(0 == rs.StartRun(1));
REQUIRE(1 == rs.EndRun(1));
rs.Check();
}
SECTION("OutsideBounds") {
rs.InsertSpace(0, 1);
Updated to Scintilla 5.4.2 & Lexilla 5.3.1 https://www.scintilla.org/scintilla542.zip Release 5.4.2 Released 5 March 2024. Significantly reduce memory used for undo actions, often to a half or quarter of previous versions. Feature #1458. Add APIs for saving and restoring undo history. For GTK, when laying out text, detect runs with both left-to-right and right-to-left ranges and divide into an ASCII prefix and more complex suffix. Lay out the ASCII prefix in the standard manner but, for the suffix, measure the whole width and spread that over the suffix bytes. This produces more usable results where the caret moves over the ASCII prefix correctly and over the suffix reasonably but not accurately. For ScintillaEdit on Qt, fix reference from ScintillaDocument to Document to match change in 5.4.1 using IDocumentEditable for SCI_GETDOCPOINTER and SCI_SETDOCPOINTER. For Direct2D on Win32, use the multi-threaded option to avoid crashes when Scintilla instances created on different threads. There may be more problems with this scenario so it should be avoided. Bug #2420. For Win32, ensure keyboard-initiated context menu appears in multi-screen situations. https://www.scintilla.org/lexilla531.zip Release 5.3.1 Released 5 March 2024. Assembler: After comments, treat \r\n line ends the same as \n. This makes testing easier. Bash: Fix folding when line changed to/from comment and previous line is comment. Issue #224. Batch: Fix handling ':' next to keywords. Issue #222. JavaScript: in cpp lexer, add lexer.cpp.backquoted.strings=2 mode to treat ` back-quoted strings as template literals which allow embedded ${expressions}. Issue #94. Python: fix lexing of rb'' and rf'' strings. Issue #223, Pull request #227. Ruby: fix lexing of methods on numeric literals like '3.times' so the '.' and method name do not appear in numeric style. Issue #225.
2024-03-06 21:05:54 +00:00
const int startFill = 1;
const int lengthFill = 1;
rs.FillRange(startFill, 99, lengthFill);
REQUIRE(1 == rs.Length());
REQUIRE(1 == rs.Runs());
REQUIRE(0 == rs.StartRun(0));
REQUIRE(1 == rs.EndRun(0));
}
}