MCPcopy Create free account
hub / github.com/RustCrypto/utils / read_buffer_exception_safety

Function read_buffer_exception_safety

block-buffer/tests/mod.rs:406–435  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

404
405#[test]
406fn read_buffer_exception_safety() {
407 let mut buf = ReadBuffer::<U4>::default();
408
409 let res = catch_unwind(AssertUnwindSafe(|| {
410 buf.write_block(
411 1,
412 |block| {
413 block[0] = 0xFF;
414 panic!("block generation panic");
415 },
416 |_| {},
417 );
418 }));
419
420 assert!(res.is_err());
421 let _ = buf.get_pos();
422
423 let mut buf = ReadBuffer::<U4>::default();
424
425 let res = catch_unwind(AssertUnwindSafe(|| {
426 buf.write_block(
427 1,
428 |block| block.0 = [0xFF; 4],
429 |_| panic!("data read panic"),
430 );
431 }));
432
433 assert!(res.is_err());
434 let _ = buf.get_pos();
435}

Callers

nothing calls this directly

Calls 3

defaultFunction · 0.85
write_blockMethod · 0.80
get_posMethod · 0.45

Tested by

no test coverage detected