Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 2b5ab06

Browse files
author
Andrii Radyk
committed
Add tests for error conversion
1 parent 946d6d5 commit 2b5ab06

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/fail_compat.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#[macro_use]
2+
extern crate failure;
3+
4+
use failure::Fail;
5+
6+
fn return_failure() -> Result<(), failure::Error> {
7+
#[derive(Fail, Debug)]
8+
#[fail(display = "my error")]
9+
struct MyError;
10+
11+
let err = MyError;
12+
Err(err.into())
13+
}
14+
15+
fn return_error() -> Result<(), Box<std::error::Error>> {
16+
return_failure()?;
17+
Ok(())
18+
}
19+
20+
fn return_error_send_sync() -> Result<(), Box<std::error::Error + Send + Sync>> {
21+
return_failure()?;
22+
Ok(())
23+
}
24+
25+
#[test]
26+
fn smoke_default_compat() {
27+
let err = return_error();
28+
assert!(err.is_err());
29+
}
30+
31+
#[test]
32+
fn smoke_compat_send_sync() {
33+
let err = return_error_send_sync();
34+
assert!(err.is_err());
35+
}

0 commit comments

Comments
 (0)