public static void TestValueConvertUInt() { using (Eina.Value from = new Eina.Value(Eina.ValueType.UInt32)) using (Eina.Value to = new Eina.Value(Eina.ValueType.UInt32)) { uint source = 0xFFFFFFFF; uint target_uint; string target_str; string source_str = $"{source}"; Test.Assert(from.Set(source)); Test.Assert(from.ConvertTo(to)); Test.Assert(to.Get(out target_uint)); Test.AssertEquals(target_uint, source); Test.Assert(to.Setup(Eina.ValueType.Int32)); Test.Assert(!from.ConvertTo(to)); Test.Assert(to.Setup(Eina.ValueType.String)); Test.Assert(from.ConvertTo(to)); Test.Assert(to.Get(out target_str)); Test.AssertEquals(target_str, source_str); // FIXME Add tests for failing ConvertTo() calls when downcasting // to smaller types } }
public static void TestValueListConvert() { using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) using (Eina.Value other = new Eina.Value(Eina.ValueType.Int32)) { other.Set(100); other.ConvertTo(list); Test.AssertEquals(100, (int)list[0]); Test.AssertEquals("[100]", list.ToString()); } }
public static void TestValueArrayConvert() { using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) using (Eina.Value other = new Eina.Value(Eina.ValueType.Int32)) { other.Set(100); other.ConvertTo(array); Test.AssertEquals(100, (int)array[0]); Test.AssertEquals("[100]", array.ToString()); } }