From 308d78e6947cc99d2c3502dafc75ee23e80a7dd4 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Thu, 5 Aug 2021 08:42:07 +0200 Subject: [PATCH] Update test --- .../libraries/armem/test/ArMemQueryTest.cpp | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp index a674ef503..32795093a 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp @@ -20,23 +20,21 @@ * GNU General Public License */ -#include "ArmarXCore/core/exceptions/LocalException.h" -#include <RobotAPI/interface/armem/query.h> -#include <boost/test/tools/old/interface.hpp> #define BOOST_TEST_MODULE RobotAPI::ArmarXLibraries::armem #define ARMARX_BOOST_TEST #include <RobotAPI/Test.h> -#include "../server/query_proc/workingmemory/EntityQueryProcessor.h" -#include "../error.h" - - -#include <iostream> +#include <RobotAPI/interface/armem/query.h> +#include <RobotAPI/libraries/armem/server/query_proc/workingmemory/EntityQueryProcessor.h> +#include <RobotAPI/libraries/armem/core/error.h> +#include <RobotAPI/libraries/armem/core/base/detail/negative_index_semantics.h> #include <SimoxUtility/algorithm/get_map_keys_values.h> #include <SimoxUtility/algorithm/string.h> +#include <iostream> + namespace armem = armarx::armem; namespace aron = armarx::aron; @@ -139,8 +137,8 @@ BOOST_AUTO_TEST_CASE(test_entity_Single_existing) for (const armem::wm::Entity& result : results) { BOOST_CHECK_EQUAL(result.name(), entity.name()); - BOOST_CHECK_EQUAL(result.size(), 1); - BOOST_CHECK_EQUAL(result.history().begin()->second.time(), armem::Time::microSeconds(3000)); + BOOST_REQUIRE_EQUAL(result.size(), 1); + BOOST_CHECK_EQUAL(result.getFirstSnapshot().time(), armem::Time::microSeconds(3000)); } } @@ -167,12 +165,13 @@ BOOST_AUTO_TEST_CASE(test_entity_All) { BOOST_CHECK_EQUAL(result.name(), entity.name()); BOOST_CHECK_EQUAL(result.size(), entity.size()); - auto jt = entity.history().begin(); - for (auto it = result.history().begin(); it != result.history().end(); ++it, ++jt) + for (armem::Time time : entity.getTimestamps()) { - BOOST_CHECK_EQUAL(it->first, jt->first); - BOOST_CHECK_EQUAL(it->second.time(), jt->second.time()); - BOOST_CHECK_NE(&it->second, &jt->second); + BOOST_REQUIRE(result.hasSnapshot(time)); + const armem::wm::EntitySnapshot& rs = result.getSnapshot(time); + const armem::wm::EntitySnapshot& es = entity.getSnapshot(time); + BOOST_CHECK_EQUAL(rs.time(), es.time()); + BOOST_CHECK_NE(&rs, &es); } } } @@ -598,33 +597,33 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeApprox_lookup_invalid_timestamp) BOOST_AUTO_TEST_CASE(test_negative_index_semantics) { - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(0, 0), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(0, 1), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(0, 10), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(0, 0), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(0, 1), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(0, 10), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(1, 1), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(5, 1), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(1, 1), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(5, 1), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(1, 5), 1); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(5, 5), 4); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(5, 6), 5); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(5, 10), 5); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(1, 5), 1); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(5, 5), 4); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(5, 6), 5); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(5, 10), 5); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-1, 0), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 0), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-1, 0), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 0), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-1, 1), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 1), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-1, 1), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 1), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-1, 2), 1); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 2), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-1, 2), 1); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 2), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-1, 5), 4); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 5), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 6), 1); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-5, 10), 5); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-10, 10), 0); - BOOST_CHECK_EQUAL(EntityQueryProcessor::negativeIndexSemantics(-20, 10), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-1, 5), 4); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 5), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 6), 1); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-5, 10), 5); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-10, 10), 0); + BOOST_CHECK_EQUAL(armem::base::detail::negativeIndexSemantics(-20, 10), 0); } @@ -640,8 +639,8 @@ BOOST_AUTO_TEST_CASE(test_entity_IndexRange_all_default) BOOST_CHECK_EQUAL(result.size(), entity.size()); - std::vector<armem::Time> times = result.getTimestamps(); - std::vector<armem::Time> expected = simox::alg::get_keys(entity.history()); + const std::vector<armem::Time> times = result.getTimestamps(); + const std::vector<armem::Time> expected = entity.getTimestamps(); BOOST_CHECK_EQUAL_COLLECTIONS(times.begin(), times.end(), expected.begin(), expected.end()); } -- GitLab