file_status.cons.pass.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 file_status
  12. // explicit file_status() noexcept;
  13. // explicit file_status(file_type, perms prms = perms::unknown) noexcept;
  14. #include <experimental/filesystem>
  15. #include <type_traits>
  16. #include <cassert>
  17. #include "test_convertible.hpp"
  18. namespace fs = std::experimental::filesystem;
  19. int main() {
  20. using namespace fs;
  21. // Default ctor
  22. {
  23. static_assert(std::is_nothrow_default_constructible<file_status>::value,
  24. "The default constructor must be noexcept");
  25. static_assert(!test_convertible<file_status>(),
  26. "The default constructor must be explicit");
  27. const file_status f;
  28. assert(f.type() == file_type::none);
  29. assert(f.permissions() == perms::unknown);
  30. }
  31. // Unary ctor
  32. {
  33. static_assert(std::is_nothrow_constructible<file_status, file_type>::value,
  34. "This constructor must be noexcept");
  35. static_assert(!test_convertible<file_status, file_type>(),
  36. "This constructor must be explicit");
  37. const file_status f(file_type::not_found);
  38. assert(f.type() == file_type::not_found);
  39. assert(f.permissions() == perms::unknown);
  40. }
  41. // Binary ctor
  42. {
  43. static_assert(std::is_nothrow_constructible<file_status, file_type, perms>::value,
  44. "This constructor must be noexcept");
  45. static_assert(!test_convertible<file_status, file_type, perms>(),
  46. "This constructor must b explicit");
  47. const file_status f(file_type::regular, perms::owner_read);
  48. assert(f.type() == file_type::regular);
  49. assert(f.permissions() == perms::owner_read);
  50. }
  51. }