| 1 | use target_features::{Architecture, Feature, Target}; |
| 2 | |
| 3 | #[test] |
| 4 | fn cpu() { |
| 5 | let mut features = Target::from_cpu(Architecture::X86, "x86-64-v2") |
| 6 | .unwrap() |
| 7 | .features() |
| 8 | .map(|f| f.name()) |
| 9 | .collect::<Vec<_>>(); |
| 10 | features.sort(); |
| 11 | assert_eq!( |
| 12 | &features, |
| 13 | &[ |
| 14 | "cmpxchg16b", |
| 15 | "fxsr", |
| 16 | "lahfsahf", |
| 17 | "popcnt", |
| 18 | "sse", |
| 19 | "sse2", |
| 20 | "sse3", |
| 21 | "sse4.1", |
| 22 | "sse4.2", |
| 23 | "ssse3", |
| 24 | ] |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | #[test] |
| 29 | fn unknown_cpu() { |
| 30 | let _ = Target::from_cpu(Architecture::X86, "this-doesn't-exist").unwrap_err(); |
| 31 | } |
| 32 | |
| 33 | #[test] |
| 34 | fn unknown_feature() { |
| 35 | let _ = Feature::new(Architecture::X86, "this-doesn't-exist").unwrap_err(); |
| 36 | } |