blob: 05ef56b01bcaff6884cc793f5262c0d995409464 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
* glyph_ut.cpp --
*
* Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
* Alexander Gololobov <agololobov@gmail.com>
*
* This file is part of Pire, the Perl Incompatible
* Regular Expressions library.
*
* Pire is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pire is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
* You should have received a copy of the GNU Lesser Public License
* along with Pire. If not, see <http://www.gnu.org/licenses>.
*/
#include <pire.h>
#include <extra/glyphs.h>
#include "stub/cppunit.h"
#include "common.h"
Y_UNIT_TEST_SUITE(Glyphs) {
Pire::Fsm ParseFsm(const char* regexp)
{
TVector<wchar32> ucs4;
Pire::Encodings::Utf8().FromLocal(regexp, regexp + strlen(regexp), std::back_inserter(ucs4));
return Pire::Lexer(ucs4).SetEncoding(Pire::Encodings::Utf8()).AddFeature(Pire::Features::GlueSimilarGlyphs()).Parse().Surround();
}
#define NOGL_REGEXP(str) REGEXP2(str, "u")
#define GL_REGEXP(str) SCANNER(ParseFsm(str))
Y_UNIT_TEST(Glyphs)
{
NOGL_REGEXP("regexp") {
ACCEPTS("regexp");
DENIES("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80");
}
GL_REGEXP("regexp") {
ACCEPTS("regexp");
ACCEPTS("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80");
}
NOGL_REGEXP("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80") {
DENIES("regexp");
ACCEPTS("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80");
}
GL_REGEXP("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80") {
ACCEPTS("regexp");
ACCEPTS("r\xD0\xB5g\xD0\xB5\xD1\x85\xD1\x80");
}
}
}
|