Zane Shelley | 72b755f | 2022-01-18 17:06:22 -0600 | [diff] [blame] | 1 | #include <hei_util.hpp> |
| 2 | |
| 3 | #include "gtest/gtest.h" |
| 4 | |
| 5 | using namespace libhei; |
| 6 | |
| 7 | TEST(UtilHash, TestSet1) |
| 8 | { |
| 9 | std::string s{"SOME_RANDOM_STRING"}; |
| 10 | |
Patrick Williams | 2f7537d | 2023-05-10 07:51:39 -0500 | [diff] [blame] | 11 | uint8_t h1 = 0xBE; |
| 12 | uint16_t h2 = 0xF2DD; |
| 13 | uint32_t h3 = 0xDFB31440; |
| 14 | uint64_t h4 = 0xD0D3828Ec49F687C; |
| 15 | NodeId_t h5 = 0xF2DD; // 2-byte field |
Zane Shelley | 72b755f | 2022-01-18 17:06:22 -0600 | [diff] [blame] | 16 | RegisterId_t h6 = static_cast<RegisterId_t>(0x31D080); // 3-byte field |
| 17 | |
| 18 | EXPECT_EQ(h1, hash<uint8_t>(s)); |
| 19 | EXPECT_EQ(h2, hash<uint16_t>(s)); |
| 20 | EXPECT_EQ(h3, hash<uint32_t>(s)); |
| 21 | EXPECT_EQ(h4, hash<uint64_t>(s)); |
| 22 | EXPECT_EQ(h5, hash<NodeId_t>(s)); |
| 23 | EXPECT_EQ(h6, hash<RegisterId_t>(s)); |
| 24 | } |