//! Tests for `cfgmatic` library API.

use cfgmatic::{build_env_name, parse_env_value};

#[test]
fn test_build_env_name() {
    assert_eq!(build_env_name("MYAPP", &["port"]), "MYAPP__PORT");
    assert_eq!(
        build_env_name("MYAPP", &["database", "url"]),
        "MYAPP__DATABASE__URL"
    );
    assert_eq!(build_env_name("", &["port"]), "PORT");
}

#[test]
fn test_parse_env_value() {
    let port: u16 = parse_env_value("8080").unwrap();
    assert_eq!(port, 8080u16);

    let debug: bool = parse_env_value("true").unwrap();
    assert!(debug);

    let host: String = parse_env_value("localhost").unwrap();
    assert_eq!(host, "localhost");
}
