brintos

brintos / llvm-project-archived public Read only

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