Skip to content
Snippets Groups Projects
Commit 3f7fe3bd authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add tests

parent 76faeb33
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ ENDMACRO()
ADD_SUBDIRECTORY(algorithm)
ADD_SUBDIRECTORY(caching)
ADD_SUBDIRECTORY(color)
ADD_SUBDIRECTORY(filesystem)
ADD_SUBDIRECTORY(json)
......
ADD_SU_TEST( CacheMap )
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::FrameTracking
* @author Adrian Knobloch ( adrian dot knobloch at student dot kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#define BOOST_TEST_MODULE SimoxUtility/color/ColorMap
#include <unordered_map>
#include <boost/test/included/unit_test.hpp>
#include <SimoxUtility/caching/CacheMap.h>
#include <iostream>
namespace CacheMapTest
{
}
BOOST_AUTO_TEST_SUITE(CacheMapTest)
BOOST_AUTO_TEST_CASE(test_at_empty)
{
auto fetchFn = [](int i)
{
return std::to_string(i);
};
simox::caching::CacheMap<int, std::string> cache(fetchFn);
BOOST_CHECK(cache.empty());
BOOST_CHECK_EQUAL(cache.size(), 0);
BOOST_CHECK_EQUAL(cache.get(1), "1");
BOOST_CHECK_EQUAL(cache.size(), 1);
BOOST_CHECK_EQUAL(cache.get(1), "1");
BOOST_CHECK_EQUAL(cache.size(), 1);
BOOST_CHECK_EQUAL(cache.get(2), "2");
BOOST_CHECK_EQUAL(cache.size(), 2);
BOOST_CHECK_EQUAL(cache.get(2), "2");
BOOST_CHECK_EQUAL(cache.size(), 2);
const bool clear = true;
cache.setFetchFn([](int i)
{
return std::to_string(-i);
}, clear);
BOOST_CHECK_EQUAL(cache.size(), 0);
BOOST_CHECK(cache.empty());
}
BOOST_AUTO_TEST_SUITE_END()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment