diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
82 files changed, 3631 insertions, 19 deletions
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/62258.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/62258.cc new file mode 100644 index 0000000000..3734f193b0 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/62258.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// PR libstdc++/62258 + +#include <exception> +#include <testsuite_hooks.h> + +struct check_on_destruct +{ + ~check_on_destruct(); +}; + +check_on_destruct::~check_on_destruct() +{ + VERIFY(std::uncaught_exception()); +} + +int main () +{ + VERIFY(!std::uncaught_exception()); + + try + { + check_on_destruct check; + + try + { + throw 1; + } + catch (...) + { + VERIFY(!std::uncaught_exception()); + + std::rethrow_exception(std::current_exception()); + } + } + catch (...) + { + VERIFY(!std::uncaught_exception()); + } + + VERIFY(!std::uncaught_exception()); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc new file mode 100644 index 0000000000..1aa00ddc1f --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc new file mode 100644 index 0000000000..7af6db3ff4 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char16_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc new file mode 100644 index 0000000000..a7730ec258 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char32_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc new file mode 100644 index 0000000000..22dfdf0351 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = wchar_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc new file mode 100644 index 0000000000..3f99cb416f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <codecvt> +#include <testsuite_hooks.h> + +void +test01() +{ + std::codecvt_utf8_utf16<char16_t> cvt; + char16_t utf16[] = u"\ub098\ub294\ud0dc\uc624"; + const char16_t* nf16; + char utf8[16]; + char* nt8; + std::mbstate_t st{}; + auto res = cvt.out(st, utf16, utf16+4, nf16, utf8, utf8+16, nt8); + VERIFY( res == std::codecvt_base::ok ); + + st = {}; + char16_t buf[4] = {}; + const char* nf8 = nt8; + char16_t* nt16; + res = cvt.in(st, utf8, nf8, nf8, buf, buf+4, nt16); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( nt16 == buf+4 ); + VERIFY( buf[0] == utf16[0] ); + VERIFY( buf[1] == utf16[1] ); + VERIFY( buf[2] == utf16[2] ); + VERIFY( buf[3] == utf16[3] ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc index c8584378cb..1b8a0e4e2f 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc @@ -36,6 +36,11 @@ void test01() VERIFY(1 == v1.get_allocator().get_personality()); VERIFY(1 == v2.get_allocator().get_personality()); VERIFY( it == v2.begin() ); + + // PR libstdc++/67707 + VERIFY( v1.size() == 0 ); + v1 = test_type(); + VERIFY( v1.size() == 0 ); } void test02() @@ -47,6 +52,11 @@ void test02() test_type v2(std::move(v1), alloc_type(2)); VERIFY(1 == v1.get_allocator().get_personality()); VERIFY(2 == v2.get_allocator().get_personality()); + + // PR libstdc++/67707 + VERIFY( v1.size() == 0 ); + v1 = test_type(); + VERIFY( v1.size() == 0 ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index 8604250696..dd3e128180 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1881 } +// { dg-error "no matching" "" { target *-*-* } 1882 } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index e8fadaabf4..1115b61ffe 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1814 } +// { dg-error "no matching" "" { target *-*-* } 1815 } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index 1444343dfa..949ea4491a 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1814 } +// { dg-error "no matching" "" { target *-*-* } 1815 } #include <deque> #include <utility> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index 0310cf2474..208e2d9259 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1965 } +// { dg-error "no matching" "" { target *-*-* } 1966 } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc index 6cc277aedc..ef301ef136 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "find returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc index 67c3bfd60a..eef6ee4515 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "find returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc index ff2748f713..4bea719160 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "find returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc index 84ddd1f1dd..6a68453ec7 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc @@ -54,6 +54,11 @@ test01() VERIFY( cit == cx.end() ); VERIFY( Cmp::count == 0); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "find returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const find returns const_iterator"); } void diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc index 983ac95e53..36bed1486a 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc @@ -20,7 +20,7 @@ // { dg-do compile } // { dg-add-options no_pch } -// { dg-xfail-if "" { { *-*-linux* *-*-gnu* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* *-*-mingw* *-*-aix* } || { uclibc || newlib } } { "*" } { "" } } +// { dg-xfail-if "" { { *-*-linux* *-*-gnu* *-*-darwin* *-*-solaris2.1[01]* hppa*-*-hpux* *-*-mingw* *-*-aix* } || { uclibc || newlib } } { "*" } { "" } } // { dg-excess-errors "" { target { { *-*-linux* *-*-gnu* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* *-*-mingw* *-*-aix* } || { uclibc || newlib } } } } #include <math.h> diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc index eb8ca3e9db..2a929b537e 100644 --- a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc @@ -28,4 +28,7 @@ test01() std::valarray<double> va{1.0, 2.0, 3.0}; std::begin(va); std::end(va); + const auto& cva = va; + std::begin(cva); + std::end(cva); } diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc new file mode 100644 index 0000000000..1c7a48581b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++14" } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.6.10 valarray range access: [valarray.range] + +#include <iterator> +#include <valarray> + +// PR libstdc++/67374 +void +test01() +{ + std::valarray<double> va{1.0, 2.0, 3.0}; + std::cbegin(va); + std::cend(va); + const auto& cva = va; + std::cbegin(cva); + std::cend(cva); +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc index 591e371436..7fb0a18b52 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-Wall" { target *-*-* } } +// { dg-options "-Wall -std=gnu++14" { target *-*-* } } // -*- C++ -*- // Copyright (C) 2004-2015 Free Software Foundation, Inc. @@ -70,5 +70,11 @@ case_labels(bitmask_type b) break; case std::_S_ios_fmtflags_end: break; + case __INT_MAX__: + break; + case ~__INT_MAX__: + break; } + static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int), + "underlying type has same range of values as int"); } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc index 44fb44e7a8..a44bca35af 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-Wall" { target *-*-* } } +// { dg-options "-Wall -std=gnu++14" { target *-*-* } } // -*- C++ -*- // Copyright (C) 2004-2015 Free Software Foundation, Inc. @@ -42,5 +42,11 @@ case_labels(bitmask_type b) break; case std::_S_ios_iostate_end: break; + case __INT_MAX__: + break; + case ~__INT_MAX__: + break; } + static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int), + "underlying type has same range of values as int"); } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc index 267f8a228b..43ddd19fb9 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-Wall" { target *-*-* } } +// { dg-options "-Wall -std=gnu++14" { target *-*-* } } // -*- C++ -*- // Copyright (C) 2004-2015 Free Software Foundation, Inc. @@ -46,5 +46,11 @@ case_labels(bitmask_type b) break; case std::_S_ios_openmode_end: break; + case __INT_MAX__: + break; + case ~__INT_MAX__: + break; } + static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int), + "underlying type has same range of values as int"); } diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc index f7653c6dc9..62131a0bcc 100644 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc @@ -82,6 +82,22 @@ test02() VERIFY(e.code() == std::regex_constants::error_range); } std::regex re("[-----]", std::regex::ECMAScript); + + VERIFY(!regex_match("b", regex("[-ac]", regex_constants::extended))); + VERIFY(!regex_match("b", regex("[ac-]", regex_constants::extended))); + VERIFY(regex_match("b", regex("[^-ac]", regex_constants::extended))); + VERIFY(regex_match("b", regex("[^ac-]", regex_constants::extended))); + VERIFY(regex_match("&", regex("[%--]", regex_constants::extended))); + VERIFY(regex_match(".", regex("[--@]", regex_constants::extended))); + try + { + regex("[a--@]", regex_constants::extended); + VERIFY(false); + } + catch (const std::regex_error& e) + { + } + VERIFY(regex_match("].", regex("[][.hyphen.]-0]*", regex_constants::extended))); } void @@ -115,6 +131,44 @@ test04() VERIFY(regex_match_debug("w", re)); } +// libstdc++/67015 +void +test05() +{ + bool test __attribute__((unused)) = true; + + regex lanana_namespace("^[a-z0-9]+$", regex::extended); + regex lsb_namespace("^_?([a-z0-9_.]+-, regex::extended)+[a-z0-9]+$"); + regex debian_dpkg_conffile_cruft("dpkg-(old|dist|new|tmp, regex::extended)$"); + regex debian_cron_namespace("^[a-z0-9][a-z0-9-]*$", regex::extended); + VERIFY(regex_match("test", debian_cron_namespace)); + VERIFY(!regex_match("-a", debian_cron_namespace)); + VERIFY(regex_match("a-", debian_cron_namespace)); + regex debian_cron_namespace_ok("^[a-z0-9][-a-z0-9]*$", regex::extended); + VERIFY(regex_match("test", debian_cron_namespace_ok)); + VERIFY(!regex_match("-a", debian_cron_namespace_ok)); + VERIFY(regex_match("a-", debian_cron_namespace_ok)); +} + +// libstdc++/67015 +void +test06() +{ + bool test __attribute__((unused)) = true; + + regex lanana_namespace("^[a-z0-9]+$"); + regex lsb_namespace("^_?([a-z0-9_.]+-)+[a-z0-9]+$"); + regex debian_dpkg_conffile_cruft("dpkg-(old|dist|new|tmp)$"); + regex debian_cron_namespace("^[a-z0-9][a-z0-9-]*$"); + VERIFY(regex_match("test", debian_cron_namespace)); + VERIFY(!regex_match("-a", debian_cron_namespace)); + VERIFY(regex_match("a-", debian_cron_namespace)); + regex debian_cron_namespace_ok("^[a-z0-9][-a-z0-9]*$"); + VERIFY(regex_match("test", debian_cron_namespace_ok)); + VERIFY(!regex_match("-a", debian_cron_namespace_ok)); + VERIFY(regex_match("a-", debian_cron_namespace_ok)); +} + int main() { @@ -122,5 +176,8 @@ main() test02(); test03(); test04(); + test05(); + test06(); + return 0; } diff --git a/libstdc++-v3/testsuite/28_regex/regression.cc b/libstdc++-v3/testsuite/28_regex/regression.cc new file mode 100644 index 0000000000..71d82d5045 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/regression.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <testsuite_regex.h> + +using namespace __gnu_test; +using namespace std; + +// PR libstdc++/67362 +void +test01() +{ + bool test __attribute__((unused)) = true; + + regex re("((.)", regex_constants::basic); +} + +int +main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc b/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc new file mode 100644 index 0000000000..dbdd9cf7db --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic/65913.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target x86_64-*-linux* powerpc*-*-linux* } } +// { dg-options "-std=gnu++11 -O0" } + +#include <atomic> +#include <testsuite_hooks.h> + +// PR libstdc++/65913 + +void +test01() +{ + struct Int { int i; }; + VERIFY( std::atomic<Int>{}.is_lock_free() ); + VERIFY( std::atomic<int>{}.is_lock_free() ); + VERIFY( std::atomic<int*>{}.is_lock_free() ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index ac64520f77..e0e7114147 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,6 +15,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -67,6 +84,11 @@ CONFIG_CLEAN_VPATH_FILES = depcomp = am__depfiles_maybe = SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ABI_TWEAKS_SRCDIR = @ABI_TWEAKS_SRCDIR@ ACLOCAL = @ACLOCAL@ ALLOCATOR_H = @ALLOCATOR_H@ @@ -370,6 +392,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; +$(top_srcdir)/fragment.am: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh @@ -405,10 +428,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc new file mode 100644 index 0000000000..56b808d325 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + std::error_code ec; + + // Test non-existent path. + const auto p = __gnu_test::nonexistent_path(); + fs::directory_iterator iter(p, ec); + VERIFY( ec ); + VERIFY( iter != fs::directory_iterator() ); + + // Test empty directory. + create_directory(p, fs::current_path(), ec); + VERIFY( !ec ); + iter = fs::directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter == fs::directory_iterator() ); + + // Test non-empty directory. + create_directory_symlink(p, p / "l", ec); + VERIFY( !ec ); + iter = fs::directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter != fs::directory_iterator() ); + VERIFY( iter->path() == p/"l" ); + ++iter; + VERIFY( iter == fs::directory_iterator() ); + + // Test inaccessible directory. + permissions(p, fs::perms::none, ec); + VERIFY( !ec ); + iter = fs::directory_iterator(p, ec); + VERIFY( ec ); + VERIFY( iter != fs::directory_iterator() ); + + // Test inaccessible directory, skipping permission denied. + const auto opts = fs::directory_options::skip_permission_denied; + iter = fs::directory_iterator(p, opts, ec); + VERIFY( !ec ); + VERIFY( iter == fs::directory_iterator() ); + + permissions(p, fs::perms::owner_all, ec); + remove_all(p, ec); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc new file mode 100644 index 0000000000..9424c80ab8 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -0,0 +1,104 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + std::error_code ec; + + // Test non-existent path. + const auto p = __gnu_test::nonexistent_path(); + fs::recursive_directory_iterator iter(p, ec); + VERIFY( ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + + // Test empty directory. + create_directory(p, fs::current_path(), ec); + VERIFY( !ec ); + iter = fs::recursive_directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter == fs::recursive_directory_iterator() ); + + // Test non-empty directory. + create_directories(p / "d1/d2"); + VERIFY( !ec ); + iter = fs::recursive_directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + VERIFY( iter->path() == p/"d1" ); + ++iter; + VERIFY( iter->path() == p/"d1/d2" ); + ++iter; + VERIFY( iter == fs::recursive_directory_iterator() ); + + // Test inaccessible directory. + permissions(p, fs::perms::none, ec); + VERIFY( !ec ); + iter = fs::recursive_directory_iterator(p, ec); + VERIFY( ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + + // Test inaccessible directory, skipping permission denied. + const auto opts = fs::directory_options::skip_permission_denied; + iter = fs::recursive_directory_iterator(p, opts, ec); + VERIFY( !ec ); + VERIFY( iter == fs::recursive_directory_iterator() ); + + // Test inaccessible sub-directory. + permissions(p, fs::perms::owner_all, ec); + VERIFY( !ec ); + permissions(p/"d1/d2", fs::perms::none, ec); + VERIFY( !ec ); + iter = fs::recursive_directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + VERIFY( iter->path() == p/"d1" ); + ++iter; // should recurse into d1 + VERIFY( iter->path() == p/"d1/d2" ); + iter.increment(ec); // should fail to recurse into p/d1/d2 + VERIFY( ec ); + + // Test inaccessible sub-directory, skipping permission denied. + iter = fs::recursive_directory_iterator(p, opts, ec); + VERIFY( !ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + VERIFY( iter->path() == p/"d1" ); + ++iter; // should recurse into d1 + VERIFY( iter->path() == p/"d1/d2" ); + iter.increment(ec); // should fail to recurse into p/d1/d2, so skip it + VERIFY( !ec ); + VERIFY( iter == fs::recursive_directory_iterator() ); + + permissions(p/"d1/d2", fs::perms::owner_all, ec); + remove_all(p, ec); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/absolute.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/absolute.cc new file mode 100644 index 0000000000..f7507f5772 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/absolute.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 15.1 Absolute [fs.op.absolute] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + for (const path& p : __gnu_test::test_paths) + VERIFY( absolute(p).is_absolute() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + path p1("/"); + VERIFY( absolute(p1) == p1 ); + VERIFY( absolute(p1, "/bar") == p1 ); + path p2("/foo"); + VERIFY( absolute(p2) == p2 ); + VERIFY( absolute(p2, "/bar") == p2 ); + path p3("foo"); + VERIFY( absolute(p3) != p3 ); + VERIFY( absolute(p3, "/bar") == "/bar/foo" ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc new file mode 100644 index 0000000000..5091a709c4 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + auto p = __gnu_test::nonexistent_path(); + canonical( p, ec ); + VERIFY( ec ); + + p = fs::current_path(); + canonical( p, ec ); + VERIFY( !ec ); + + p = "/"; + p = canonical( p, ec ); + VERIFY( p == "/" ); + VERIFY( !ec ); + + p = "/."; + p = canonical( p, ec ); + VERIFY( p == "/" ); + VERIFY( !ec ); + + p = "/.."; + p = canonical( p, ec ); + VERIFY( p == "/" ); + VERIFY( !ec ); + + p = "/../.././."; + p = canonical( p, ec ); + VERIFY( p == "/" ); + VERIFY( !ec ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc new file mode 100644 index 0000000000..35d49f0f7f --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 15.3 Copy [fs.op.copy] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + for (const path& p : __gnu_test::test_paths) + VERIFY( absolute(p).is_absolute() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + path p1("/"); + VERIFY( absolute(p1) == p1 ); + VERIFY( absolute(p1, "/bar") == p1 ); + path p2("/foo"); + VERIFY( absolute(p2) == p2 ); + VERIFY( absolute(p2, "/bar") == p2 ); + path p3("foo"); + VERIFY( absolute(p3) != p3 ); + VERIFY( absolute(p3, "/bar") == "/bar/foo" ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc new file mode 100644 index 0000000000..b84d966ad7 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + std::error_code ec; + + // Test empty path. + bool b = fs::create_directories( "", ec ); + VERIFY( ec ); + VERIFY( !b ); + + // Test existing path. + b = fs::create_directories( fs::current_path(), ec ); + VERIFY( !ec ); + VERIFY( !b ); + + // Test non-existent path. + const auto p = __gnu_test::nonexistent_path(); + b = fs::create_directories( p, ec ); + VERIFY( !ec ); + VERIFY( b ); + VERIFY( is_directory(p) ); + + b = fs::create_directories( p/".", ec ); + VERIFY( !ec ); + VERIFY( !b ); + + b = fs::create_directories( p/"..", ec ); + VERIFY( !ec ); + VERIFY( !b ); + + b = fs::create_directories( p/"d1/d2/d3", ec ); + VERIFY( !ec ); + VERIFY( b ); + VERIFY( is_directory(p/"d1/d2/d3") ); + + b = fs::create_directories( p/"./d4/../d5", ec ); + VERIFY( !ec ); + VERIFY( b ); + VERIFY( is_directory(p/"./d4/../d5") ); + + remove_all(p, ec); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/current_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/current_path.cc new file mode 100644 index 0000000000..81ade73ab5 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/current_path.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 15.11 Current path [fs.op.current_path] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + fs::path dot("."); + fs::path cwd = fs::current_path(); + std::error_code ec; + fs::path cwd2 = fs::current_path(ec); + VERIFY( cwd == cwd2 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + auto oldwd = fs::current_path(); + auto tmpdir = fs::temp_directory_path(); + current_path(tmpdir); + VERIFY( canonical(fs::current_path()) == canonical(tmpdir) ); + std::error_code ec; + current_path(oldwd, ec); + VERIFY( canonical(fs::current_path()) == canonical(oldwd) ); + VERIFY( canonical(fs::current_path(ec)) == canonical(oldwd) ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc new file mode 100644 index 0000000000..dba4a6f5a5 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + VERIFY( exists(path{"/"}) ); + VERIFY( exists(path{"/."}) ); + VERIFY( exists(path{"."}) ); + VERIFY( exists(path{".."}) ); + VERIFY( exists(std::experimental::filesystem::current_path()) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + path rel = __gnu_test::nonexistent_path(); + VERIFY( !exists(rel) ); +} + +void +test03() +{ + bool test __attribute__((unused)) = false; + + path abs = absolute(__gnu_test::nonexistent_path()); + VERIFY( !exists(abs) ); +} + +int +main() +{ + test01(); + test02(); + test03(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc new file mode 100644 index 0000000000..7603064d46 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + size_t size = fs::file_size(".", ec); + VERIFY( ec == std::errc::is_a_directory ); + VERIFY( size == -1 ); + + try { + size = fs::file_size("."); + ec.clear(); + } catch (const fs::filesystem_error& e) { + ec = e.code(); + } + VERIFY( ec == std::errc::is_a_directory ); + VERIFY( size == -1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + fs::path p = __gnu_test::nonexistent_path(); + + std::error_code ec; + size_t size = fs::file_size(p, ec); + VERIFY( ec ); + VERIFY( size == -1 ); + + try { + size = fs::file_size(p); + ec.clear(); + } catch (const fs::filesystem_error& e) { + ec = e.code(); + } + VERIFY( ec ); + VERIFY( size == -1 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/status.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/status.cc new file mode 100644 index 0000000000..0f1730d82f --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/status.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + fs::file_status st1 = fs::status(".", ec); + VERIFY( !ec ); + VERIFY( st1.type() == fs::file_type::directory ); + + fs::file_status st2 = fs::status("."); + VERIFY( st2.type() == fs::file_type::directory ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + fs::path p = __gnu_test::nonexistent_path(); + + std::error_code ec; + fs::file_status st1 = fs::status(p, ec); + VERIFY( ec ); + VERIFY( st1.type() == fs::file_type::not_found ); + + fs::file_status st2 = fs::status(p); + VERIFY( st2.type() == fs::file_type::not_found ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc new file mode 100644 index 0000000000..bd9b6adf3e --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <stdlib.h> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +void +clean_env() +{ + ::unsetenv("TMPDIR"); + ::unsetenv("TMP"); + ::unsetenv("TEMPDIR"); + ::unsetenv("TEMP"); +} + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + + clean_env(); + + if (!fs::exists("/tmp")) + return; // just give up + + std::error_code ec; + fs::path p1 = fs::temp_directory_path(ec); + VERIFY( exists(p1) ); + + fs::path p2 = fs::temp_directory_path(); + VERIFY( p1 == p2 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = false; + + clean_env(); + + if (::setenv("TMPDIR", __gnu_test::nonexistent_path().string().c_str(), 1)) + return; // just give up + + std::error_code ec; + fs::path p = fs::temp_directory_path(ec); + VERIFY( ec ); + + std::error_code ec2; + try { + p = fs::temp_directory_path(); + } catch (const fs::filesystem_error& e) { + ec2 = e.code(); + } + VERIFY( ec2 == ec ); +} + + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/append/path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/append/path.cc new file mode 100644 index 0000000000..75d2df0c8a --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/append/path.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.3 path appends [path.append] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + const path p("/foo/bar"); + + path pp = p; + pp /= p; + VERIFY( pp.native() == "/foo/bar/foo/bar" ); + + path q("baz"); + + path qq = q; + qq /= q; + VERIFY( qq.native() == "baz/baz" ); + + q /= p; + VERIFY( q.native() == "baz/foo/bar" ); + + path r = ""; + r /= path(); + VERIFY( r.empty() ); + + r /= path("rel"); + VERIFY( !r.is_absolute() ); + + path s = "dir/"; + s /= path("/file"); + VERIFY( s.native() == "dir//file" ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc new file mode 100644 index 0000000000..fe4f96cde9 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; +using __gnu_test::compare_paths; + +void +test01() +{ + for (std::string s : __gnu_test::test_paths) + { + path p0 = s, p1, p2, p3, p4; + + p1 = s; + compare_paths(p0, p1); + + p2 = s.c_str(); + compare_paths(p0, p2); + +#if _GLIBCXX_USE_WCHAR_T + std::wstring ws(s.begin(), s.end()); + + p3 = ws; + compare_paths(p0, p3); + + p4 = ws.c_str(); + compare_paths(p0, p4); +#endif + } +} + +void +test02() +{ + for (std::string s : __gnu_test::test_paths) + { + path p0 = s, p1, p2, p3, p4, p5, p6, p7, p8; + + p1.assign(s); + compare_paths(p0, p1); + + p2.assign( s.begin(), s.end() ); + compare_paths(p0, p2); + + p3.assign( s.c_str() ); + compare_paths(p0, p3); + + p4.assign( s.c_str(), s.c_str() + s.size() ); + compare_paths(p0, p4); + +#if _GLIBCXX_USE_WCHAR_T + std::wstring ws(s.begin(), s.end()); + + p5.assign(ws); + compare_paths(p0, p5); + + p6.assign( ws.begin(), ws.end() ); + compare_paths(p0, p6); + + p7.assign( ws.c_str() ); + compare_paths(p0, p7); + + p8.assign( ws.c_str(), ws.c_str() + ws.size() ); + compare_paths(p0, p8); +#endif + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/assign/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/copy.cc new file mode 100644 index 0000000000..29dbcd4035 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/copy.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <experimental/filesystem> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; +using __gnu_test::compare_paths; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + path copy; + copy = p; + __gnu_test::compare_paths(p, copy); + } +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path copy = p; + path move; + move = std::move(copy); + __gnu_test::compare_paths(p, move); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/compare/compare.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/compare.cc new file mode 100644 index 0000000000..e8f5e41cfa --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/compare.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.8 path compare [path.compare] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p("/foo/bar"); + VERIFY( p.compare(p) == 0 ); + VERIFY( p.compare("/foo//bar") == 0 ); + + path q("/foo/baz"); + VERIFY( p.compare(q) < 0 ); + VERIFY( q.compare(p) > 0 ); + + path r("/foo/bar/."); + VERIFY( p.compare(r) < 0 ); + + VERIFY( path("a/b/").compare("a/b/.") == 0 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/compare/path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/path.cc new file mode 100644 index 0000000000..7858af1622 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/path.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.8 path compare [path.compare] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + const path p0 = "/a/a/b/b"; + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.compare(p) == 0 ); + int cmp = p.compare(p0); + if (cmp == 0) + VERIFY( p0.compare(p) == 0 ); + else if (cmp < 0) + VERIFY( p0.compare(p) > 0 ); + else if (cmp > 0) + VERIFY( p0.compare(p) < 0 ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/compare/strings.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/strings.cc new file mode 100644 index 0000000000..7e6156819a --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/compare/strings.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.8 path compare [path.compare] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + const std::string s0 = "/a/a/b/b"; + const path p0 = s0; + for (const std::string& s : __gnu_test::test_paths) + { + path p(s); + VERIFY( p.compare(s) == 0 ); + VERIFY( p.compare(s.c_str()) == 0 ); + VERIFY( p.compare(p0) == p.compare(s0) ); + VERIFY( p.compare(p0) == p.compare(s0.c_str()) ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/concat/path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/path.cc new file mode 100644 index 0000000000..fceae117d2 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/path.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.4 path concatenation [path.concat] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + const path p("/foo/bar"); + + path pp = p; + pp += p; + VERIFY( pp.native() == "/foo/bar/foo/bar" ); + VERIFY( std::distance(pp.begin(), pp.end()) == 5 ); + + path q("foo/bar"); + + path qq = q; + qq += q; + VERIFY( qq.native() == "foo/barfoo/bar" ); + VERIFY( std::distance(qq.begin(), qq.end()) == 3 ); + + q += p; + VERIFY( q.native() == "foo/bar/foo/bar" ); + VERIFY( std::distance(q.begin(), q.end()) == 4 ); +} + +void +test02() +{ + for (path p : __gnu_test::test_paths) + { + auto prior_native = p.native(); + path x("//blah/di/blah"); + p += x; + VERIFY( p.native() == prior_native + x.native() ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc new file mode 100644 index 0000000000..61ef7e40cf --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.4 path concatenation [path.concat] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p("/"); + p += path::string_type("foo"); + VERIFY( p.filename() == "foo" ); + p += "bar"; + VERIFY( p.filename() == "foobar" ); + p += '/'; + VERIFY( p.parent_path() == "/foobar" && p.filename() == "." ); +#if _GLIBCXX_USE_WCHAR_T + p += L"baz.txt"; +#else + p += "baz.txt"; +#endif + VERIFY( p.filename() == "baz.txt" ); + p.concat("/dir/"); + VERIFY( p.parent_path() == "/foobar/baz.txt/dir" && p.filename() == "." ); + std::string file = "file"; + p.concat(file.begin(), file.end()); + VERIFY( p.filename() == "file" ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/copy.cc new file mode 100644 index 0000000000..d0180b6c0a --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/copy.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.1 path constructors [path.construct] + +#include <experimental/filesystem> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + path copy = p; + __gnu_test::compare_paths(p, copy); + } +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path copy = p; + path move = std::move(copy); + __gnu_test::compare_paths(p, move); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/default.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/default.cc new file mode 100644 index 0000000000..d8952a7372 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/default.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.1 path constructors [path.construct] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p; + VERIFY( p.empty() ); + VERIFY( !p.has_root_path() ); + VERIFY( !p.has_root_name() ); + VERIFY( !p.has_root_directory() ); + VERIFY( !p.has_relative_path() ); + VERIFY( !p.has_parent_path() ); + VERIFY( !p.has_filename() ); + VERIFY( !p.has_stem() ); + VERIFY( !p.has_extension() ); + VERIFY( !p.is_absolute() ); + VERIFY( p.is_relative() ); + VERIFY( std::distance(p.begin(), p.end()) == 0 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/locale.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/locale.cc new file mode 100644 index 0000000000..4c8c184159 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/locale.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.1 path constructors [path.construct] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p("/foo/bar", std::locale::classic()); + VERIFY( p.string() == "/foo/bar" ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc new file mode 100644 index 0000000000..2e8922913c --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.1 path constructors [path.construct] + +#include <experimental/filesystem> +#include <string> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; +using __gnu_test::compare_paths; + +void +test01() +{ + for (std::string s : __gnu_test::test_paths) + { + path p1 = s; + path p2( s.begin(), s.end() ); + path p3( s.c_str() ); + path p4( s.c_str(), s.c_str() + s.size() ); + + compare_paths(p1, p2); + compare_paths(p1, p3); + compare_paths(p1, p4); + +#if _GLIBCXX_USE_WCHAR_T + std::wstring ws(s.begin(), s.end()); + path p5 = ws; + path p6( ws.begin(), ws.end() ); + path p7( ws.c_str() ); + path p8( ws.c_str(), ws.c_str() + ws.size() ); + + compare_paths(p1, p5); + compare_paths(p1, p6); + compare_paths(p1, p7); + compare_paths(p1, p8); +#endif + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/extension.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/extension.cc new file mode 100644 index 0000000000..96f5bf5344 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/extension.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo/bar.txt").extension() == path(".txt") ); + VERIFY( path("/foo/bar.baz.txt").extension() == path(".txt") ); + VERIFY( path(".bar.baz.txt").extension() == path(".txt") ); + + VERIFY( path(".hidden").extension() == path(".hidden") ); + + VERIFY( path().extension() == path() ); + VERIFY( path(".").extension() == path() ); + VERIFY( path("..").extension() == path() ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + auto stem = p.stem(); + auto ext = p.extension(); + auto file = p.filename(); + VERIFY( stem.native() + ext.native() == file.native() ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/filename.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/filename.cc new file mode 100644 index 0000000000..dc3f07ff69 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/filename.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo/bar.txt").filename() == "bar.txt" ); + VERIFY( path("/").filename() == "/" ); + VERIFY( path(".").filename() == "." ); + VERIFY( path("..").filename() == ".." ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path f = p.filename(); + if (p.empty()) + VERIFY( f.empty() ); + else + VERIFY( f == *--p.end() ); + if (p != p.root_path()) + VERIFY( !f.has_root_path() ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/parent_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/parent_path.cc new file mode 100644 index 0000000000..41df1bfb59 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/parent_path.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p0; + VERIFY( p0.parent_path() == p0 ); + path p1 = "foo"; + VERIFY( p1.parent_path() == p0 ); + path p2 = "foo/bar"; + VERIFY( p2.parent_path() == p1 ); + path p3 = "/foo/bar"; + VERIFY( p3.parent_path() == path("/foo") ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + if (p.begin() == p.end()) + continue; + path pp; + for (auto i = p.begin(), end = --p.end(); i != end; ++i) + { + pp /= *i; + } + VERIFY( p.parent_path() == pp ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/relative_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/relative_path.cc new file mode 100644 index 0000000000..16e8f864ad --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/relative_path.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p1 = "foo"; + VERIFY( p1.relative_path() == p1 ); + path p2 = "foo/bar"; + VERIFY( p2.relative_path() == p2 ); + path p3 = "/foo/bar"; + VERIFY( p3.relative_path() == p2 ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + bool after_root = false; + const path prel = p.relative_path(); + VERIFY( !prel.has_root_name() ); + path rel; + for (const auto& cmpt : p) + { + if (!cmpt.has_root_path()) + after_root = true; + if (after_root) + rel /= cmpt; + } + VERIFY( prel == rel ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_directory.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_directory.cc new file mode 100644 index 0000000000..4f372d6ddb --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_directory.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p1 = "foo/bar"; + VERIFY( p1.root_directory() == path() ); + path p2 = "/foo/bar"; + VERIFY( p2.root_directory() == path("/") ); + path p3 = "//foo"; + VERIFY( p3.root_directory() == path() ); + path p4 = "///foo"; + VERIFY( p4.root_directory() == path("/") ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path rootdir = p.root_directory(); + // If root-directory is composed of 'slash name', + // 'slash' is excluded from the returned string. + if (!rootdir.empty() && rootdir.native() != "/") + VERIFY( rootdir.native()[0] != '/' ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_name.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_name.cc new file mode 100644 index 0000000000..01886738be --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_name.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo/bar.txt").extension() == ".txt" ); + VERIFY( path("/foo/bar.baz.txt").extension() == ".txt" ); + VERIFY( path(".").extension().empty() ); + VERIFY( path("..").extension().empty() ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_path.cc new file mode 100644 index 0000000000..feb4e7995d --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_path.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p1 = "foo/bar"; + VERIFY( p1.root_path() == path() ); + path p2 = "/foo/bar"; + VERIFY( p2.root_path() == path("/") ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path rootp = p.root_path(); + path rootn = p.root_name(); + path rootd = p.root_directory(); + VERIFY( rootp == (rootn / rootd) ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/stem.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/stem.cc new file mode 100644 index 0000000000..d3611b8877 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/stem.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo/bar.txt").stem() == path("bar") ); + path p = "foo.bar.baz.tar"; + std::vector<std::string> v; + for (; !p.extension().empty(); p = p.stem()) + v.push_back(p.extension().native()); + VERIFY( v.at(0) == ".tar" ); + VERIFY( v.at(1) == ".baz" ); + VERIFY( v.at(2) == ".bar" ); + + VERIFY( path(".hidden").stem() == path() ); + + VERIFY( path().stem() == path() ); + VERIFY( path(".").stem() == path(".") ); + VERIFY( path("..").stem() == path("..") ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc new file mode 100644 index 0000000000..1e302f2bf7 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/generic/generic_string.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.7 path generic format observers [path.generic.obs] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + path p2(p), p3; + p2.swap(p3); + VERIFY( p2 == path() ); + VERIFY( p3 == p ); + p2.swap(p3); + VERIFY( p2 == p ); + VERIFY( p3 == path() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc new file mode 100644 index 0000000000..0e543349d9 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/itr/traversal.cc @@ -0,0 +1,86 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.5 path iterators [path.itr] + +#include <experimental/filesystem> +#include <vector> +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + path p; + VERIFY( p.begin() == p.end() ); + + std::vector<path> v, v2; + + p = "/"; + v.assign(p.begin(), p.end()); + v2 = { "/" }; + VERIFY( v == v2 ); + + p = "filename"; + v.assign(p.begin(), p.end()); + v2 = { "filename" }; + VERIFY( v == v2 ); + + p = "dir/"; + v.assign(p.begin(), p.end()); + v2 = { "dir", "." }; + VERIFY( v == v2 ); + + p = "//rootname/dir/"; + v.assign(p.begin(), p.end()); + v2 = { "//rootname", "/", "dir", "." }; + VERIFY( v == v2 ); + + p = "//rootname/dir/filename"; + v.assign(p.begin(), p.end()); + v2 = { "//rootname", "/", "dir", "filename" }; + VERIFY( v == v2 ); +} + +void +test02() +{ + using reverse_iterator = std::reverse_iterator<path::iterator>; + std::vector<path> fwd, rev; + + for (const path& p : __gnu_test::test_paths) + { + const auto begin = p.begin(), end = p.end(); + fwd.assign(begin, end); + rev.assign(reverse_iterator(end), reverse_iterator(begin)); + VERIFY( fwd.size() == rev.size() ); + VERIFY( std::equal(fwd.begin(), fwd.end(), rev.rbegin()) ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/clear.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/clear.cc new file mode 100644 index 0000000000..e28f900315 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/clear.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (path p : __gnu_test::test_paths) + { + path empty; + p.clear(); + VERIFY( p.empty() ); + __gnu_test::compare_paths(p, empty); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/make_preferred.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/make_preferred.cc new file mode 100644 index 0000000000..f38ecf6fc0 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/make_preferred.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +template<typename T, T sep> +struct checker +{ + static void check(const char* s) { } +}; + +template<> +struct checker<char, '/'> +{ + static void check() + { + VERIFY( path("foo/bar").make_preferred() == "foo/bar" ); + } +}; + +template<> +struct checker<wchar_t, L'\\'> +{ + static void check() + { + VERIFY( path("foo/bar").make_preferred() == L"foo\\bar" ); + } +}; + +void +test01() +{ + checker<path::value_type, path::preferred_separator>::check(); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/remove_filename.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/remove_filename.cc new file mode 100644 index 0000000000..4612e4490d --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/remove_filename.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo").remove_filename() == "/" ); + VERIFY( path("/").remove_filename() == "" ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path p2(p); + p2.remove_filename(); + p2 /= p.filename(); + VERIFY( p2 == p ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_extension.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_extension.cc new file mode 100644 index 0000000000..163016b09a --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_extension.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo.txt").replace_extension("cpp") == "/foo.cpp" ); + VERIFY( path("/foo.txt").replace_extension(".cpp") == "/foo.cpp" ); + VERIFY( path("/").replace_extension("bar") == "/.bar" ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path p2 = p; + VERIFY(p2.replace_extension(p2.extension()) == p); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_filename.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_filename.cc new file mode 100644 index 0000000000..c9706008a0 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/replace_filename.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( path("/foo").replace_filename("bar") == "/bar" ); + VERIFY( path("/").replace_filename("bar") == "bar" ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path p2(p); + p2.replace_filename(p.filename()); + VERIFY( p2 == p ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/swap.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/swap.cc new file mode 100644 index 0000000000..df990e05f4 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/modifiers/swap.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.5 path modifiers [path.modifiers] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + const path p("/foo/bar"); + path p1; + path p2 = p; + p1.swap(p2); + VERIFY( p2.empty() ); + __gnu_test::compare_paths(p1, p); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/nonmember/hash_value.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/nonmember/hash_value.cc new file mode 100644 index 0000000000..3971237a65 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/nonmember/hash_value.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.6 path non-member functions [path.non-member] + +#include <experimental/filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + VERIFY( hash_value(path("a//b")) == hash_value(path("a/b")) ); + VERIFY( hash_value(path("a/")) == hash_value(path("a/.")) ); +} + +void +test02() +{ + for (const path& p : __gnu_test::test_paths) + { + path pp = p.native(); + VERIFY( hash_value(p) == hash_value(pp) ); + } +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/empty.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/empty.cc new file mode 100644 index 0000000000..b636f07261 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/empty.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const std::string& s : __gnu_test::test_paths) + { + VERIFY( s.empty() == path(s).empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_extension.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_extension.cc new file mode 100644 index 0000000000..1edee38112 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_extension.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_extension() == !p.extension().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_filename.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_filename.cc new file mode 100644 index 0000000000..308f78762a --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_filename.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_filename() == !p.filename().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_parent_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_parent_path.cc new file mode 100644 index 0000000000..5068ebb04b --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_parent_path.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_parent_path() == !p.parent_path().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_relative_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_relative_path.cc new file mode 100644 index 0000000000..13ab666ae4 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_relative_path.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_relative_path() == !p.relative_path().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_directory.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_directory.cc new file mode 100644 index 0000000000..16df83c0ab --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_directory.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_root_directory() == !p.root_directory().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_name.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_name.cc new file mode 100644 index 0000000000..e8f2de7069 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_name.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_root_name() == !p.root_name().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_path.cc new file mode 100644 index 0000000000..fed615fb57 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_root_path.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_root_path() == !p.root_path().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_stem.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_stem.cc new file mode 100644 index 0000000000..eab381a227 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/has_stem.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.has_stem() == !p.stem().empty() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/query/is_relative.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/query/is_relative.cc new file mode 100644 index 0000000000..4512f6e747 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/query/is_relative.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.4.9 path decomposition [path.decompose] + +#include <experimental/filesystem> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +using std::experimental::filesystem::path; + +void +test01() +{ + for (const path& p : __gnu_test::test_paths) + { + VERIFY( p.is_relative() == !p.is_absolute() ); + } +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/functional/not_fn.cc b/libstdc++-v3/testsuite/experimental/functional/not_fn.cc index 8285ec4fbf..4c137e85be 100644 --- a/libstdc++-v3/testsuite/experimental/functional/not_fn.cc +++ b/libstdc++-v3/testsuite/experimental/functional/not_fn.cc @@ -20,6 +20,8 @@ #include <experimental/functional> #include <testsuite_hooks.h> +using std::experimental::not_fn; + int func(int, char) { return 0; } struct F @@ -33,8 +35,6 @@ struct F void test01() { - using std::experimental::not_fn; - auto f1 = not_fn(func); VERIFY( f1(1, '2') == true ); @@ -50,8 +50,36 @@ test01() VERIFY( f5(1) == false ); } +template<typename F, typename Arg> +auto foo(F f, Arg arg) -> decltype(not_fn(f)(arg)) { return not_fn(f)(arg); } + +template<typename F, typename Arg> +auto foo(F f, Arg arg) -> decltype(not_fn(f)()) { return not_fn(f)(); } + +struct negator +{ + bool operator()(int) const { return false; } + void operator()() const {} +}; + +void +test02() +{ + foo(negator{}, 1); // PR libstdc++/66998 +} + +void +test03() +{ + struct X { bool b; }; + X x{ false }; + VERIFY( not_fn(&X::b)(x) ); +} + int main() { test01(); + test02(); + test03(); } diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 56ca89617a..b5fb3e3877 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -223,6 +223,15 @@ proc dg-require-little-endian { args } { return } +proc dg-require-filesystem-ts { args } { + if { ![ check_v3_target_filesystem_ts ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} + proc add_options_for_no_pch { flags } { # This forces any generated and possibly included PCH to be invalid. return "-D__GLIBCXX__=99999999" diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index cca70780ef..8322fac04f 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1894,6 +1894,59 @@ proc check_v3_target_little_endian { } { return $et_little_endian } +proc check_v3_target_filesystem_ts { } { + global cxxflags + global DEFAULT_CXXFLAGS + global et_filesystem_ts + global tool + + if { ![info exists et_filesystem_ts_target_name] } { + set et_filesystem_ts_target_name "" + } + + # If the target has changed since we set the cached value, clear it. + set current_target [current_target_name] + if { $current_target != $et_filesystem_ts_target_name } { + verbose "check_v3_target_filesystem_ts: `$et_filesystem_ts_target_name'" 2 + set et_filesystem_ts_target_name $current_target + if [info exists et_filesystem_ts] { + verbose "check_v3_target_filesystem_ts: removing cached result" 2 + unset et_filesystem_ts + } + } + + if [info exists et_filesystem_ts] { + verbose "check_v3_target_filesystem_ts: using cached result" 2 + } else { + set et_filesystem_ts 0 + + # Set up and preprocess a C++ test program that depends + # on debug mode activated. + set src filesystem_ts[pid].cc + + set f [open $src "w"] + puts $f "#include <experimental/filesystem>" + puts $f "#if ! __cpp_lib_experimental_filesystem" + puts $f "# error No Filesystem TS support" + puts $f "#endif" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11" + + set lines [v3_target_compile $src /dev/null preprocess ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + # No error message, preprocessing succeeded. + set et_filesystem_ts 1 + } + } + verbose "check_v3_target_filesystem_ts: $et_filesystem_ts" 2 + return $et_filesystem_ts +} + set additional_prunes "" if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \ diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc index c62ef61ebf..046888f77c 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc @@ -1,5 +1,5 @@ // { dg-do run } -// { dg-options "-g -O0" } +// { dg-options "-g -O0 -std=gnu++98" } // Copyright (C) 2011-2015 Free Software Foundation, Inc. // @@ -70,6 +70,13 @@ main() std::map<std::string, int>::iterator mpiter = mp.begin(); // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } } + // PR 67440 + std::set<int> intset; + intset.insert(2); + intset.insert(3); + const std::set<int> const_intset = intset; +// { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } } + std::set<std::string> sp; sp.insert("clownfish"); sp.insert("barrel"); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index ad3c256129..e1956bfa52 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -1,7 +1,7 @@ // If you modify this, please update simple11.cc and debug.cc as well. // { dg-do run } -// { dg-options "-g -O0" } +// { dg-options "-g -O0 -std=gnu++98" } // Copyright (C) 2011-2015 Free Software Foundation, Inc. // @@ -73,6 +73,13 @@ main() std::map<std::string, int>::iterator mpiter = mp.begin(); // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } } + // PR 67440 + std::set<int> intset; + intset.insert(2); + intset.insert(3); + const std::set<int> const_intset = intset; +// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } } + std::set<std::string> sp; sp.insert("clownfish"); sp.insert("barrel"); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc index ba36a6abef..5f7e9a6a7a 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc @@ -73,6 +73,10 @@ main() std::map<std::string, int>::iterator mpiter = mp.begin(); // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } } + // PR 67440 + const std::set<int> const_intset = {2, 3}; +// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } } + std::set<std::string> sp; sp.insert("clownfish"); sp.insert("barrel"); diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h new file mode 100644 index 0000000000..524972ece9 --- /dev/null +++ b/libstdc++-v3/testsuite/util/testsuite_fs.h @@ -0,0 +1,93 @@ +// -*- C++ -*- +// Filesystem utils for the C++ library testsuite. +// +// Copyright (C) 2014-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// + +#ifndef _TESTSUITE_FS_H +#define _TESTSUITE_FS_H 1 + +#include <experimental/filesystem> +#include <iostream> +#include <string> +#include <cstdio> +#include <stdlib.h> +#include <unistd.h> + +namespace __gnu_test +{ +#define PATH_CHK(p1, p2, fn) \ + if ( p1.fn() != p2.fn() ) \ + throw std::experimental::filesystem::filesystem_error( #fn, p1, p2, \ + std::make_error_code(std::errc::invalid_argument) ) + + void + compare_paths(const std::experimental::filesystem::path& p1, + const std::experimental::filesystem::path& p2) + { + // std::cout << "Comparing " << p1 << " and " << p2 << std::endl; + PATH_CHK( p1, p2, string ); + PATH_CHK( p1, p2, empty ); + PATH_CHK( p1, p2, has_root_path ); + PATH_CHK( p1, p2, has_root_name ); + PATH_CHK( p1, p2, has_root_directory ); + PATH_CHK( p1, p2, has_relative_path ); + PATH_CHK( p1, p2, has_parent_path ); + PATH_CHK( p1, p2, has_filename ); + PATH_CHK( p1, p2, has_stem ); + PATH_CHK( p1, p2, has_extension ); + PATH_CHK( p1, p2, is_absolute ); + PATH_CHK( p1, p2, is_relative ); + auto d1 = std::distance(p1.begin(), p1.end()); + auto d2 = std::distance(p2.begin(), p2.end()); + if( d1 != d2 ) + throw std::experimental::filesystem::filesystem_error( + "distance(begin, end)", p1, p2, + std::make_error_code(std::errc::invalid_argument) ); + } + + const std::string test_paths[] = { + "", "/", "//", "/.", "/./", "/a", "/a/", "/a//", "/a/b/c/d", "/a//b", + "a", "a/b", "a/b/", "a/b/c", "a/b/c.d", "a/b/..", "a/b/c.", "a/b/.c" + }; + + // This is NOT supposed to be a secure way to get a unique name! + // We just need a path that doesn't exist for testing purposes. + std::experimental::filesystem::path + nonexistent_path() + { + std::experimental::filesystem::path p; +#if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L + char tmp[] = "test.XXXXXX"; + int fd = ::mkstemp(tmp); + if (fd == -1) + throw std::experimental::filesystem::filesystem_error("mkstemp failed", + std::error_code(errno, std::generic_category())); + ::unlink(tmp); + ::close(fd); + p = tmp; +#else + char buf[64]; + std::sprintf(buf, "test.%lu", (unsigned long)::getpid()); + p = buf; +#endif + return p; + } + +} // namespace __gnu_test +#endif |