file_status.cons.pass.cpp 1.9 KB

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