diff options
| author | Neil <nyamatongwe@gmail.com> | 2018-03-27 19:35:55 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2018-03-27 19:35:55 +1100 | 
| commit | e93a47975d317f59df0fdcca7cee95b6ab4ff33f (patch) | |
| tree | 852d09d665ca8cb76fa919805db7fcfa0028ea39 /test/unit/testRunStyles.cxx | |
| parent | fb9f493960b075b034b18d61036d36f384f2e3f8 (diff) | |
| download | scintilla-mirror-e93a47975d317f59df0fdcca7cee95b6ab4ff33f.tar.gz | |
Return a FillResult struct from RunStyles::FillRange instead of modifying
arguments as that is clumsy when converting types.
Diffstat (limited to 'test/unit/testRunStyles.cxx')
| -rw-r--r-- | test/unit/testRunStyles.cxx | 68 | 
1 files changed, 36 insertions, 32 deletions
| 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)); | 
