From 5b3faa208ea29e45c6d845760bb902c3a9f057da Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Mon, 21 Jun 2021 13:34:23 +1000 Subject: Add tests for CharacterCategoryMap, RESearch, and Document. --- test/unit/testDocument.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/unit/testDocument.cxx (limited to 'test/unit/testDocument.cxx') diff --git a/test/unit/testDocument.cxx b/test/unit/testDocument.cxx new file mode 100644 index 000000000..983074daf --- /dev/null +++ b/test/unit/testDocument.cxx @@ -0,0 +1,59 @@ +/** @file testDocument.cxx + ** Unit Tests for Scintilla internal data structures + **/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ScintillaTypes.h" + +#include "ILoader.h" +#include "ILexer.h" + +#include "Debugging.h" + +#include "CharacterCategoryMap.h" +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "CellBuffer.h" +#include "CharClassify.h" +#include "Decoration.h" +#include "CaseFolder.h" +#include "Document.h" + +#include "catch.hpp" + +using namespace Scintilla; +using namespace Scintilla::Internal; + +// Test Document. + +TEST_CASE("Document") { + + const char sText[] = "Scintilla"; + const Sci::Position sLength = static_cast(strlen(sText)); + + Document doc(DocumentOption::Default); + + SECTION("InsertOneLine") { + const Sci::Position length = doc.InsertString(0, sText, sLength); + REQUIRE(sLength == doc.Length()); + REQUIRE(length == sLength); + REQUIRE(1 == doc.LinesTotal()); + REQUIRE(0 == doc.LineStart(0)); + REQUIRE(0 == doc.LineFromPosition(0)); + REQUIRE(sLength == doc.LineStart(1)); + REQUIRE(0 == doc.LineFromPosition(static_cast(sLength))); + REQUIRE(doc.CanUndo()); + REQUIRE(!doc.CanRedo()); + } + +} -- cgit v1.2.3