c_str.pass.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // class path
  12. // const value_type* c_str() const noexcept;
  13. #include <experimental/filesystem>
  14. #include <type_traits>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "filesystem_test_helper.hpp"
  18. namespace fs = std::experimental::filesystem;
  19. int main()
  20. {
  21. using namespace fs;
  22. const char* const value = "hello world";
  23. const std::string str_value = value;
  24. path p(value);
  25. { // Check signature
  26. ASSERT_SAME_TYPE(path::value_type const*, decltype(p.c_str()));
  27. ASSERT_NOEXCEPT(p.c_str());
  28. }
  29. {
  30. path p(value);
  31. assert(p.c_str() == str_value);
  32. assert(p.native().c_str() == p.c_str());
  33. }
  34. }