easy_ut.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * easy_ut.cpp -- Unit tests for PireEasy
  3. *
  4. * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
  5. * Alexander Gololobov <agololobov@gmail.com>
  6. *
  7. * This file is part of Pire, the Perl Incompatible
  8. * Regular Expressions library.
  9. *
  10. * Pire is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Lesser Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * Pire is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Lesser Public License for more details.
  19. * You should have received a copy of the GNU Lesser Public License
  20. * along with Pire. If not, see <http://www.gnu.org/licenses>.
  21. */
  22. #include <stub/hacks.h>
  23. #include <stub/defaults.h>
  24. #include "stub/cppunit.h"
  25. #include <stdexcept>
  26. #include "common.h"
  27. #undef Run
  28. #include <easy.h>
  29. Y_UNIT_TEST_SUITE(TestPireEasy) {
  30. Y_UNIT_TEST(Match)
  31. {
  32. Pire::Regexp re("(foo|bar)+", Pire::I);
  33. UNIT_ASSERT("prefix fOoBaR suffix" ==~ re);
  34. UNIT_ASSERT(!("bla bla bla" ==~ re));
  35. }
  36. Y_UNIT_TEST(Utf8)
  37. {
  38. Pire::Regexp re("^.$", Pire::I | Pire::UTF8);
  39. UNIT_ASSERT("\x41" ==~ re);
  40. UNIT_ASSERT(!("\x81" ==~ re));
  41. }
  42. Y_UNIT_TEST(TwoFeatures)
  43. {
  44. Pire::Regexp re("^(a.c&.b.)$", Pire::I | Pire::ANDNOT);
  45. UNIT_ASSERT("abc" ==~ re);
  46. UNIT_ASSERT("ABC" ==~ re);
  47. UNIT_ASSERT(!("adc" ==~ re));
  48. }
  49. }