file_status.cons.pass.cpp 1.9 KB

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