Mercurial > code
view C++/Tests/Directory/main.cpp @ 249:3b4ae8feca1c
Switch to GoogleTest finished #285
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 01 Oct 2014 14:38:25 +0200 |
parents | C++/Tests/Directory/TestDirectory.cpp@5a99711d52f9 |
children | b686a09fb9c6 |
line wrap: on
line source
/* * main.cpp -- test directory * * Copyright (c) 2013, 2014 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 { auto flags = Directory::NotDotDot; 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 { auto flags = Directory::NotDot; 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 { Directory directory("."); 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 { auto flags = Directory::NotDot | Directory::NotDotDot; 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_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(); }