file_status.mods.pass.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // void type(file_type) noexcept;
  12. // void permissions(perms) noexcept;
  13. #include "filesystem_include.hpp"
  14. #include <type_traits>
  15. #include <cassert>
  16. int main(int, char**) {
  17. using namespace fs;
  18. file_status st;
  19. // type test
  20. {
  21. static_assert(noexcept(st.type(file_type::regular)),
  22. "operation must be noexcept");
  23. static_assert(std::is_same<decltype(st.type(file_type::regular)), void>::value,
  24. "operation must return void");
  25. assert(st.type() != file_type::regular);
  26. st.type(file_type::regular);
  27. assert(st.type() == file_type::regular);
  28. }
  29. // permissions test
  30. {
  31. static_assert(noexcept(st.permissions(perms::owner_read)),
  32. "operation must be noexcept");
  33. static_assert(std::is_same<decltype(st.permissions(perms::owner_read)), void>::value,
  34. "operation must return void");
  35. assert(st.permissions() != perms::owner_read);
  36. st.permissions(perms::owner_read);
  37. assert(st.permissions() == perms::owner_read);
  38. }
  39. return 0;
  40. }