use strum::{Display, EnumString};
#[derive(Clone, Copy, Debug, Display, EnumString, Eq, Ord, PartialEq, PartialOrd)]
#[non_exhaustive]
#[strum(serialize_all = "lowercase")]
pub enum Architecture {
Aarch64,
Any,
Arm,
Armv6h,
Armv7h,
I486,
I686,
Pentium4,
Riscv32,
Riscv64,
X86_64,
#[strum(to_string = "x86_64_v2")]
X86_64V2,
#[strum(to_string = "x86_64_v3")]
X86_64V3,
#[strum(to_string = "x86_64_v4")]
X86_64V4,
}
#[cfg(test)]
mod tests {
use std::str::FromStr;
use rstest::rstest;
use strum::ParseError;
use super::*;
#[rstest]
#[case("aarch64", Ok(Architecture::Aarch64))]
#[case("any", Ok(Architecture::Any))]
#[case("arm", Ok(Architecture::Arm))]
#[case("armv6h", Ok(Architecture::Armv6h))]
#[case("armv7h", Ok(Architecture::Armv7h))]
#[case("i486", Ok(Architecture::I486))]
#[case("i686", Ok(Architecture::I686))]
#[case("pentium4", Ok(Architecture::Pentium4))]
#[case("riscv32", Ok(Architecture::Riscv32))]
#[case("riscv64", Ok(Architecture::Riscv64))]
#[case("x86_64", Ok(Architecture::X86_64))]
#[case("x86_64_v2", Ok(Architecture::X86_64V2))]
#[case("x86_64_v3", Ok(Architecture::X86_64V3))]
#[case("x86_64_v4", Ok(Architecture::X86_64V4))]
#[case("foo", Err(ParseError::VariantNotFound))]
fn architecture_from_string(#[case] s: &str, #[case] arch: Result<Architecture, ParseError>) {
assert_eq!(Architecture::from_str(s), arch);
}
#[rstest]
#[case(Architecture::Aarch64, "aarch64")]
#[case(Architecture::Any, "any")]
#[case(Architecture::Arm, "arm")]
#[case(Architecture::Armv6h, "armv6h")]
#[case(Architecture::Armv7h, "armv7h")]
#[case(Architecture::I486, "i486")]
#[case(Architecture::I686, "i686")]
#[case(Architecture::Pentium4, "pentium4")]
#[case(Architecture::Riscv32, "riscv32")]
#[case(Architecture::Riscv64, "riscv64")]
#[case(Architecture::X86_64, "x86_64")]
#[case(Architecture::X86_64V2, "x86_64_v2")]
#[case(Architecture::X86_64V3, "x86_64_v3")]
#[case(Architecture::X86_64V4, "x86_64_v4")]
fn architecture_format_string(#[case] arch: Architecture, #[case] arch_str: &str) {
assert_eq!(arch_str, format!("{}", arch));
}
}