forked from aeron-io/simple-binary-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseline_enum_from_str.rs
More file actions
60 lines (56 loc) · 1.35 KB
/
Copy pathbaseline_enum_from_str.rs
File metadata and controls
60 lines (56 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use examples_baseline::boost_type::BoostType;
use BoostType::{NullVal, KERS, NITROUS, SUPERCHARGER, TURBO};
#[test]
fn test_boost_type_from_str() -> Result<(), ()> {
assert_eq!(
"TURBO".parse::<BoostType>()?,
TURBO,
"Parse \"TURBO\" as BoostType"
);
assert_eq!(
"SUPERCHARGER".parse::<BoostType>()?,
SUPERCHARGER,
"Parse \"SUPERCHARGER\" as BoostType"
);
assert_eq!(
"NITROUS".parse::<BoostType>()?,
NITROUS,
"Parse \"NITROUS\" as BoostType"
);
assert_eq!(
"KERS".parse::<BoostType>()?,
KERS,
"Parse \"KERS\" as BoostType"
);
assert_eq!(
"Turbo".parse::<BoostType>()?,
NullVal,
"Parse \"Turbo\" as BoostType"
);
assert_eq!(
"Supercharger".parse::<BoostType>()?,
NullVal,
"Parse \"Supercharger\" as BoostType"
);
assert_eq!(
"Nitrous".parse::<BoostType>()?,
NullVal,
"Parse \"Nitrous\" as BoostType"
);
assert_eq!(
"Kers".parse::<BoostType>()?,
NullVal,
"Parse \"Kers\" as BoostType"
);
assert_eq!(
"AA".parse::<BoostType>()?,
NullVal,
"Parse \"AA\" as BoostType"
);
assert_eq!(
"".parse::<BoostType>().unwrap(),
NullVal,
"Parse \"\" as BoostType"
);
Ok(())
}