| 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 |
|
| 9 |
// UNSUPPORTED: c++03, c++11, c++14 |
| 10 |
// UNSUPPORTED: no-filesystem |
| 11 |
// UNSUPPORTED: availability-filesystem-missing |
| 12 |
|
| 13 |
// <filesystem> |
| 14 |
|
| 15 |
// bool status_known(file_status s) noexcept; |
| 16 |
|
| 17 |
#include <filesystem> |
| 18 |
#include <type_traits> |
| 19 |
#include <cassert> |
| 20 |
|
| 21 |
#include "test_macros.h" |
| 22 |
#include "filesystem_test_helper.h" |
| 23 |
namespace fs = std::filesystem; |
| 24 |
using namespace fs; |
| 25 |
|
| 26 |
static void signature_test() |
| 27 |
{ |
| 28 |
file_status s; ((void)s); |
| 29 |
ASSERT_SAME_TYPE(decltype(status_known(s)), bool); |
| 30 |
ASSERT_NOEXCEPT(status_known(s)); |
| 31 |
} |
| 32 |
|
| 33 |
static void status_known_test() |
| 34 |
{ |
| 35 |
struct TestCase { |
| 36 |
file_type type; |
| 37 |
bool expect; |
| 38 |
}; |
| 39 |
const TestCase testCases[] = { |
| 40 |
{file_type::none, false}, |
| 41 |
{file_type::not_found, true}, |
| 42 |
{file_type::regular, true}, |
| 43 |
{file_type::directory, true}, |
| 44 |
{file_type::symlink, true}, |
| 45 |
{file_type::block, true}, |
| 46 |
{file_type::character, true}, |
| 47 |
{file_type::fifo, true}, |
| 48 |
{file_type::socket, true}, |
| 49 |
{file_type::unknown, true} |
| 50 |
}; |
| 51 |
for (auto& TC : testCases) { |
| 52 |
file_status s(TC.type); |
| 53 |
assert(status_known(s) == TC.expect); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
int main(int, char**) { |
| 58 |
signature_test(); |
| 59 |
status_known_test(); |
| 60 |
|
| 61 |
return 0; |
| 62 |
} |