icase.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // { dg-do run { target c++11 } }
  2. // { dg-timeout-factor 2 }
  3. //
  4. // Copyright (C) 2016-2022 Free Software Foundation, Inc.
  5. //
  6. // This file is part of the GNU ISO C++ Library. This library is free
  7. // software; you can redistribute it and/or modify it under the
  8. // terms of the GNU General Public License as published by the
  9. // Free Software Foundation; either version 3, or (at your option)
  10. // any later version.
  11. //
  12. // This library is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License along
  18. // with this library; see the file COPYING3. If not see
  19. // <http://www.gnu.org/licenses/>.
  20. // 28.7 Class template regex_traits [re.traits]
  21. #include <regex>
  22. #include <testsuite_hooks.h>
  23. using namespace std;
  24. void
  25. test01()
  26. {
  27. {
  28. regex re("[T-f]", regex::icase);
  29. VERIFY(regex_match("A", re));
  30. VERIFY(regex_match("F", re));
  31. VERIFY(regex_match("a", re));
  32. VERIFY(regex_match("f", re));
  33. VERIFY(!regex_match("G", re));
  34. VERIFY(!regex_match("S", re));
  35. VERIFY(!regex_match("g", re));
  36. VERIFY(!regex_match("s", re));
  37. VERIFY(regex_match("T", re));
  38. VERIFY(regex_match("Z", re));
  39. VERIFY(regex_match("t", re));
  40. VERIFY(regex_match("z", re));
  41. }
  42. // icase works with std::regex_traits<>, because we know how it's implemented.
  43. {
  44. regex re("[T-f]", regex::icase | regex::collate);
  45. VERIFY(regex_match("A", re));
  46. VERIFY(regex_match("F", re));
  47. VERIFY(regex_match("a", re));
  48. VERIFY(regex_match("f", re));
  49. VERIFY(!regex_match("G", re));
  50. VERIFY(!regex_match("S", re));
  51. VERIFY(!regex_match("g", re));
  52. VERIFY(!regex_match("s", re));
  53. VERIFY(regex_match("T", re));
  54. VERIFY(regex_match("Z", re));
  55. VERIFY(regex_match("t", re));
  56. VERIFY(regex_match("z", re));
  57. }
  58. }
  59. int main()
  60. {
  61. test01();
  62. return 0;
  63. }