freya-core 0.3.4

Internal core funcionatilies for Freya.
Documentation
use freya_core::{
    parsing::Parse,
    values::CornerRadius,
};

#[test]
fn parse_basic_corner_radius() {
    assert_eq!(
        CornerRadius::parse("3"),
        Ok(CornerRadius {
            top_left: 3.0,
            top_right: 3.0,
            bottom_right: 3.0,
            bottom_left: 3.0,
            smoothing: 0.0
        })
    );
}
#[test]
fn parse_two_value_radius() {
    assert_eq!(
        CornerRadius::parse("2 4"),
        Ok(CornerRadius {
            top_left: 2.0,
            top_right: 2.0,
            bottom_right: 4.0,
            bottom_left: 4.0,
            smoothing: 0.0,
        })
    );
}

#[test]
fn parse_four_value_radius() {
    assert_eq!(
        CornerRadius::parse("2 4 3 1"),
        Ok(CornerRadius {
            top_left: 2.0,
            top_right: 4.0,
            bottom_right: 3.0,
            bottom_left: 1.0,
            smoothing: 0.0,
        })
    );
}

#[test]
fn invalid_radius() {
    let extra_value = CornerRadius::parse("1 2 4 3 1");
    let bad_value_count = CornerRadius::parse("4 3 1");
    let bad_unit = CornerRadius::parse("4deg 3");
    let incorrect_separator = CornerRadius::parse("4, 3, 2, 1");

    assert!(extra_value.is_err());
    assert!(bad_value_count.is_err());
    assert!(bad_unit.is_err());
    assert!(incorrect_separator.is_err());
}