libcxx

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

operator_string.pass.cpp (1158B)


      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 // operator string_type() const;
     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   using string_type = path::string_type;
     31   const char* const value = "hello world";
     32   { // Check signature
     33     path p(value);
     34     static_assert(std::is_convertible<path, string_type>::value, "");
     35     static_assert(std::is_constructible<string_type, path>::value, "");
     36     ASSERT_SAME_TYPE(string_type, decltype(p.operator string_type()));
     37     ASSERT_NOT_NOEXCEPT(p.operator string_type());
     38   }
     39   {
     40     path p(value);
     41     assert(p.native() == value);
     42     string_type s = p;
     43     assert(s == value);
     44     assert(p == value);
     45   }
     46 }