MCPcopy Create free account
hub / github.com/deviceplug/btleplug / test_throw_unwind_panic

Function test_throw_unwind_panic

src/droidplug/jni_utils/exceptions.rs:526–554  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

524
525 #[test]
526 fn test_throw_unwind_panic() {
527 test_utils::JVM_ENV.with(|env| {
528 super::throw_unwind(env, || panic!("This is a panic"))
529 .unwrap_err()
530 .unwrap();
531 assert!(env.exception_check().unwrap());
532 let ex = env.exception_occurred().unwrap();
533 env.exception_clear().unwrap();
534 assert!(
535 env.is_instance_of(ex, "io/github/gedgygedgy/rust/panic/PanicException")
536 .unwrap()
537 );
538
539 let suppressed_list = env
540 .call_method(ex, "getSuppressed", "()[Ljava/lang/Throwable;", &[])
541 .unwrap()
542 .l()
543 .unwrap();
544 assert_eq!(
545 env.get_array_length(suppressed_list.into_inner()).unwrap(),
546 0
547 );
548
549 let ex = super::JPanicException::from_env(env, ex).unwrap();
550 let any = ex.take().unwrap();
551 let str = any.downcast::<&str>().unwrap();
552 assert_eq!(*str, "This is a panic");
553 });
554 }
555
556 #[test]
557 fn test_throw_unwind_panic_suppress() {

Callers

nothing calls this directly

Calls 2

throw_unwindFunction · 0.85
takeMethod · 0.80

Tested by

no test coverage detected