return -1;
if (l.nspace > r.nspace)
return 1;
- if (l.get_key() < r.get_key())
- return -1;
- if (l.get_key() > r.get_key())
- return 1;
+ if (!(l.get_key().empty() && r.get_key().empty())) {
+ if (l.get_effective_key() < r.get_effective_key()) {
+ return -1;
+ }
+ if (l.get_effective_key() > r.get_effective_key()) {
+ return 1;
+ }
+ }
if (l.oid < r.oid)
return -1;
if (l.oid > r.oid)
add_executable(unittest_static_ptr test_static_ptr.cc)
add_ceph_unittest(unittest_static_ptr)
+
+add_executable(unittest_hobject test_hobject.cc
+ $<TARGET_OBJECTS:unit-main>)
+target_link_libraries(unittest_hobject global ceph-common)
+add_ceph_unittest(unittest_hobject)
--- /dev/null
+#include "common/hobject.h"
+#include "gtest/gtest.h"
+
+TEST(HObject, cmp)
+{
+ hobject_t c{object_t{"fooc"}, "food", CEPH_NOSNAP, 42, 0, "nspace"};
+ hobject_t d{object_t{"food"}, "", CEPH_NOSNAP, 42, 0, "nspace"};
+ hobject_t e{object_t{"fooe"}, "food", CEPH_NOSNAP, 42, 0, "nspace"};
+ ASSERT_EQ(-1, cmp(c, d));
+ ASSERT_EQ(-1, cmp(d, e));
+}