libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

c_str.pass.cpp (981B)


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