aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/testDecoration.cxx13
-rw-r--r--test/unit/testRunStyles.cxx68
2 files changed, 42 insertions, 39 deletions
diff --git a/test/unit/testDecoration.cxx b/test/unit/testDecoration.cxx
index 3e18b1665..d2fbc7df2 100644
--- a/test/unit/testDecoration.cxx
+++ b/test/unit/testDecoration.cxx
@@ -73,19 +73,18 @@ TEST_CASE("DecorationList") {
const int value = 59;
Sci::Position position = 4;
Sci::Position fillLength = 3;
- bool changed = decol.FillRange(position, value, fillLength);
- REQUIRE(changed);
- REQUIRE(position == 4);
- REQUIRE(fillLength == 3);
- REQUIRE(fillLength == 3);
+ auto fr = decol.FillRange(position, value, fillLength);
+ REQUIRE(fr.changed);
+ REQUIRE(fr.position == 4);
+ REQUIRE(fr.fillLength == 3);
REQUIRE(decol.ValueAt(indicator, 5) == value);
REQUIRE(decol.AllOnFor(5) == (1 << indicator));
REQUIRE(decol.Start(indicator, 5) == 4);
REQUIRE(decol.End(indicator, 5) == 7);
const int indicatorB=6;
decol.SetCurrentIndicator(indicatorB);
- changed = decol.FillRange(position, value, fillLength);
- REQUIRE(changed);
+ fr = decol.FillRange(position, value, fillLength);
+ REQUIRE(fr.changed);
REQUIRE(decol.AllOnFor(5) == ((1 << indicator) | (1 << indicatorB)));
decol.DeleteRange(5, 1);
REQUIRE(decol.Start(indicatorB, 5) == 4);
diff --git a/test/unit/testRunStyles.cxx b/test/unit/testRunStyles.cxx
index 75daac26e..3edb61657 100644
--- a/test/unit/testRunStyles.cxx
+++ b/test/unit/testRunStyles.cxx
@@ -21,6 +21,14 @@ using namespace Scintilla;
// Test RunStyles.
+namespace Scintilla { // Xcode clang 9.0 doesn't like this when in the unnamed namespace
+ bool operator==(const FillResult<int> &fra, const FillResult<int> &frb) {
+ return fra.changed == frb.changed &&
+ fra.position == frb.position &&
+ fra.fillLength == frb.fillLength;
+ }
+}
+
TEST_CASE("RunStyles") {
RunStyles<int, int> rs;
@@ -93,9 +101,8 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 5);
int startFill = 1;
int lengthFill = 3;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(1 == startFill);
- REQUIRE(3 == lengthFill);
+ 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));
@@ -114,16 +121,14 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 5);
int startFill = 1;
int lengthFill = 3;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(1 == startFill);
- REQUIRE(3 == lengthFill);
+ const auto fr = rs.FillRange(startFill, 99, lengthFill);
+ REQUIRE(FillResult<int>{true, 1, 3} == fr);
int startFill2 = 2;
int lengthFill2 = 1;
// Compiler warnings if 'false' used instead of '0' as expected value:
- REQUIRE(false == rs.FillRange(startFill2, 99, lengthFill2));
- REQUIRE(2 == startFill2);
- REQUIRE(1 == lengthFill2);
+ 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));
@@ -136,15 +141,13 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 5);
int startFill = 1;
int lengthFill = 2;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(1 == startFill);
- REQUIRE(2 == lengthFill);
+ const auto fr = rs.FillRange(startFill, 99, lengthFill);
+ REQUIRE(FillResult<int>{true, 1, 2} == fr);
int startFill2 = 2;
int lengthFill2 = 2;
- REQUIRE(true == rs.FillRange(startFill2, 99, lengthFill2));
- REQUIRE(3 == startFill2);
- REQUIRE(1 == lengthFill2);
+ const auto fr2 = rs.FillRange(startFill2, 99, lengthFill2);
+ REQUIRE(FillResult<int>{true, 3, 1} == fr2);
REQUIRE(3 == rs.Runs());
}
@@ -174,9 +177,8 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 5);
int startFill = 1;
int lengthFill = 3;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(1 == startFill);
- REQUIRE(3 == lengthFill);
+ 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));
@@ -211,11 +213,13 @@ TEST_CASE("RunStyles") {
REQUIRE(true == rs.AllSameAs(0));
int startFill = 1;
int lengthFill = 3;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
+ 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));
- REQUIRE(true == rs.FillRange(startFill, 0, lengthFill));
+ const auto fr2 = rs.FillRange(startFill, 0, lengthFill);
+ REQUIRE(true == fr2.changed);
REQUIRE(true == rs.AllSame());
REQUIRE(false == rs.AllSameAs(88));
REQUIRE(true == rs.AllSameAs(0));
@@ -227,29 +231,27 @@ TEST_CASE("RunStyles") {
int startFill = 1;
int lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(1 == startFill);
- REQUIRE(1 == lengthFill);
+ const auto fr = rs.FillRange(startFill, 99, lengthFill);
+ REQUIRE(FillResult<int>{true, 1, 1} == fr);
REQUIRE(3 == rs.Runs());
startFill = 2;
lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
- REQUIRE(2 == startFill);
- REQUIRE(1 == lengthFill);
+ const auto fr2 = rs.FillRange(startFill, 99, lengthFill);
+ REQUIRE(FillResult<int>{true, 2, 1} == fr2);
REQUIRE(3 == rs.Runs());
startFill = 1;
lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 0, lengthFill));
+ const auto fr3 = rs.FillRange(startFill, 0, lengthFill);
+ REQUIRE(FillResult<int>{true, 1, 1} == fr3);
REQUIRE(3 == rs.Runs());
- REQUIRE(1 == lengthFill);
startFill = 2;
lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 0, lengthFill));
+ const auto fr4 = rs.FillRange(startFill, 0, lengthFill);
+ REQUIRE(FillResult<int>{true, 2, 1} == fr4);
REQUIRE(1 == rs.Runs());
- REQUIRE(1 == lengthFill);
REQUIRE(-1 == rs.Find(0,6));
}
@@ -284,7 +286,8 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 3);
int startFill = 1;
int lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
+ const auto fr = rs.FillRange(startFill, 99, lengthFill);
+ REQUIRE(true == fr.changed);
REQUIRE(3 == rs.Length());
REQUIRE(3 == rs.Runs());
rs.DeleteRange(1, 1);
@@ -296,7 +299,8 @@ TEST_CASE("RunStyles") {
rs.InsertSpace(0, 2);
int startFill = 1;
int lengthFill = 1;
- REQUIRE(true == rs.FillRange(startFill, 99, lengthFill));
+ 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));