150276Speter// { dg-options "-std=gnu++11 -lstdc++fs" }
2184989Srafan// { dg-require-filesystem-ts "" }
350276Speter
450276Speter// Copyright (C) 2014-2015 Free Software Foundation, Inc.
550276Speter//
650276Speter// This file is part of the GNU ISO C++ Library.  This library is free
750276Speter// software; you can redistribute it and/or modify it under the
850276Speter// terms of the GNU General Public License as published by the
950276Speter// Free Software Foundation; either version 3, or (at your option)
1050276Speter// any later version.
1150276Speter
1250276Speter// This library is distributed in the hope that it will be useful,
1350276Speter// but WITHOUT ANY WARRANTY; without even the implied warranty of
1450276Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1550276Speter// GNU General Public License for more details.
1650276Speter
1750276Speter// You should have received a copy of the GNU General Public License along
1850276Speter// with this library; see the file COPYING3.  If not see
1950276Speter// <http://www.gnu.org/licenses/>.
2050276Speter
2150276Speter// 8.4.9 path decomposition [path.decompose]
2250276Speter
2350276Speter#include <experimental/filesystem>
2450276Speter#include <testsuite_hooks.h>
2550276Speter#include <testsuite_fs.h>
2650276Speter
2750276Speterusing std::experimental::filesystem::path;
2850276Speter
2950276Spetervoid
3050276Spetertest01()
3150276Speter{
32166124Srafan  path p1 = "foo/bar";
3350276Speter  VERIFY( p1.root_directory() == path() );
3450276Speter  path p2 = "/foo/bar";
3550276Speter  VERIFY( p2.root_directory() == path("/") );
3650276Speter  path p3 = "//foo";
3750276Speter  VERIFY( p3.root_directory() == path() );
3850276Speter  path p4 = "///foo";
3950276Speter  VERIFY( p4.root_directory() == path("/") );
4050276Speter}
4150276Speter
4250276Spetervoid
4350276Spetertest02()
4498503Speter{
4550276Speter  for (const path& p : __gnu_test::test_paths)
4650276Speter  {
4750276Speter    path rootdir = p.root_directory();
4850276Speter    // If root-directory is composed of 'slash name',
4950276Speter    // 'slash' is excluded from the returned string.
5050276Speter    if (!rootdir.empty() && rootdir.native() != "/")
51184989Srafan      VERIFY( rootdir.native()[0] != '/' );
5250276Speter  }
5350276Speter}
5462449Speter
5562449Speterint
5650276Spetermain()
5750276Speter{
5850276Speter  test01();
5950276Speter  test02();
6062449Speter}
6162449Speter