Mercurial > malikania
changeset 162:b65a86a84fcb
Common: remove weak_array, closes #772 @5m
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 17 Mar 2018 14:16:29 +0100 |
parents | be0d90706ded |
children | a99a7db489bd |
files | libcommon/CMakeLists.txt tests/libcommon/CMakeLists.txt tests/libcommon/weak_array/CMakeLists.txt tests/libcommon/weak_array/main.cpp |
diffstat | 4 files changed, 0 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/libcommon/CMakeLists.txt Sat Mar 17 14:13:19 2018 +0100 +++ b/libcommon/CMakeLists.txt Sat Mar 17 14:16:29 2018 +0100 @@ -32,7 +32,6 @@ ${libmlk-common_SOURCE_DIR}/malikania/tileset.hpp ${libmlk-common_SOURCE_DIR}/malikania/unicode.hpp ${libmlk-common_SOURCE_DIR}/malikania/util.hpp - ${libmlk-common_SOURCE_DIR}/malikania/weak_array.hpp ) set(
--- a/tests/libcommon/CMakeLists.txt Sat Mar 17 14:13:19 2018 +0100 +++ b/tests/libcommon/CMakeLists.txt Sat Mar 17 14:16:29 2018 +0100 @@ -19,7 +19,6 @@ add_subdirectory(network-stream) add_subdirectory(util) add_subdirectory(size) -add_subdirectory(weak_array) # JavaScript bindings add_subdirectory(js-elapsed-timer)
--- a/tests/libcommon/weak_array/CMakeLists.txt Sat Mar 17 14:13:19 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -# -# CMakeLists.txt -- CMake build system for malikania -# -# Copyright (c) 2013-2018 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. -# - -malikania_create_test( - NAME weak_array - LIBRARIES libmlk-common - SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp -)
--- a/tests/libcommon/weak_array/main.cpp Sat Mar 17 14:13:19 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * main.cpp -- test weak_array - * - * Copyright (c) 2013-2018 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. - */ - -#define BOOST_TEST_MODULE "weak_array" -#include <boost/test/unit_test.hpp> - -#include <malikania/weak_array.hpp> - -namespace mlk { - -class weak_array_fixture { -protected: - weak_array<int> array_; -}; - -BOOST_FIXTURE_TEST_SUITE(weak_array_suite, weak_array_fixture) - -BOOST_AUTO_TEST_CASE(reuse) -{ - auto value = std::make_shared<int>(123); - - array_.push_back(value); - array_.push_back(std::make_shared<int>(256)); - - auto it1 = array_.find_if([] (auto ptr) { - return *ptr = 123; - }); - auto it2 = array_.find_if([] (auto ptr) { - return *ptr = 123; - }); - - BOOST_TEST(it1 == value); - BOOST_TEST(it2 == value); - BOOST_TEST(it1 == it2); - BOOST_TEST(*it1 == 123); - BOOST_TEST(*it2 == 123); -} - -BOOST_AUTO_TEST_CASE(not_found) -{ - array_.push_back(std::make_shared<int>(123)); - - auto v = array_.find_if([] (auto ptr) { - return *ptr = 123; - }); - - BOOST_TEST(!v); -} - -BOOST_AUTO_TEST_SUITE_END() - -} // !mlk