Skip to content

Commit

Permalink
test: Add value variants test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmah309 committed Sep 10, 2024
1 parent 012a755 commit 42ea2d9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,45 @@ pub mod documentation {
}
}

#[cfg(test)]
pub mod value_variants {
use error_set::error_set;

error_set! {
X = {
IoError(std::io::Error),
// #[derive(Clone)]
#[display("My name is {}", name)]
B {
name: String
}
};
Y = {
A,
} || X;
Z = {
C {
val: i32
}
};
}

pub enum Test {
A,
B { name: String },
}

#[test]
fn test() {
let x = X::B {
name: "john".to_string(),
};
assert_eq!(x.to_string(), "My name is john".to_string());
let y: Y = x.into();
assert_eq!(y.to_string(), "My name is john".to_string());
}
}

#[cfg(test)]
pub mod should_not_compile_tests {

Expand Down

0 comments on commit 42ea2d9

Please sign in to comment.