![]() |
Tesseract 0.28.4
|
Unit tests for NameId<Tag>, LinkId, JointId, and LinkIdPair types. More...
#include <tesseract/common/macros.h>#include <gtest/gtest.h>#include <unordered_set>#include <unordered_map>#include <map>#include <cereal/archives/xml.hpp>#include <sstream>#include <boost/container_hash/hash.hpp>#include <tesseract/common/types.h>#include <tesseract/common/types_boost_hash.h>#include <tesseract/common/cereal_serialization.h>#include <tesseract/common/serialization.h>#include <tesseract/common/test_suite/name_id_testing.h>Functions | |
| EXPECT_EQ (a1, a2) | |
| EXPECT_EQ (a1.value(), a2.value()) | |
| EXPECT_NE (a, b) | |
| EXPECT_TRUE (valid.isValid()) | |
| EXPECT_FALSE (invalid.isValid()) | |
| EXPECT_EQ (invalid.value(), 0U) | |
| EXPECT_FALSE (empty_id.isValid()) | |
| EXPECT_EQ (empty_id.value(), 0U) | |
| EXPECT_TRUE (empty_id.name().empty()) | |
| EXPECT_TRUE (zero_valued.isValid()) | |
| EXPECT_EQ (zero_valued.value(), 0U) | |
| EXPECT_NE (zero_valued, LinkId{}) | |
| EXPECT_EQ (id, "test_link") | |
| EXPECT_TRUE (id.name().empty()) | |
| EXPECT_FALSE (id.isValid()) | |
| EXPECT_EQ (link.value(), joint.value()) | |
| EXPECT_EQ (hasher(id), id.value()) | |
| EXPECT_EQ (hash_value(id), id.value()) | |
| ids | insert (LinkId("a")) |
| ids | insert (LinkId("b")) |
| EXPECT_EQ (ids.size(), 2U) | |
| EXPECT_TRUE (ids.count(LinkId("a"))==1) | |
| EXPECT_TRUE (ids.count(LinkId("b"))==1) | |
| EXPECT_TRUE (ids.count(LinkId("c"))==0) | |
| EXPECT_TRUE ((a< b)||(b< a)) | |
| EXPECT_FALSE (a< a) | |
| EXPECT_EQ (map.at(reversed), 42) | |
| EXPECT_EQ (hash_value(pair), pair.hash()) | |
| EXPECT_EQ (pair.first(), pair.second()) | |
| EXPECT_EQ (ab.first(), ba.first()) | |
| EXPECT_LE (ab.first().value(), ab.second().value()) | |
| assigned | assign (a, b) |
| EXPECT_EQ (assigned, constructed) | |
| EXPECT_EQ (assigned.hash(), constructed.hash()) | |
| assigned | assign (b, a) |
| scratch | assign (LinkId("a_rather_long_link_name_beyond_sso"), LinkId("another_rather_long_link_name")) |
| EXPECT_EQ (scratch, LinkIdPair(LinkId("a_rather_long_link_name_beyond_sso"), LinkId("another_rather_long_link_name"))) | |
| scratch | assign (LinkId("x"), LinkId("y")) |
| EXPECT_EQ (scratch, expected) | |
| EXPECT_EQ (scratch.hash(), expected.hash()) | |
| EXPECT_EQ (assigned.first().name(), "link_a") | |
| EXPECT_EQ (assigned.second().name(), "link_b") | |
| EXPECT_EQ (assigned, LinkIdPair(a, b)) | |
| pair | assign (pair.first(), pair.second()) |
| EXPECT_EQ (pair, LinkIdPair(a, b)) | |
| pair | assign (c, pair.first()) |
| EXPECT_EQ (pair, expected) | |
| pair | assign (LinkId(), LinkId()) |
| EXPECT_EQ (pair, LinkIdPair()) | |
| EXPECT_EQ (pair.hash(), LinkIdPair().hash()) | |
| EXPECT_NE (xml.find("test_link"), std::string::npos)<< xml | |
Variables | |
| const LinkId | a2 = LinkId("link_a") |
| const LinkId | b = LinkId("link_b") |
| const LinkId | invalid {} |
| const auto | zero_valued = NameIdTestAccess::create<LinkId>(0, "hashes_to_zero") |
| const LinkId | link = LinkId("foo") |
| const JointId | joint = JointId("foo") |
| std::hash< LinkId > | hasher |
| oss<< "link "<< LinkId("base_link")<< " and joint "<< JointId("joint_1");EXPECT_EQ(oss.str(), "link base_link and joint joint_1");} { std::ostringstream oss;oss<< LinkId{};EXPECT_TRUE(oss.str().empty());} { const LinkId a=LinkId("link_a");const LinkId b=LinkId("link_b");const LinkIdPair ab=LinkIdPair(a, b);const LinkIdPair ba=LinkIdPair(b, a);EXPECT_EQ(ab, ba);EXPECT_LE(ab.first().value(), ab.second().value());} { const LinkIdPair p1=LinkIdPair(LinkId("x"), LinkId("y"));const LinkIdPair p2=LinkIdPair(LinkId("y"), LinkId("x"));const LinkIdPair p3=LinkIdPair(LinkId("x"), LinkId("z"));EXPECT_EQ(p1, p2);EXPECT_NE(p1, p3);} { std::unordered_map< LinkIdPair, int > | map |
| const LinkIdPair | key = LinkIdPair(LinkId("a"), LinkId("b")) |
| const LinkIdPair | reversed = LinkIdPair(LinkId("b"), LinkId("a")) |
| const LinkIdPair | pair = LinkIdPair(a, a) |
| const LinkIdPair | ab = LinkIdPair(a, b) |
| const LinkIdPair | ba = LinkIdPair(b, a) |
| const LinkIdPair | constructed = LinkIdPair(a, b) |
| LinkIdPair | assigned |
| const LinkIdPair | expected = LinkIdPair(LinkId("x"), LinkId("y")) |
| const LinkId | c = LinkId("link_c") |
| const LinkId | id ("test_link") |
| const std::string | xml = Serialization::toArchiveStringXML(id, "id") |
Unit tests for NameId<Tag>, LinkId, JointId, and LinkIdPair types.
| std::hash<LinkId> hasher |
| map[key] |
| const LinkId id("test_link") | ( | "test_link" | ) |