length.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // { dg-do run { target c++11 } }
  2. // { dg-timeout-factor 2 }
  3. //
  4. // 2010-06-09 Stephen M. Webb <stephen.webb@bregmasoft.ca>
  5. //
  6. // Copyright (C) 2010-2022 Free Software Foundation, Inc.
  7. //
  8. // This file is part of the GNU ISO C++ Library. This library is free
  9. // software; you can redistribute it and/or modify it under the
  10. // terms of the GNU General Public License as published by the
  11. // Free Software Foundation; either version 3, or (at your option)
  12. // any later version.
  13. //
  14. // This library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License along
  20. // with this library; see the file COPYING3. If not see
  21. // <http://www.gnu.org/licenses/>.
  22. // 28.9.1 [re.submatch.members] sub_match members
  23. #include <regex>
  24. #include <testsuite_hooks.h>
  25. void
  26. test01()
  27. {
  28. typedef std::sub_match<const char*> sm_t;
  29. const char* test_data = "cabbage";
  30. sm_t::difference_type test_len = 3;
  31. sm_t sm1;
  32. sm1.first = test_data + 0;
  33. sm1.second = test_data + test_len;
  34. sm1.matched = true;
  35. sm_t sm2;
  36. sm2.matched = false;
  37. VERIFY( sm1.length() == test_len );
  38. VERIFY( sm2.length() == 0 );
  39. }
  40. int main()
  41. {
  42. test01();
  43. }