2015-06-07 21:19:26 +00:00
|
|
|
// Unit Tests for Scintilla internal data structures
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstring>
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
#include <stdexcept>
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2015-06-07 21:19:26 +00:00
|
|
|
#include <algorithm>
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <memory>
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
#include "Platform.h"
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
#include "Position.h"
|
2015-06-07 21:19:26 +00:00
|
|
|
#include "SplitVector.h"
|
|
|
|
#include "Partitioning.h"
|
|
|
|
#include "RunStyles.h"
|
|
|
|
#include "Decoration.h"
|
|
|
|
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
const int indicator=4;
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
using namespace Scintilla;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
// Test Decoration.
|
|
|
|
|
|
|
|
TEST_CASE("Decoration") {
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
std::unique_ptr<IDecoration> deco = DecorationCreate(false, indicator);
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
SECTION("HasCorrectIndicator") {
|
2019-05-04 18:14:48 +00:00
|
|
|
REQUIRE(indicator == deco->Indicator());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("IsEmptyInitially") {
|
2019-05-04 18:14:48 +00:00
|
|
|
REQUIRE(0 == deco->Length());
|
|
|
|
REQUIRE(1 == deco->Runs());
|
|
|
|
REQUIRE(deco->Empty());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("SimpleSpace") {
|
2019-05-04 18:14:48 +00:00
|
|
|
deco->InsertSpace(0, 1);
|
|
|
|
REQUIRE(deco->Empty());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("SimpleRun") {
|
2019-05-04 18:14:48 +00:00
|
|
|
deco->InsertSpace(0, 1);
|
|
|
|
deco->SetValueAt(0, 2);
|
|
|
|
REQUIRE(!deco->Empty());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test DecorationList.
|
|
|
|
|
|
|
|
TEST_CASE("DecorationList") {
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
std::unique_ptr<IDecorationList> decol = DecorationListCreate(false);
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
SECTION("HasCorrectIndicator") {
|
2019-05-04 18:14:48 +00:00
|
|
|
decol->SetCurrentIndicator(indicator);
|
|
|
|
REQUIRE(indicator == decol->GetCurrentIndicator());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("HasCorrectCurrentValue") {
|
|
|
|
const int value = 55;
|
2019-05-04 18:14:48 +00:00
|
|
|
decol->SetCurrentValue(value);
|
|
|
|
REQUIRE(value == decol->GetCurrentValue());
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("ExpandSetValues") {
|
2019-05-04 18:14:48 +00:00
|
|
|
decol->SetCurrentIndicator(indicator);
|
|
|
|
decol->InsertSpace(0, 9);
|
2015-06-07 21:19:26 +00:00
|
|
|
const int value = 59;
|
2019-05-04 18:14:48 +00:00
|
|
|
const Sci::Position position = 4;
|
|
|
|
const Sci::Position 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);
|
2015-06-07 21:19:26 +00:00
|
|
|
const int indicatorB=6;
|
2019-05-04 18:14:48 +00:00
|
|
|
decol->SetCurrentIndicator(indicatorB);
|
|
|
|
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);
|
|
|
|
REQUIRE(decol->End(indicatorB, 5) == 6);
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|