MRPT  1.9.9
ts_hash_map_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
12 
13 template <typename T>
15 {
16  T h1, h2;
17  mrpt::containers::reduced_hash("prueba1", h1);
18  mrpt::containers::reduced_hash("prueba2", h2);
19  EXPECT_NE(h1, h2);
20 }
21 
22 TEST(ts_hash_map, string_hash_u8) { simple_test_hash_string<uint8_t>(); }
23 TEST(ts_hash_map, string_hash_u16) { simple_test_hash_string<uint16_t>(); }
24 TEST(ts_hash_map, string_hash_u32) { simple_test_hash_string<uint32_t>(); }
25 TEST(ts_hash_map, string_hash_u64) { simple_test_hash_string<uint64_t>(); }
26 TEST(ts_hash_map, stdstring_key)
27 {
28  mrpt::containers::ts_hash_map<std::string, double> m;
29 
30  EXPECT_TRUE(m.empty());
31 
32  m["numero"] = 2.3;
33  EXPECT_FALSE(m.empty());
34  m.clear();
35  EXPECT_TRUE(m.empty());
36 
37  m["uno"] = 1.0;
38  m["dos"] = 2.0;
39  m["tres"] = 3.0;
40 
41  EXPECT_EQ(1.0, m["uno"]);
42  EXPECT_EQ(2.0, m["dos"]);
43  EXPECT_EQ(3.0, m["tres"]);
44 
45  m["tres"]++;
46  EXPECT_EQ(4.0, m["tres"])
47  << "Fail after ++ operator applied to reference [].";
48 
49  double num = .0;
50  for (const auto& e : m) num += e.second;
51  EXPECT_NEAR(num, 7.0, 1e-10)
52  << "Fail after visiting and summing all entries";
53 
54  {
55  const auto& it = m.find("pepe");
56  EXPECT_TRUE(it == m.end());
57  }
58 
59  {
60  const auto& it = m.find("uno");
61  EXPECT_TRUE(it->second == 1.0);
62  }
63 }
void simple_test_hash_string()
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
TEST(ts_hash_map, string_hash_u8)
void reduced_hash(const std::string_view &value, uint8_t &hash)
hash function used by ts_hash_map.
Definition: ts_hash_map.cpp:25
ts_hash_map()=default
< Default constructor */
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020