summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ripple/fossil/src/chunker/mod.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/ripple/fossil/src/chunker/mod.rs b/ripple/fossil/src/chunker/mod.rs
index 07b3e8d..c2a9f4c 100644
--- a/ripple/fossil/src/chunker/mod.rs
+++ b/ripple/fossil/src/chunker/mod.rs
@@ -61,9 +61,6 @@ impl<'a> Iterator for Chunker<'a> {
 	}
 
 	fn size_hint(&self) -> (usize, Option<usize>) {
-		if self.buffer.is_empty() {
-			return (0, Some(0));
-		}
 		let min = (self.buffer.len() + MAX_CHUNK_SIZE - 1) / MAX_CHUNK_SIZE;
 		let max = (self.buffer.len() + MIN_CHUNK_SIZE - 1) / MIN_CHUNK_SIZE;
 		(min, Some(max))
@@ -207,4 +204,18 @@ mod test {
 			super::MIN_CHUNK_SIZE / 2
 		);
 	}
+
+	#[test]
+	fn size_hint() {
+		assert_eq!(super::Chunker::from(&[]).size_hint(), (0, Some(0)));
+		assert_eq!(super::Chunker::from(&[0]).size_hint(), (1, Some(1)));
+		assert_eq!(
+			super::Chunker::from(&[0; super::MAX_CHUNK_SIZE]).size_hint(),
+			(1, Some(super::MAX_CHUNK_SIZE / super::MIN_CHUNK_SIZE))
+		);
+		assert_eq!(
+			super::Chunker::from(&[0; super::MAX_CHUNK_SIZE + 1]).size_hint(),
+			(2, Some(super::MAX_CHUNK_SIZE / super::MIN_CHUNK_SIZE + 1))
+		);
+	}
 }