c_str.pass.cpp 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // <filesystem>
  10. // class path
  11. // const value_type* c_str() const noexcept;
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "filesystem_test_helper.hpp"
  17. int main(int, char**)
  18. {
  19. using namespace fs;
  20. const char* const value = "hello world";
  21. const std::string str_value = value;
  22. { // Check signature
  23. path p(value);
  24. ASSERT_SAME_TYPE(path::value_type const*, decltype(p.c_str()));
  25. ASSERT_NOEXCEPT(p.c_str());
  26. }
  27. {
  28. path p(value);
  29. assert(p.c_str() == str_value);
  30. assert(p.native().c_str() == p.c_str());
  31. }
  32. return 0;
  33. }