Mercurial > code
view C++/tests/Directory/main.cpp @ 468:becd06089e8f
Get rid of Flags, update README
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 04 Nov 2015 21:21:30 +0100 |
parents | d5ec1174b707 |
children | 898d8b29a4f1 |
line wrap: on
line source
/* * main.cpp -- test directory * * Copyright (c) 2013-2015 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <gtest/gtest.h> #include <Directory.h> TEST(Filter, withDot) { try { int flags = Directory::Dot; Directory directory(".", flags); bool dot(false); bool dotdot(false); for (const auto &entry : directory) { if (entry.name == ".") dot = true; if (entry.name == "..") dotdot = true; } ASSERT_TRUE(dot); ASSERT_FALSE(dotdot); } catch (const std::runtime_error &error) { FAIL() << "skipping test because: " << error.what(); } } TEST(Filter, withDotDot) { try { int flags = Directory::DotDot; Directory directory(".", flags); bool dot(false); bool dotdot(false); for (const auto &entry : directory) { if (entry.name == ".") dot = true; if (entry.name == "..") dotdot = true; } ASSERT_FALSE(dot); ASSERT_TRUE(dotdot); } catch (const std::runtime_error &error) { FAIL() << "skipping test because: " << error.what(); } } TEST(Filter, withBothDots) { try { int flags = Directory::Dot | Directory::DotDot; Directory directory(".", flags); bool dot(false); bool dotdot(false); for (const auto &entry : directory) { if (entry.name == ".") dot = true; if (entry.name == "..") dotdot = true; } ASSERT_TRUE(dot); ASSERT_TRUE(dotdot); } catch (const std::runtime_error &error) { FAIL() << "skipping test because: " << error.what(); } } TEST(Filter, withoutDots) { try { Directory directory("."); bool dot(false); bool dotdot(false); for (const auto &entry : directory) { if (entry.name == ".") dot = true; if (entry.name == "..") dotdot = true; } ASSERT_FALSE(dot); ASSERT_FALSE(dotdot); } catch (const std::runtime_error &error) { FAIL() << "skipping test because: " << error.what(); } } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }