mirror of
https://github.com/zhaofengli/attic.git
synced 2025-03-15 21:08:23 +00:00
server/chunking: Add a couple of test cases on buffer size boundaries
This commit is contained in:
parent
49bd872153
commit
19111317f7
1 changed files with 18 additions and 12 deletions
|
@ -90,8 +90,9 @@ mod tests {
|
||||||
/// Chunks and reconstructs a file.
|
/// Chunks and reconstructs a file.
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chunking_basic() {
|
fn test_chunking_basic() {
|
||||||
|
fn case(size: usize) {
|
||||||
block_on(async move {
|
block_on(async move {
|
||||||
let test_file = get_data(32 * 1024 * 1024); // 32 MiB
|
let test_file = get_data(size); // 32 MiB
|
||||||
let mut reconstructed_file = Vec::new();
|
let mut reconstructed_file = Vec::new();
|
||||||
|
|
||||||
let cursor = Cursor::new(&test_file);
|
let cursor = Cursor::new(&test_file);
|
||||||
|
@ -107,6 +108,11 @@ mod tests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case(32 * 1024 * 1024 - 1);
|
||||||
|
case(32 * 1024 * 1024);
|
||||||
|
case(32 * 1024 * 1024 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns some fake data.
|
/// Returns some fake data.
|
||||||
fn get_data(len: usize) -> Vec<u8> {
|
fn get_data(len: usize) -> Vec<u8> {
|
||||||
let mut state = 42u32;
|
let mut state = 42u32;
|
||||||
|
|
Loading…
Add table
Reference in a new issue