Add GetNthBlockTest am: ca9704edc3
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1769945
Change-Id: I4028c6b96794e3275ada8fca36ad966601fa4923
diff --git a/payload_consumer/install_operation_executor_unittest.cc b/payload_consumer/install_operation_executor_unittest.cc
index 2a99782..3c2fb0f 100644
--- a/payload_consumer/install_operation_executor_unittest.cc
+++ b/payload_consumer/install_operation_executor_unittest.cc
@@ -205,4 +205,22 @@
}
VerityUntouchedExtents(op);
}
+
+TEST_F(InstallOperationExecutorTest, GetNthBlockTest) {
+ std::vector<Extent> extents;
+ extents.emplace_back(ExtentForRange(10, 3));
+ extents.emplace_back(ExtentForRange(20, 2));
+ extents.emplace_back(ExtentForRange(30, 1));
+ extents.emplace_back(ExtentForRange(40, 4));
+
+ ASSERT_EQ(GetNthBlock(extents, 0), 10U);
+ ASSERT_EQ(GetNthBlock(extents, 2), 12U);
+ ASSERT_EQ(GetNthBlock(extents, 3), 20U);
+ ASSERT_EQ(GetNthBlock(extents, 4), 21U);
+ ASSERT_EQ(GetNthBlock(extents, 5), 30U);
+ ASSERT_EQ(GetNthBlock(extents, 6), 40U);
+ ASSERT_EQ(GetNthBlock(extents, 7), 41U);
+ ASSERT_EQ(GetNthBlock(extents, 8), 42U);
+}
+
} // namespace chromeos_update_engine