mirror of
https://github.com/danog/strum.git
synced 2024-11-27 12:24:59 +01:00
30 lines
485 B
Rust
30 lines
485 B
Rust
extern crate strum;
|
|
#[macro_use]
|
|
extern crate strum_macros;
|
|
|
|
use strum::EnumProperty;
|
|
|
|
#[derive(Debug, EnumProperty)]
|
|
enum Test {
|
|
#[strum(props(key="value"))]
|
|
A,
|
|
B,
|
|
}
|
|
|
|
#[test]
|
|
fn prop_test() {
|
|
let a = Test::A;
|
|
assert_eq!("value", a.get_str("key").unwrap());
|
|
}
|
|
|
|
#[test]
|
|
fn prop_test_not_found() {
|
|
let a = Test::A;
|
|
assert_eq!(None, a.get_str("Not Found"));
|
|
}
|
|
|
|
#[test]
|
|
fn prop_test_not_found_2() {
|
|
let b = Test::B;
|
|
assert_eq!(None, b.get_str("key"));
|
|
} |