typed_money/currency/
ada.rs1use super::{CurrencyType, LiquidityRating, SymbolPosition, VolatilityRating};
2use crate::Currency;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
21pub struct ADA;
22
23impl Currency for ADA {
24 const DECIMALS: u8 = 6;
25 const CODE: &'static str = "ADA";
26 const SYMBOL: &'static str = "₳";
27
28 const NAME: &'static str = "Cardano";
30 const COUNTRY: &'static str = "Global";
31 const REGION: &'static str = "Worldwide";
32 const CURRENCY_TYPE: CurrencyType = CurrencyType::Cryptocurrency;
33 const IS_MAJOR: bool = true;
34 const IS_STABLE: bool = false;
35 const INTRODUCED_YEAR: u16 = 2017;
36 const ISO_4217_NUMBER: u16 = 0; const THOUSANDS_SEPARATOR: char = ',';
38 const DECIMAL_SEPARATOR: char = '.';
39 const SYMBOL_POSITION: SymbolPosition = SymbolPosition::Before;
40 const SPACE_BETWEEN: bool = false;
41 const VOLATILITY_RATING: VolatilityRating = VolatilityRating::High;
42 const LIQUIDITY_RATING: LiquidityRating = LiquidityRating::High;
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48 use crate::Amount;
49
50 #[test]
51 fn test_ada_currency_properties() {
52 assert_eq!(ADA::DECIMALS, 6);
53 assert_eq!(ADA::CODE, "ADA");
54 assert_eq!(ADA::SYMBOL, "₳");
55 }
56
57 #[test]
58 fn test_ada_amount_creation() {
59 let amount = Amount::<ADA>::from_major(1000);
60 assert_eq!(amount.to_major_floor(), 1000);
61 }
62
63 #[test]
64 fn test_ada_amount_with_lovelace() {
65 let amount = Amount::<ADA>::from_minor(1_000_000); assert_eq!(amount.to_major_floor(), 1);
67 assert_eq!(amount.to_minor(), 1_000_000);
68 }
69}