Implement ExtentLess correctly
If two extents start on the same block but have different number of
blocks, current impl of ExtentLess will consider them equal.
Test: th
Change-Id: Ief147f9d0a91b3dcd7f8ccc690f3aea972cbeabb
diff --git a/payload_consumer/extent_map_unittest.cc b/payload_consumer/extent_map_unittest.cc
index e7972cd..867038b 100644
--- a/payload_consumer/extent_map_unittest.cc
+++ b/payload_consumer/extent_map_unittest.cc
@@ -119,4 +119,17 @@
ASSERT_EQ(ret[2].num_blocks(), 2U);
}
+TEST_F(ExtentMapTest, GetSameStartBlock) {
+ ASSERT_TRUE(map_.AddExtent(ExtentForRange(0, 5), 7));
+ ASSERT_TRUE(map_.AddExtent(ExtentForRange(10, 5), 12));
+
+ const auto ret = map_.Get(ExtentForRange(0, 10));
+ // ASSERT_FALSE(ret.has_value()) << ret.value() won't work, because when |ret|
+ // doesn't have value, the part after '<<' after still evaluated, resulting in
+ // undefined behavior.
+ if (ret.has_value()) {
+ FAIL() << ret.value();
+ }
+}
+
} // namespace chromeos_update_engine