use std::collections::HashMap; use shiny_configuration::value::number::Number; use shiny_configuration::value::Value; fn assert_into_eq>(raw: T, value: Value) { let into_value: Value = raw.into(); assert_eq!(into_value, value); } #[test] fn test_into_value() { // String and char assert_into_eq("hello", Value::String("hello".to_string())); assert_into_eq('c', Value::String("c".to_string())); assert_into_eq("hello".to_string(), Value::String("hello".to_string())); // Bool assert_into_eq(true, Value::Bool(true)); assert_into_eq(false, Value::Bool(false)); // Number assert_into_eq(42i8, Value::Number(Number::Integer(42))); assert_into_eq(42i16, Value::Number(Number::Integer(42))); assert_into_eq(42i32, Value::Number(Number::Integer(42))); assert_into_eq(42i64, Value::Number(Number::Integer(42))); assert_into_eq(42u8, Value::Number(Number::UInteger(42))); assert_into_eq(42u16, Value::Number(Number::UInteger(42))); assert_into_eq(42u32, Value::Number(Number::UInteger(42))); assert_into_eq(42u64, Value::Number(Number::UInteger(42))); assert_into_eq(42f32, Value::Number(Number::Float(42.0))); assert_into_eq(42f64, Value::Number(Number::Float(42.0))); // Option assert_into_eq(Option::::None, Value::None); assert_into_eq(Some(42i32), Value::Number(Number::Integer(42))); assert_into_eq((), Value::None); // Vec assert_into_eq( vec![1, 2, 3], Value::Array(vec![1.into(), 2.into(), 3.into()]), ); // Map assert_into_eq( HashMap::from([("1", 1 as i64), ("2", 2 as i64)]), Value::Map(HashMap::from([ ("1".to_string(), Value::Number(Number::Integer(1))), ("2".to_string(), Value::Number(Number::Integer(2))), ])), ); }