2022-01-05 00:07:50 +01:00
|
|
|
/** @file testSplitVector.cxx
|
|
|
|
** Unit Tests for Scintilla internal data structures
|
|
|
|
**/
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2019-05-04 20:14:48 +02:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstring>
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2019-05-04 20:14:48 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2022-01-05 00:07:50 +01:00
|
|
|
#include <optional>
|
2013-08-28 02:44:27 +02:00
|
|
|
#include <algorithm>
|
2019-05-04 20:14:48 +02:00
|
|
|
#include <memory>
|
2013-08-28 02:44:27 +02:00
|
|
|
|
2022-01-05 00:07:50 +01:00
|
|
|
#include "Debugging.h"
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2019-05-04 20:14:48 +02:00
|
|
|
#include "Position.h"
|
2013-01-25 01:46:29 +01:00
|
|
|
#include "SplitVector.h"
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
#include "catch.hpp"
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2022-01-05 00:07:50 +01:00
|
|
|
using namespace Scintilla::Internal;
|
2019-05-04 20:14:48 +02:00
|
|
|
|
2013-01-25 01:46:29 +01:00
|
|
|
// Test SplitVector.
|
|
|
|
|
2022-08-27 09:35:52 +02:00
|
|
|
using UniqueInt = std::unique_ptr<int>;
|
|
|
|
|
|
|
|
// Test SplitVector.
|
|
|
|
|
|
|
|
TEST_CASE("CompileCopying SplitVector") {
|
|
|
|
|
|
|
|
// These are compile-time tests to check that basic copy and move
|
|
|
|
// operations are defined correctly.
|
|
|
|
|
|
|
|
SECTION("CopyingMoving") {
|
|
|
|
SplitVector<int> s;
|
|
|
|
SplitVector<int> s2;
|
|
|
|
|
|
|
|
// Copy constructor fails
|
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 22:05:54 +01:00
|
|
|
const SplitVector<int> sa(s);
|
2022-08-27 09:35:52 +02:00
|
|
|
// Copy assignment fails
|
|
|
|
SplitVector<int> sb;
|
|
|
|
sb = s;
|
|
|
|
|
|
|
|
// Move constructor fails
|
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 22:05:54 +01:00
|
|
|
const SplitVector<int> sc(std::move(s));
|
2022-08-27 09:35:52 +02:00
|
|
|
// Move assignment fails
|
|
|
|
SplitVector<int> sd;
|
|
|
|
sd = (std::move(s2));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("MoveOnly") {
|
|
|
|
SplitVector<UniqueInt> s;
|
|
|
|
|
|
|
|
#if defined(SHOW_COPY_BUILD_FAILURES)
|
|
|
|
// Copy is not defined for std::unique_ptr
|
|
|
|
// Copy constructor fails
|
|
|
|
SplitVector<UniqueInt> sa(s);
|
|
|
|
// Copy assignment fails
|
|
|
|
SplitVector<UniqueInt> sb;
|
|
|
|
sb = s;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Move constructor fails
|
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 22:05:54 +01:00
|
|
|
const SplitVector<UniqueInt> sc(std::move(s));
|
2022-08-27 09:35:52 +02:00
|
|
|
// Move assignment fails
|
|
|
|
SplitVector<UniqueInt> sd;
|
|
|
|
sd = (std::move(s));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:14:48 +02:00
|
|
|
struct StringSetHolder {
|
|
|
|
SplitVector<std::string> sa;
|
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 22:05:54 +01:00
|
|
|
[[nodiscard]] bool Check() const noexcept {
|
2019-05-04 20:14:48 +02:00
|
|
|
for (int i = 0; i < sa.Length(); i++) {
|
|
|
|
if (sa[i].empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-05 00:07:50 +01:00
|
|
|
constexpr int lengthTestArray = 4;
|
2013-01-25 01:46:29 +01:00
|
|
|
static const int testArray[4] = {3, 4, 5, 6};
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
TEST_CASE("SplitVector") {
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SplitVector<int> sv;
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("IsEmptyInitially") {
|
|
|
|
REQUIRE(0 == sv.Length());
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("InsertOne") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
sv.Insert(5, 3);
|
|
|
|
REQUIRE(11 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i == 5) ? 3 : 0) == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("Insertion") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
REQUIRE(10 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(0 == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2019-05-04 20:14:48 +02:00
|
|
|
SECTION("InsertionString") {
|
|
|
|
// This test failed an earlier version of SplitVector that copied backwards incorrectly
|
|
|
|
StringSetHolder ssh;
|
|
|
|
ssh.sa.Insert(0, "Alpha");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Beta");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Cat");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Dog");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Elephant");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Fox");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Grass");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Hat");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Delete(4);
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Indigo");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Jackal");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Kanga");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Lion");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(0, "Mango");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
ssh.sa.Insert(1, "Neon");
|
|
|
|
REQUIRE(ssh.Check());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("InsertionPattern") {
|
|
|
|
sv.Insert(0, 1); // 1
|
|
|
|
sv.Insert(0, 2); // 21
|
|
|
|
sv.Insert(0, 3); // 321
|
|
|
|
sv.Insert(1, 4); // 3421
|
|
|
|
sv.Insert(0, 5); // 53421
|
|
|
|
sv.Insert(1, 6); // 563421
|
|
|
|
sv.Insert(0, 7); // 7563421
|
|
|
|
sv.Insert(1, 8); // 78563421
|
|
|
|
|
|
|
|
REQUIRE(8 == sv.Length());
|
|
|
|
|
|
|
|
REQUIRE(7 == sv.ValueAt(0));
|
|
|
|
REQUIRE(8 == sv.ValueAt(1));
|
|
|
|
REQUIRE(5 == sv.ValueAt(2));
|
|
|
|
REQUIRE(6 == sv.ValueAt(3));
|
|
|
|
REQUIRE(3 == sv.ValueAt(4));
|
|
|
|
REQUIRE(4 == sv.ValueAt(5));
|
|
|
|
REQUIRE(2 == sv.ValueAt(6));
|
|
|
|
REQUIRE(1 == sv.ValueAt(7));
|
|
|
|
|
|
|
|
sv.Delete(4); // 7856421
|
|
|
|
|
|
|
|
REQUIRE(7 == sv.Length());
|
|
|
|
|
|
|
|
REQUIRE(7 == sv.ValueAt(0));
|
|
|
|
REQUIRE(8 == sv.ValueAt(1));
|
|
|
|
REQUIRE(5 == sv.ValueAt(2));
|
|
|
|
REQUIRE(6 == sv.ValueAt(3));
|
|
|
|
REQUIRE(4 == sv.ValueAt(4));
|
|
|
|
REQUIRE(2 == sv.ValueAt(5));
|
|
|
|
REQUIRE(1 == sv.ValueAt(6));
|
|
|
|
|
|
|
|
sv.Insert(0, 9); // 97856421
|
|
|
|
sv.Insert(1, 0xa); // 9a7856421
|
|
|
|
sv.Insert(0, 0xb); // b9a7856421
|
|
|
|
sv.Insert(1, 0xc); // bc9a7856421
|
|
|
|
sv.Insert(0, 0xd); // dbc9a7856421
|
|
|
|
sv.Insert(1, 0xe); // debc9a7856421
|
|
|
|
|
|
|
|
REQUIRE(13 == sv.Length());
|
|
|
|
|
|
|
|
REQUIRE(0xd == sv.ValueAt(0));
|
|
|
|
REQUIRE(0xe == sv.ValueAt(1));
|
|
|
|
REQUIRE(0xb == sv.ValueAt(2));
|
|
|
|
REQUIRE(0xc == sv.ValueAt(3));
|
|
|
|
REQUIRE(9 == sv.ValueAt(4));
|
|
|
|
REQUIRE(0xa == sv.ValueAt(5));
|
|
|
|
REQUIRE(7 == sv.ValueAt(6));
|
|
|
|
REQUIRE(8 == sv.ValueAt(7));
|
|
|
|
REQUIRE(5 == sv.ValueAt(8));
|
|
|
|
REQUIRE(6 == sv.ValueAt(9));
|
|
|
|
REQUIRE(4 == sv.ValueAt(10));
|
|
|
|
REQUIRE(2 == sv.ValueAt(11));
|
|
|
|
REQUIRE(1 == sv.ValueAt(12));
|
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("EnsureLength") {
|
|
|
|
sv.EnsureLength(4);
|
|
|
|
REQUIRE(4 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(0 == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("InsertFromArray") {
|
|
|
|
sv.InsertFromArray(0, testArray, 0, lengthTestArray);
|
|
|
|
REQUIRE(lengthTestArray == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE((i+3) == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2021-02-21 05:53:09 +01:00
|
|
|
SECTION("InsertEmpty") {
|
|
|
|
sv.InsertEmpty(0, 0);
|
|
|
|
REQUIRE(0 == sv.Length());
|
|
|
|
int *pi = sv.InsertEmpty(0, 2);
|
|
|
|
REQUIRE(2 == sv.Length());
|
|
|
|
REQUIRE(0 == sv.ValueAt(0));
|
|
|
|
REQUIRE(0 == sv.ValueAt(1));
|
|
|
|
pi[0] = 4;
|
|
|
|
pi[1] = 5;
|
|
|
|
REQUIRE(4 == sv.ValueAt(0));
|
|
|
|
REQUIRE(5 == sv.ValueAt(1));
|
|
|
|
pi = sv.InsertEmpty(1, 2);
|
|
|
|
pi[0] = 6;
|
|
|
|
pi[1] = 7;
|
|
|
|
REQUIRE(4 == sv.Length());
|
|
|
|
REQUIRE(4 == sv.ValueAt(0));
|
|
|
|
REQUIRE(6 == sv.ValueAt(1));
|
|
|
|
REQUIRE(7 == sv.ValueAt(2));
|
|
|
|
REQUIRE(5 == sv.ValueAt(3));
|
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("SetValue") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
sv.SetValueAt(5, 3);
|
|
|
|
REQUIRE(10 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i == 5) ? 3 : 0) == sv.ValueAt(i));
|
|
|
|
}
|
|
|
|
// Move the gap
|
|
|
|
sv.InsertValue(7, 1, 17);
|
|
|
|
REQUIRE(17 == sv.ValueAt(7));
|
|
|
|
REQUIRE(0 == sv.ValueAt(8));
|
|
|
|
// Set after the gap
|
|
|
|
sv.SetValueAt(8, 19);
|
|
|
|
REQUIRE(19 == sv.ValueAt(8));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Indexing") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
sv.SetValueAt(5, 3);
|
|
|
|
REQUIRE(10 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i == 5) ? 3 : 0) == sv[i]);
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("Fill") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
REQUIRE(10 == sv.Length());
|
|
|
|
sv.InsertValue(7, 1, 1);
|
|
|
|
REQUIRE(11 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i == 7) ? 1 : 0) == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("DeleteOne") {
|
|
|
|
sv.InsertFromArray(0, testArray, 0, lengthTestArray);
|
|
|
|
sv.Delete(2);
|
|
|
|
REQUIRE((lengthTestArray-1) == sv.Length());
|
|
|
|
REQUIRE(3 == sv[0]);
|
|
|
|
REQUIRE(4 == sv[1]);
|
|
|
|
REQUIRE(6 == sv[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("DeleteRange") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
REQUIRE(10 == sv.Length());
|
|
|
|
sv.InsertValue(7, 1, 1);
|
|
|
|
REQUIRE(11 == sv.Length());
|
|
|
|
sv.DeleteRange(2, 3);
|
|
|
|
REQUIRE(8 == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i == 4) ? 1 : 0) == sv.ValueAt(i));
|
|
|
|
}
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("DeleteAll") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
sv.InsertValue(7, 1, 1);
|
|
|
|
sv.DeleteRange(2, 3);
|
|
|
|
sv.DeleteAll();
|
|
|
|
REQUIRE(0 == sv.Length());
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("GetRange") {
|
|
|
|
sv.InsertValue(0, 10, 0);
|
|
|
|
sv.InsertValue(7, 1, 1);
|
|
|
|
int retrieveArray[11] = {0};
|
|
|
|
sv.GetRange(retrieveArray, 0, 11);
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE(((i==7) ? 1 : 0) == retrieveArray[i]);
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("GetRangeOverGap") {
|
|
|
|
sv.InsertFromArray(0, testArray, 0, lengthTestArray);
|
|
|
|
REQUIRE(lengthTestArray == sv.Length());
|
|
|
|
int retrieveArray[lengthTestArray] = {0};
|
|
|
|
sv.GetRange(retrieveArray, 0, lengthTestArray);
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
REQUIRE((i+3) == retrieveArray[i]);
|
|
|
|
}
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("ReplaceUp") {
|
|
|
|
// Replace each element by inserting and then deleting the displaced element
|
|
|
|
// This should perform many moves
|
2022-01-05 00:07:50 +01:00
|
|
|
constexpr int testLength=105;
|
2015-06-07 23:19:26 +02:00
|
|
|
sv.EnsureLength(testLength);
|
|
|
|
for (int i=0; i<testLength; i++)
|
|
|
|
sv.SetValueAt(i, i+2);
|
|
|
|
REQUIRE(testLength == sv.Length());
|
|
|
|
for (int i=0; i<sv.Length(); i++) {
|
|
|
|
sv.InsertValue(i, 1, i+9);
|
|
|
|
sv.Delete(i+1);
|
|
|
|
}
|
|
|
|
for (int i=0; i<sv.Length(); i++)
|
|
|
|
REQUIRE((i+9) == sv.ValueAt(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("ReplaceDown") {
|
|
|
|
// From the end, replace each element by inserting and then deleting the displaced element
|
|
|
|
// This should perform many moves
|
2022-01-05 00:07:50 +01:00
|
|
|
constexpr int testLength=24;
|
2015-06-07 23:19:26 +02:00
|
|
|
sv.EnsureLength(testLength);
|
|
|
|
for (int i=0; i<testLength; i++)
|
|
|
|
sv.SetValueAt(i, i+12);
|
|
|
|
REQUIRE(testLength == sv.Length());
|
2019-05-04 20:14:48 +02:00
|
|
|
for (ptrdiff_t i=sv.Length()-1; i>=0; i--) {
|
|
|
|
sv.InsertValue(i, 1, static_cast<int>(i+5));
|
2015-06-07 23:19:26 +02:00
|
|
|
sv.Delete(i+1);
|
|
|
|
}
|
|
|
|
for (int i=0; i<sv.Length(); i++)
|
|
|
|
REQUIRE((i+5) == sv.ValueAt(i));
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("BufferPointer") {
|
2019-05-04 20:14:48 +02:00
|
|
|
// Low-level access to the data
|
2015-06-07 23:19:26 +02:00
|
|
|
sv.InsertFromArray(0, testArray, 0, lengthTestArray);
|
2019-05-04 20:14:48 +02:00
|
|
|
sv.Insert(0, 99); // This moves the gap so that BufferPointer() must also move
|
|
|
|
REQUIRE(1 == sv.GapPosition());
|
2022-01-05 00:07:50 +01:00
|
|
|
constexpr int lengthAfterInsertion = 1 + lengthTestArray;
|
2019-05-04 20:14:48 +02:00
|
|
|
REQUIRE(lengthAfterInsertion == (sv.Length()));
|
2022-01-05 00:07:50 +01:00
|
|
|
const int *retrievePointer = sv.BufferPointer();
|
2019-05-04 20:14:48 +02:00
|
|
|
for (int i=1; i<sv.Length(); i++) {
|
|
|
|
REQUIRE((i+3-1) == retrievePointer[i]);
|
2015-06-07 23:19:26 +02:00
|
|
|
}
|
2019-05-04 20:14:48 +02:00
|
|
|
REQUIRE(lengthAfterInsertion == sv.Length());
|
|
|
|
// Gap was moved to end.
|
|
|
|
REQUIRE(lengthAfterInsertion == sv.GapPosition());
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("DeleteBackAndForth") {
|
|
|
|
sv.InsertValue(0, 10, 87);
|
|
|
|
for (int i=0; i<10; i+=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 22:05:54 +01:00
|
|
|
const int len = 10 - i;
|
2015-06-07 23:19:26 +02:00
|
|
|
REQUIRE(len == sv.Length());
|
2019-05-04 20:14:48 +02:00
|
|
|
for (int j=0; j<sv.Length(); j++) {
|
|
|
|
REQUIRE(87 == sv.ValueAt(j));
|
2015-06-07 23:19:26 +02:00
|
|
|
}
|
|
|
|
sv.Delete(len-1);
|
|
|
|
sv.Delete(0);
|
2013-01-25 01:46:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 23:19:26 +02:00
|
|
|
SECTION("GrowSize") {
|
|
|
|
sv.SetGrowSize(5);
|
|
|
|
REQUIRE(5 == sv.GetGrowSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("OutsideBounds") {
|
|
|
|
sv.InsertValue(0, 10, 87);
|
|
|
|
REQUIRE(0 == sv.ValueAt(-1));
|
|
|
|
REQUIRE(0 == sv.ValueAt(10));
|
|
|
|
|
|
|
|
/* Could be a death test as this asserts:
|
|
|
|
sv.SetValueAt(-1,98);
|
|
|
|
sv.SetValueAt(10,99);
|
|
|
|
REQUIRE(0 == sv.ValueAt(-1));
|
|
|
|
REQUIRE(0 == sv.ValueAt(10));
|
|
|
|
*/
|
|
|
|
}
|
2013-01-25 01:46:29 +01:00
|
|
|
|
|
|
|
}
|