Mercurial > code
view C++/Tests/Directory/main.cpp @ 307:e2a8cbf2dd79
Utf8:
* Add unit tests
* Rename toucs -> toutf32
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Dec 2014 10:39:38 +0100 |
parents | b686a09fb9c6 |
children |
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(); }