/* Self tests for filesystem path handling for GDB. Copyright (C) 2017 Free Software Foundation, Inc. This file is part of GDB. This program 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 of the License, or (at your option) any later version. This program 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 program. If not, see . */ #include #include "gdb_path.h" //namespace selftest { namespace fs = gdb::filesystem; static int i = 0; template void print_path (T &p) { std::cout << i++ << ":\n"; std::cout << "string = " << p.string () << "\n"; std::cout << "c_str = " << p.c_str () << "\n"; std::cout << "root_name = " << p.root_name () << "\n"; std::cout << "root_dir = " << p.root_directory () << "\n"; std::cout << "root_path = " << p.root_path () << "\n"; std::cout << "relative_path = " << p.relative_path () << "\n"; std::cout << "parent_path = " << p.parent_path () << "\n"; std::cout << "filename = " << p.filename () << "\n"; std::cout << "stem = " << p.stem () << "\n"; std::cout << "extension = " << p.extension () << "\n"; std::cout << "\n"; } int main () { fs::path p ("/"); print_path (p); p.clear (); p = "C:1/2///"; print_path (p); p.clear (); p = "C:/1/2///"; print_path (p); p.clear (); p = fs::path ("/1/x/y/z/../../..///2/."); fs::path q = "3"; fs::path r = "4"; fs::path s; s = q / r; p /= s; p /= std::string ("5"); p /= "6"; p.append (".7"); p /= "."; p /= "x"; p /= ".."; print_path (p); p += fs::path (".foo"); print_path (p); p += ".bar"; print_path (p); fs::path t; print_path (t); gdb::path gp ("/a/b/c/$x/$y/e/f"); print_path (gp); gp.type = gdb::TARGET_PATH; gp.substitute ("$x", "d"); gp.substitute ("$y", ""); print_path (gp); gp.clear (); gp /= "../foo"; print_path (gp); } //} /* namespace selftest */