/** @file testSplitVector.cxx ** Unit Tests for Scintilla internal data structures **/ #include #include #include #include #include #include #include #include #include "Debugging.h" #include "Position.h" #include "SplitVector.h" #include "catch.hpp" using namespace Scintilla::Internal; // Test SplitVector. using UniqueInt = std::unique_ptr; // 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 s; SplitVector s2; // Copy constructor fails SplitVector sa(s); // Copy assignment fails SplitVector sb; sb = s; // Move constructor fails SplitVector sc(std::move(s)); // Move assignment fails SplitVector sd; sd = (std::move(s2)); } SECTION("MoveOnly") { SplitVector s; #if defined(SHOW_COPY_BUILD_FAILURES) // Copy is not defined for std::unique_ptr // Copy constructor fails SplitVector sa(s); // Copy assignment fails SplitVector sb; sb = s; #endif // Move constructor fails SplitVector sc(std::move(s)); // Move assignment fails SplitVector sd; sd = (std::move(s)); } } struct StringSetHolder { SplitVector sa; bool Check() const noexcept { for (int i = 0; i < sa.Length(); i++) { if (sa[i].empty()) { return false; } } return true; } }; constexpr int lengthTestArray = 4; static const int testArray[4] = {3, 4, 5, 6}; TEST_CASE("SplitVector") { SplitVector sv; SECTION("IsEmptyInitially") { REQUIRE(0 == sv.Length()); } SECTION("InsertOne") { sv.InsertValue(0, 10, 0); sv.Insert(5, 3); REQUIRE(11 == sv.Length()); for (int i=0; i=0; i--) { sv.InsertValue(i, 1, static_cast(i+5)); sv.Delete(i+1); } for (int i=0; i