diff options
author | Zufu Liu <unknown> | 2021-06-21 13:35:09 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-06-21 13:35:09 +1000 |
commit | 6de6577e1c9f8fad2852abb3b850f563fb7a04c6 (patch) | |
tree | 1d1a35fb028ad5a304afd9447311c60b3ba3f920 | |
parent | 5b3faa208ea29e45c6d845760bb902c3a9f057da (diff) | |
download | scintilla-mirror-rel-5-1-0.tar.gz |
Fix some warnings in unit tests.rel-5-1-0
-rw-r--r-- | test/unit/testCharClassify.cxx | 16 | ||||
-rw-r--r-- | test/unit/testDecoration.cxx | 12 | ||||
-rw-r--r-- | test/unit/testPartitioning.cxx | 4 | ||||
-rw-r--r-- | test/unit/testSplitVector.cxx | 12 | ||||
-rw-r--r-- | test/unit/testUniConversion.cxx | 2 |
5 files changed, 22 insertions, 24 deletions
diff --git a/test/unit/testCharClassify.cxx b/test/unit/testCharClassify.cxx index 0dd75c514..18bf9dc29 100644 --- a/test/unit/testCharClassify.cxx +++ b/test/unit/testCharClassify.cxx @@ -26,7 +26,7 @@ class CharClassifyTest { CharClassifyTest(const CharClassifyTest &) = delete; protected: CharClassifyTest() { - pcc.reset(new CharClassify()); + pcc = std::make_unique<CharClassify>(); for (int ch = 0; ch < 256; ch++) { if (ch == '\r' || ch == '\n') charClass[ch] = CharacterClass::newLine; @@ -39,9 +39,6 @@ protected: } } - ~CharClassifyTest() { - } - std::unique_ptr<CharClassify> pcc; CharacterClass charClass[256]; @@ -100,26 +97,27 @@ TEST_CASE_METHOD(CharClassifyTest, "CharsOfClass") { CharacterClass thisClass = CharacterClass(classVal % 4); int size = pcc->GetCharsOfClass(thisClass, NULL); std::vector<unsigned char> buffer(size+1); - pcc->GetCharsOfClass(thisClass, &buffer[0]); + void *pBuffer = static_cast<void *>(buffer.data()); + pcc->GetCharsOfClass(thisClass, buffer.data()); for (int i = 1; i < 256; i++) { if (charClass[i] == thisClass) { - if (!memchr(reinterpret_cast<char*>(&buffer[0]), i, size)) + if (!memchr(pBuffer, i, size)) std::cerr << "Character " << i << " should be class " << GetClassName(thisClass) << ", but was not in GetCharsOfClass;" << " it is reported to be " << GetClassName(pcc->GetClass(i)) << std::endl; - REQUIRE(memchr(reinterpret_cast<char*>(&buffer[0]), i, size)); + REQUIRE(memchr(pBuffer, i, size)); } else { - if (memchr(reinterpret_cast<char*>(&buffer[0]), i, size)) + if (memchr(pBuffer, i, size)) std::cerr << "Character " << i << " should not be class " << GetClassName(thisClass) << ", but was in GetCharsOfClass" << " it is reported to be " << GetClassName(pcc->GetClass(i)) << std::endl; - REQUIRE_FALSE(memchr(reinterpret_cast<char*>(&buffer[0]), i, size)); + REQUIRE_FALSE(memchr(pBuffer, i, size)); } } } diff --git a/test/unit/testDecoration.cxx b/test/unit/testDecoration.cxx index 023b44163..fd43bc238 100644 --- a/test/unit/testDecoration.cxx +++ b/test/unit/testDecoration.cxx @@ -22,7 +22,7 @@ #include "catch.hpp" -const int indicator=4; +constexpr int indicator=4; using namespace Scintilla::Internal; @@ -66,7 +66,7 @@ TEST_CASE("DecorationList") { } SECTION("HasCorrectCurrentValue") { - const int value = 55; + constexpr int value = 55; decol->SetCurrentValue(value); REQUIRE(value == decol->GetCurrentValue()); } @@ -74,9 +74,9 @@ TEST_CASE("DecorationList") { SECTION("ExpandSetValues") { decol->SetCurrentIndicator(indicator); decol->InsertSpace(0, 9); - const int value = 59; - const Sci::Position position = 4; - const Sci::Position fillLength = 3; + constexpr int value = 59; + constexpr Sci::Position position = 4; + constexpr Sci::Position fillLength = 3; auto fr = decol->FillRange(position, value, fillLength); REQUIRE(fr.changed); REQUIRE(fr.position == 4); @@ -85,7 +85,7 @@ TEST_CASE("DecorationList") { REQUIRE(decol->AllOnFor(5) == (1 << indicator)); REQUIRE(decol->Start(indicator, 5) == 4); REQUIRE(decol->End(indicator, 5) == 7); - const int indicatorB=6; + constexpr int indicatorB=6; decol->SetCurrentIndicator(indicatorB); fr = decol->FillRange(position, value, fillLength); REQUIRE(fr.changed); diff --git a/test/unit/testPartitioning.cxx b/test/unit/testPartitioning.cxx index e28ef318e..b2b7598d8 100644 --- a/test/unit/testPartitioning.cxx +++ b/test/unit/testPartitioning.cxx @@ -22,9 +22,9 @@ using namespace Scintilla::Internal; -const int growSize = 4; +constexpr int growSize = 4; -const int lengthTestArray = 8; +constexpr int lengthTestArray = 8; static const int testArray[lengthTestArray] = {3, 4, 5, 6, 7, 8, 9, 10}; // Test SplitVectorWithRangeAdd. diff --git a/test/unit/testSplitVector.cxx b/test/unit/testSplitVector.cxx index 8320d5bcb..aa855f1b1 100644 --- a/test/unit/testSplitVector.cxx +++ b/test/unit/testSplitVector.cxx @@ -25,7 +25,7 @@ using namespace Scintilla::Internal; struct StringSetHolder { SplitVector<std::string> sa; - bool Check() { + bool Check() const noexcept { for (int i = 0; i < sa.Length(); i++) { if (sa[i].empty()) { return false; @@ -35,7 +35,7 @@ struct StringSetHolder { } }; -const int lengthTestArray = 4; +constexpr int lengthTestArray = 4; static const int testArray[4] = {3, 4, 5, 6}; TEST_CASE("SplitVector") { @@ -279,7 +279,7 @@ TEST_CASE("SplitVector") { SECTION("ReplaceUp") { // Replace each element by inserting and then deleting the displaced element // This should perform many moves - const int testLength=105; + constexpr int testLength=105; sv.EnsureLength(testLength); for (int i=0; i<testLength; i++) sv.SetValueAt(i, i+2); @@ -295,7 +295,7 @@ TEST_CASE("SplitVector") { SECTION("ReplaceDown") { // From the end, replace each element by inserting and then deleting the displaced element // This should perform many moves - const int testLength=24; + constexpr int testLength=24; sv.EnsureLength(testLength); for (int i=0; i<testLength; i++) sv.SetValueAt(i, i+12); @@ -313,9 +313,9 @@ TEST_CASE("SplitVector") { sv.InsertFromArray(0, testArray, 0, lengthTestArray); sv.Insert(0, 99); // This moves the gap so that BufferPointer() must also move REQUIRE(1 == sv.GapPosition()); - const int lengthAfterInsertion = 1 + lengthTestArray; + constexpr int lengthAfterInsertion = 1 + lengthTestArray; REQUIRE(lengthAfterInsertion == (sv.Length())); - int *retrievePointer = sv.BufferPointer(); + const int *retrievePointer = sv.BufferPointer(); for (int i=1; i<sv.Length(); i++) { REQUIRE((i+3-1) == retrievePointer[i]); } diff --git a/test/unit/testUniConversion.cxx b/test/unit/testUniConversion.cxx index eabb46442..2ee05103e 100644 --- a/test/unit/testUniConversion.cxx +++ b/test/unit/testUniConversion.cxx @@ -255,7 +255,7 @@ TEST_CASE("UniConversion") { namespace { // Simple adapter to avoid casting -int UTFClass(const char *s) { +int UTFClass(const char *s) noexcept { return UTF8Classify(reinterpret_cast<const unsigned char *>(s), static_cast<int>(strlen(s))); } |