11590Srgrimes// { dg-options "-std=gnu++11 -lstdc++fs" }
21590Srgrimes// { dg-require-filesystem-ts "" }
31590Srgrimes
41590Srgrimes// Copyright (C) 2014-2015 Free Software Foundation, Inc.
51590Srgrimes//
61590Srgrimes// This file is part of the GNU ISO C++ Library.  This library is free
71590Srgrimes// software; you can redistribute it and/or modify it under the
81590Srgrimes// terms of the GNU General Public License as published by the
91590Srgrimes// Free Software Foundation; either version 3, or (at your option)
101590Srgrimes// any later version.
111590Srgrimes
121590Srgrimes// This library is distributed in the hope that it will be useful,
131590Srgrimes// but WITHOUT ANY WARRANTY; without even the implied warranty of
141590Srgrimes// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151590Srgrimes// GNU General Public License for more details.
161590Srgrimes
171590Srgrimes// You should have received a copy of the GNU General Public License along
181590Srgrimes// with this library; see the file COPYING3.  If not see
191590Srgrimes// <http://www.gnu.org/licenses/>.
201590Srgrimes
211590Srgrimes// 8.4.9 path decomposition [path.decompose]
221590Srgrimes
231590Srgrimes#include <experimental/filesystem>
241590Srgrimes#include <vector>
251590Srgrimes#include <testsuite_hooks.h>
261590Srgrimes#include <testsuite_fs.h>
271590Srgrimes
281590Srgrimesusing std::experimental::filesystem::path;
291590Srgrimes
301590Srgrimesvoid
311590Srgrimestest01()
321590Srgrimes{
33207705Sdelphij  VERIFY( path("/foo/bar.txt").extension() == path(".txt") );
34207705Sdelphij  VERIFY( path("/foo/bar.baz.txt").extension() == path(".txt") );
35207705Sdelphij  VERIFY( path(".bar.baz.txt").extension() == path(".txt") );
36207705Sdelphij
37207705Sdelphij  VERIFY( path(".hidden").extension() == path(".hidden") );
38207705Sdelphij
3993604Sobrien  VERIFY( path().extension() == path() );
4093604Sobrien  VERIFY( path(".").extension() == path() );
411590Srgrimes  VERIFY( path("..").extension() == path() );
421590Srgrimes}
431590Srgrimes
441590Srgrimesvoid
451590Srgrimestest02()
461590Srgrimes{
4772945Sknu  for (const path& p : __gnu_test::test_paths)
48200462Sdelphij  {
491590Srgrimes    auto stem = p.stem();
501590Srgrimes    auto ext = p.extension();
511590Srgrimes    auto file = p.filename();
521590Srgrimes    VERIFY( stem.native() + ext.native() == file.native() );
531590Srgrimes  }
54207705Sdelphij}
5591400Sdwmalone
561590Srgrimesint
57176478Simpmain()
581590Srgrimes{
5976250Sphk  test01();
6076250Sphk  test02();
6176250Sphk}
62157555Sceri