aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/regex/pire/ut/easy_ut.cpp
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2025-06-25 00:23:21 +0300
committerthegeorg <thegeorg@yandex-team.com>2025-06-25 00:38:34 +0300
commite7147783ae6a23ee6675fa9f8ca6f43c6af17bc3 (patch)
tree454e5df12108188dd07fff8193566892d22e5909 /library/cpp/regex/pire/ut/easy_ut.cpp
parentebc5e196362b795c9a1ac8efa9d5a997cf07b1a4 (diff)
downloadydb-e7147783ae6a23ee6675fa9f8ca6f43c6af17bc3.tar.gz
pire was achived on GitHub, move the code into library/cpp/regex/pire
commit_hash:018daf4645e87c4e0b31e1191af4e75e48f6d958
Diffstat (limited to 'library/cpp/regex/pire/ut/easy_ut.cpp')
-rw-r--r--library/cpp/regex/pire/ut/easy_ut.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/library/cpp/regex/pire/ut/easy_ut.cpp b/library/cpp/regex/pire/ut/easy_ut.cpp
new file mode 100644
index 00000000000..5f0f8303fce
--- /dev/null
+++ b/library/cpp/regex/pire/ut/easy_ut.cpp
@@ -0,0 +1,57 @@
+/*
+ * easy_ut.cpp -- Unit tests for PireEasy
+ *
+ * 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 <stub/hacks.h>
+#include <stub/defaults.h>
+#include "stub/cppunit.h"
+#include <stdexcept>
+#include "common.h"
+
+#undef Run
+
+#include <easy.h>
+
+Y_UNIT_TEST_SUITE(TestPireEasy) {
+
+Y_UNIT_TEST(Match)
+{
+ Pire::Regexp re("(foo|bar)+", Pire::I);
+ UNIT_ASSERT("prefix fOoBaR suffix" ==~ re);
+ UNIT_ASSERT(!("bla bla bla" ==~ re));
+}
+
+Y_UNIT_TEST(Utf8)
+{
+ Pire::Regexp re("^.$", Pire::I | Pire::UTF8);
+ UNIT_ASSERT("\x41" ==~ re);
+ UNIT_ASSERT(!("\x81" ==~ re));
+}
+
+Y_UNIT_TEST(TwoFeatures)
+{
+ Pire::Regexp re("^(a.c&.b.)$", Pire::I | Pire::ANDNOT);
+ UNIT_ASSERT("abc" ==~ re);
+ UNIT_ASSERT("ABC" ==~ re);
+ UNIT_ASSERT(!("adc" ==~ re));
+}
+
+}