mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-08-27 04:38:26 +02:00
Release 5.5.5 (https://www.scintilla.org/scintilla555.zip) Released 25 February 2025. Remember selection with undo and redo. Controlled with SCI_SETUNDOSELECTIONHISTORY. Feature #1273, Bug #1479, Bug #1224. Serialize selection type and ranges with SCI_GETSELECTIONSERIALIZED and SCI_SETSELECTIONSERIALIZED. For Win32, update Direct2D and DirectWrite interfaces used to 1.1 and add a lower-level approach to calling DirectWrite 1.1 by specifying SC_TECHNOLOGY_DIRECT_WRITE_1. Since Windows Vista does not support these API versions, Scintilla o longer supports DirectWrite on Windows Vista and will fall back to using GDI. Fix segmentation of long lexemes to avoid breaking before modifiers like accents that must be drawn with their base letters. For wrapping, try to break lines without separating letters from modifiers. For GTK on Windows, replace reverse arrow cursor with hand as reverse arrow was small in scaled modes. Bug #2460. Fix bug on Qt where double-click stopped working when Scintilla instance had been running for weeks. Release 5.4.3 (https://www.scintilla.org/lexilla543.zip) Released 25 February 2025. C++: Fix evaluation of != in preprocessor condition. Issue #299. Modula-3: Allow digits in uppercase identifiers. Issue #297. Pascal: Fix asm style extending past end. Issue #295. Python: Fix detection of attributes and decorators. Issue #294, Pull request #302. Ruby: Implement substyles for identifiers SCE_RB_IDENTIFIER. Ruby: Recognize name as SCE_RB_DEFNAME in def when `::` used as well as `.`. Issue #300. Close #16235
132 lines
3.6 KiB
C++
132 lines
3.6 KiB
C++
/** @file testCharClassify.cxx
|
|
** Unit Tests for Scintilla internal data structures
|
|
**/
|
|
|
|
#include <cstring>
|
|
|
|
#include <string_view>
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <algorithm>
|
|
#include <memory>
|
|
#include <iostream>
|
|
|
|
#include "Debugging.h"
|
|
|
|
#include "CharClassify.h"
|
|
|
|
#include "catch.hpp"
|
|
|
|
using namespace Scintilla::Internal;
|
|
|
|
// Test CharClassify.
|
|
|
|
constexpr int byteValues = 256;
|
|
|
|
class CharClassifyTest {
|
|
public:
|
|
// Avoid warnings, deleted so never called.
|
|
CharClassifyTest(const CharClassifyTest &) = delete;
|
|
protected:
|
|
CharClassifyTest() {
|
|
pcc = std::make_unique<CharClassify>();
|
|
for (int ch = 0; ch < byteValues; ch++) {
|
|
if (ch == '\r' || ch == '\n')
|
|
charClass[ch] = CharacterClass::newLine;
|
|
else if (ch < 0x20 || ch == ' ' || ch == '\x7f')
|
|
charClass[ch] = CharacterClass::space;
|
|
else if (ch >= 0x80 || isalnum(ch) || ch == '_')
|
|
charClass[ch] = CharacterClass::word;
|
|
else
|
|
charClass[ch] = CharacterClass::punctuation;
|
|
}
|
|
}
|
|
|
|
std::unique_ptr<CharClassify> pcc;
|
|
CharacterClass charClass[byteValues] {};
|
|
|
|
static const char* GetClassName(CharacterClass charClass) noexcept {
|
|
switch(charClass) {
|
|
#define CASE(c) case CharacterClass::c: return #c
|
|
CASE(space);
|
|
CASE(newLine);
|
|
CASE(word);
|
|
CASE(punctuation);
|
|
#undef CASE
|
|
default:
|
|
return "<unknown>";
|
|
}
|
|
}
|
|
};
|
|
|
|
TEST_CASE_METHOD(CharClassifyTest, "Defaults") {
|
|
for (int i = 0; i < byteValues; i++) {
|
|
if (charClass[i] != pcc->GetClass(i)) {
|
|
std::cerr
|
|
<< "Character " << i
|
|
<< " should be class " << GetClassName(charClass[i])
|
|
<< ", but got " << GetClassName(pcc->GetClass(i)) << std::endl;
|
|
}
|
|
REQUIRE(charClass[i] == pcc->GetClass(i));
|
|
}
|
|
}
|
|
|
|
TEST_CASE_METHOD(CharClassifyTest, "Custom") {
|
|
unsigned char buf[2] = {0, 0};
|
|
for (int i = 0; i < byteValues; i++) {
|
|
const CharacterClass thisClass = static_cast<CharacterClass>(i % 4);
|
|
buf[0] = i;
|
|
pcc->SetCharClasses(buf, thisClass);
|
|
charClass[i] = thisClass;
|
|
}
|
|
for (int i = 0; i < byteValues; i++) {
|
|
if (charClass[i] != pcc->GetClass(i)) {
|
|
std::cerr
|
|
<< "Character " << i
|
|
<< " should be class " << GetClassName(charClass[i])
|
|
<< ", but got " << GetClassName(pcc->GetClass(i)) << std::endl;
|
|
}
|
|
REQUIRE(charClass[i] == pcc->GetClass(i));
|
|
}
|
|
}
|
|
|
|
TEST_CASE_METHOD(CharClassifyTest, "CharsOfClass") {
|
|
unsigned char buf[2] = {0, 0};
|
|
for (int i = 1; i < byteValues; i++) {
|
|
const CharacterClass thisClass = static_cast<CharacterClass>(i % 4);
|
|
buf[0] = i;
|
|
pcc->SetCharClasses(buf, thisClass);
|
|
charClass[i] = thisClass;
|
|
}
|
|
for (int classVal = 0; classVal < 4; ++classVal) {
|
|
const CharacterClass thisClass = static_cast<CharacterClass>(classVal % 4);
|
|
const int size = pcc->GetCharsOfClass(thisClass, nullptr);
|
|
std::vector<unsigned char> buffer(size+1);
|
|
const unsigned char *pBuffer = buffer.data();
|
|
pcc->GetCharsOfClass(thisClass, buffer.data());
|
|
for (int i = 1; i < byteValues; i++) {
|
|
if (charClass[i] == thisClass) {
|
|
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(pBuffer, i, size));
|
|
} else {
|
|
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(pBuffer, i, size));
|
|
}
|
|
}
|
|
}
|
|
}
|