quant-primitives 0.7.0

Pure trading primitives — candles, intervals, symbols, currencies, asset taxonomy
Documentation
use super::*;

#[test]
fn normalizes_to_uppercase() {
    let currency = Currency::new("usd");
    assert_eq!(currency.code(), "USD");
}

#[test]
fn equality_is_case_insensitive() {
    let usd1 = Currency::new("usd");
    let usd2 = Currency::new("USD");
    assert_eq!(usd1, usd2);
}

#[test]
fn display_shows_code() {
    let currency = Currency::new("eur");
    assert_eq!(format!("{}", currency), "EUR");
}

#[test]
fn from_str_ref() {
    let c: Currency = "btc".into();
    assert_eq!(c.code(), "BTC");
}

#[test]
fn serde_roundtrip() {
    let original = Currency::new("sol");
    let json = serde_json::to_string(&original).expect("valid json");
    let parsed: Currency = serde_json::from_str(&json).expect("valid json");
    assert_eq!(parsed, original);
}

#[test]
fn hash_consistency() {
    use std::collections::HashSet;
    let mut set = HashSet::new();
    set.insert(Currency::new("usd"));
    assert!(set.contains(&Currency::new("USD")));
}