47 EXPECT_EQ(cxstr_key.hash, bytes_key.hash); |
47 EXPECT_EQ(cxstr_key.hash, bytes_key.hash); |
48 EXPECT_EQ(str_key.len, len); |
48 EXPECT_EQ(str_key.len, len); |
49 EXPECT_EQ(cxstr_key.len, len); |
49 EXPECT_EQ(cxstr_key.len, len); |
50 EXPECT_EQ(bytes_key.len, len); |
50 EXPECT_EQ(bytes_key.len, len); |
51 EXPECT_EQ(bytes_key.len, len); |
51 EXPECT_EQ(bytes_key.len, len); |
52 EXPECT_EQ(str_key.data.cstr, str); |
52 EXPECT_EQ(str_key.data, str); |
53 EXPECT_EQ(bytes_key.data.cbytes, reinterpret_cast<unsigned char const *>(str)); |
|
54 EXPECT_EQ(bytes_key.data.cobj, reinterpret_cast<void const *>(str)); |
|
55 EXPECT_EQ(cxstr_key.data.cobj, reinterpret_cast<void const *>(str)); |
|
56 } |
53 } |
57 |
54 |
58 TEST(cx_hash_key, empty_string) { |
55 TEST(cx_hash_key, empty_string) { |
59 auto str = ""; |
56 auto str = ""; |
60 |
57 |
68 EXPECT_EQ(str_key.hash, 4152238450u); |
65 EXPECT_EQ(str_key.hash, 4152238450u); |
69 EXPECT_EQ(obj_key.hash, 4152238450u); |
66 EXPECT_EQ(obj_key.hash, 4152238450u); |
70 EXPECT_EQ(str_key.len, 0); |
67 EXPECT_EQ(str_key.len, 0); |
71 EXPECT_EQ(bytes_key.len, 0); |
68 EXPECT_EQ(bytes_key.len, 0); |
72 EXPECT_EQ(bytes_key.len, 0); |
69 EXPECT_EQ(bytes_key.len, 0); |
73 EXPECT_EQ(str_key.data.cstr, str); |
70 EXPECT_EQ(str_key.data, str); |
74 EXPECT_EQ(bytes_key.data.cbytes, reinterpret_cast<unsigned char const *>(str)); |
|
75 EXPECT_EQ(bytes_key.data.cobj, reinterpret_cast<void const *>(str)); |
|
76 } |
71 } |
77 |
72 |
78 TEST(cx_hash_key, null_ptr) { |
73 TEST(cx_hash_key, null_ptr) { |
79 auto str_key = cx_hash_key_str(nullptr); |
74 auto str_key = cx_hash_key_str(nullptr); |
80 auto bytes_key = cx_hash_key_bytes(nullptr, 0); |
75 auto bytes_key = cx_hash_key_bytes(nullptr, 0); |
84 EXPECT_EQ(str_key.hash, 1574210520u); |
79 EXPECT_EQ(str_key.hash, 1574210520u); |
85 EXPECT_EQ(obj_key.hash, 1574210520u); |
80 EXPECT_EQ(obj_key.hash, 1574210520u); |
86 EXPECT_EQ(str_key.len, 0); |
81 EXPECT_EQ(str_key.len, 0); |
87 EXPECT_EQ(bytes_key.len, 0); |
82 EXPECT_EQ(bytes_key.len, 0); |
88 EXPECT_EQ(bytes_key.len, 0); |
83 EXPECT_EQ(bytes_key.len, 0); |
89 EXPECT_EQ(str_key.data.cstr, nullptr); |
84 EXPECT_EQ(str_key.data, nullptr); |
90 EXPECT_EQ(bytes_key.data.cbytes, nullptr); |
|
91 EXPECT_EQ(bytes_key.data.cobj, nullptr); |
|
92 } |
85 } |