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

How to use assert in unit test? #133

Closed
bbigras opened this issue Feb 21, 2017 · 1 comment
Closed

How to use assert in unit test? #133

bbigras opened this issue Feb 21, 2017 · 1 comment

Comments

@bbigras
Copy link

bbigras commented Feb 21, 2017

I'm trying to do something like this:

#![recursion_limit = "1024"]

#[macro_use]
extern crate error_chain;

mod errors {
    error_chain! { }
}

use errors::*;

fn run() -> Result<()> {
    bail!("test")
}

quick_main!(run);

#[test]
fn test_bail() {
    assert_eq!(run(), Err("test"));
}

When I run it I get:

  Compiling test-chain v0.1.0 (file:///home/bbigras/dev/rust/tests/test-chain)
error[E0369]: binary operation `==` cannot be applied to type `std::result::Result<(), errors::Error>`
  --> src/main.rs:20:5
   |
20 |     assert_eq!(run(), Err("test"));
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: an implementation of `std::cmp::PartialEq` might be missing for `std::result::Result<(), errors::Error>`
   = note: this error originates in a macro outside of the current crate

error: aborting due to previous error

error: Could not compile `test-chain`.

Maybe related to #95.

error-chain 0.9.0
nightly-x86_64-unknown-linux-gnu (default)

@Yamakaky
Copy link
Contributor

Error doesn't implement Eq. Closing for #134

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants