예제 #1
0
        // Could add another POD struct nested in here but it seems to not be blittable when
        // adding a POD struct into another POD struct.

        public static void Run()
        {
            UScriptStruct unrealStruct = UScriptStruct.GetStruct <Test_SimpleBlittableStruct>();

            Tests.Assert(unrealStruct != null, "Test_SimpleBlittableStruct");

            Tests.AssertProperty <UInt8Property>(unrealStruct, "Val1");
            Tests.AssertProperty <UByteProperty>(unrealStruct, "Val2");
            Tests.AssertProperty <UInt16Property>(unrealStruct, "Val3");
            Tests.AssertProperty <UUInt16Property>(unrealStruct, "Val4");
            Tests.AssertProperty <UIntProperty>(unrealStruct, "Val5");
            Tests.AssertProperty <UUInt32Property>(unrealStruct, "Val6");
            Tests.AssertProperty <UInt64Property>(unrealStruct, "Val7");
            Tests.AssertProperty <UUInt64Property>(unrealStruct, "Val8");
            Tests.AssertProperty <UFloatProperty>(unrealStruct, "Val9");
            Tests.AssertProperty <UDoubleProperty>(unrealStruct, "Val10");
            Tests.AssertProperty <UNameProperty>(unrealStruct, "Val11");

            Tests.Assert(StructDefault <Test_SimpleBlittableStruct> .IsBlittableStruct, unrealStruct, "IsBlittableStruct");
            Tests.Assert(unrealStruct.StructFlags.HasFlag(EStructFlags.IsPlainOldData), unrealStruct, "IsPlainOldData");

            Test_SimpleBlittableStruct defaultValue = StructDefault <Test_SimpleBlittableStruct> .Value;

            Tests.AssertEqual(defaultValue, default(Test_SimpleBlittableStruct), unrealStruct, "default state");
        }
예제 #2
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_SimpleClassTMap>();

            Tests.Assert(unrealClass != null, "Test_SimpleClassTMap");

            Tests.AssertTMapProperty <UInt8Property, UNameProperty>(unrealClass, "Val1");
            Tests.AssertTMapProperty <UByteProperty, UStrProperty>(unrealClass, "Val2");
            Tests.AssertTMapProperty <UInt16Property, USoftObjectProperty>(unrealClass, "Val3");
            Tests.AssertTMapProperty <UUInt16Property, USoftClassProperty>(unrealClass, "Val4");
            Tests.AssertTMapProperty <UIntProperty, USoftClassProperty>(unrealClass, "Val5");
            Tests.AssertTMapProperty <UUInt32Property, UWeakObjectProperty>(unrealClass, "Val6");
            Tests.AssertTMapProperty <UInt64Property, ULazyObjectProperty>(unrealClass, "Val7");
            Tests.AssertTMapProperty <UUInt64Property, UClassProperty>(unrealClass, "Val8");
            Tests.AssertTMapProperty <UFloatProperty, UStructProperty>(unrealClass, "Val9");
            Tests.AssertTMapProperty <UDoubleProperty, UEnumProperty>(unrealClass, "Val10");
            //Tests.AssertTMapProperty<UDelegateProperty, UObjectProperty>(unrealClass, "Val11");
            //Tests.AssertTMapProperty<UMulticastDelegateProperty, UMulticastDelegateProperty>(unrealClass, "Val12");
            Tests.AssertTMapProperty <UObjectProperty, UDelegateProperty>(unrealClass, "Val13");
            Tests.AssertTMapProperty <UEnumProperty, UDoubleProperty>(unrealClass, "Val14");
            Tests.AssertTMapProperty <UStructProperty, UFloatProperty>(unrealClass, "Val15");
            Tests.AssertTMapProperty <UClassProperty, UUInt64Property>(unrealClass, "Val16");
            Tests.AssertTMapProperty <ULazyObjectProperty, UInt64Property>(unrealClass, "Val17");
            //Tests.AssertTMapProperty<UWeakObjectProperty, UUInt32Property>(unrealClass, "Val18");
            Tests.AssertTMapProperty <USoftClassProperty, UIntProperty>(unrealClass, "Val19");
            Tests.AssertTMapProperty <USoftObjectProperty, UUInt16Property>(unrealClass, "Val20");
            Tests.AssertTMapProperty <UStrProperty, UInt16Property>(unrealClass, "Val21");
            Tests.AssertTMapProperty <UNameProperty, UByteProperty>(unrealClass, "Val22");
            //Tests.AssertTSetProperty<UTextProperty>(unrealClass, "Val23");

            Test_SimpleClassTMap obj = NewObject <Test_SimpleClassTMap>();

            obj.Val1.Add(100, new FName("test1"));
            Tests.AssertEqual(obj.Val1[100], new FName("test1"), unrealClass, "Val1");
            obj.Val1.Add(101, new FName("test2"));
            Tests.AssertEqual(obj.Val1[101], new FName("test2"), unrealClass, "Val1");
            obj.Val1.Add(101, new FName("test3"));
            IDictionary <sbyte, FName> test = obj.Val1;

            Tests.AssertEqual(obj.Val1[101], new FName("test3"), unrealClass, "Val1");
            Tests.AssertEqual(obj.Val1.Count, 2, unrealClass, "Val1");
            obj.Val1.Remove(101);
            Tests.AssertEqual(obj.Val1.Count, 1, unrealClass, "Val1");
            obj.Val1.Clear();
            Tests.AssertEqual(obj.Val1.Count, 0, unrealClass, "Val1");

            obj.Val2.Add(102, "test4");
            obj.Val2.Add(103, "test5");
            Tests.AssertEqual(obj.Val2[102], "test4", unrealClass, "Val2");
            Tests.AssertEqual(obj.Val2[103], "test5", unrealClass, "Val2");
            Tests.AssertEqual(obj.Val2.Count, 2, unrealClass, "Val2");

            obj.Val3.Add(103, new TSoftObject <UObject>(Tests.ActorClass));
            obj.Val3.Add(104, TSoftObject <UObject> .Null);
            Tests.AssertEqual(obj.Val3[103], new TSoftObject <UObject>(Tests.ActorClass), unrealClass, "Val3");
            Tests.AssertEqual(obj.Val3[104], TSoftObject <UObject> .Null, unrealClass, "Val3");
            obj.Val3[103] = TSoftObject <UObject> .Null;
            obj.Val3[104] = new TSoftObject <UObject>(Tests.ActorClass);
            Tests.AssertEqual(obj.Val3[103], TSoftObject <UObject> .Null, unrealClass, "Val3");
            Tests.AssertEqual(obj.Val3[104], new TSoftObject <UObject>(Tests.ActorClass), unrealClass, "Val3");

            obj.Val4.Add(105, new TSoftClass <UObject>(Tests.ActorClass));
            obj.Val4.Add(106, TSoftClass <UObject> .Null);
            Tests.AssertEqual(obj.Val4[105], new TSoftClass <UObject>(Tests.ActorClass), unrealClass, "Val4");
            Tests.AssertEqual(obj.Val4[106], TSoftClass <UObject> .Null, unrealClass, "Val4");

            obj.Val5.Add(107, new TSoftClass <UObject>(Tests.ActorClass));
            obj.Val5.Add(108, TSoftClass <UObject> .Null);
            Tests.AssertEqual(obj.Val5[107], new TSoftClass <UObject>(Tests.ActorClass), unrealClass, "Val5");
            Tests.AssertEqual(obj.Val5[108], TSoftClass <UObject> .Null, unrealClass, "Val5");

            obj.Val6.Add(109, new TWeakObject <UObject>(Tests.ActorClass));
            obj.Val6.Add(110, TWeakObject <UObject> .Null);
            Tests.AssertEqual(obj.Val6[109], new TWeakObject <UObject>(Tests.ActorClass), unrealClass, "Val6");
            Tests.AssertEqual(obj.Val6[110], TWeakObject <UObject> .Null, unrealClass, "Val6");

            obj.Val7.Add(111, new TLazyObject <UObject>(Tests.ActorClass));
            obj.Val7.Add(112, TLazyObject <UObject> .Null);
            Tests.AssertEqual(obj.Val7[111], new TLazyObject <UObject>(Tests.ActorClass), unrealClass, "Val7");
            Tests.AssertEqual(obj.Val7[112], TLazyObject <UObject> .Null, unrealClass, "Val7");

            obj.Val8.Add(113, new TSubclassOf <UObject>(Tests.ActorClass));
            obj.Val8.Add(114, TSubclassOf <UObject> .Null);
            Tests.AssertEqual(obj.Val8[113], new TSubclassOf <UObject>(Tests.ActorClass), unrealClass, "Val8");
            Tests.AssertEqual(obj.Val8[114], TSubclassOf <UObject> .Null, unrealClass, "Val8");

            Test_SimpleBlittableStruct blitt1 = StructDefault <Test_SimpleBlittableStruct> .Value;

            blitt1.Val1 = 10;
            blitt1.Val2 = 11;
            obj.Val9.Add(115.5f, blitt1);
            obj.Val9.Add(116.5f, default(Test_SimpleBlittableStruct));
            Tests.AssertEqual(obj.Val9[115.5f], blitt1, unrealClass, "Val9");
            Tests.AssertEqual(obj.Val9[116.5f], default(Test_SimpleBlittableStruct), unrealClass, "Val9");

            obj.Val10.Add(117.2, Test_SimpleEnum.Val2);
            obj.Val10.Add(118.2, Test_SimpleEnum.Val3);
            Tests.AssertEqual(obj.Val10[117.2], Test_SimpleEnum.Val2, unrealClass, "Val10");
            Tests.AssertEqual(obj.Val10[118.2], Test_SimpleEnum.Val3, unrealClass, "Val10");

            Test_SimpleDelegate simpleDelegate = new Test_SimpleDelegate();

            simpleDelegate.Bind(obj.BindSimpleDelegate);
            obj.Val13.Add(Tests.ActorClass, simpleDelegate);
            obj.Val13.Add(null, null);
            Tests.Assert(obj.Val13[Tests.ActorClass].IsTargetBound(obj, new FName("BindSimpleDelegate")), unrealClass, "Val13");
            Tests.Assert(!obj.Val13[null].IsBound, unrealClass, "Val13");

            obj.Val14.Add(Test_SimpleEnum.Val3, 0.3);
            obj.Val14.Add(Test_SimpleEnum.Val2, 0.6);
            Tests.AssertEqual(obj.Val14[Test_SimpleEnum.Val3], 0.3, unrealClass, "Val14");
            Tests.AssertEqual(obj.Val14[Test_SimpleEnum.Val2], 0.6, unrealClass, "Val14");

            obj.Val15.Add(blitt1, 0.4f);
            obj.Val15.Add(default(Test_SimpleBlittableStruct), 0.8f);
            Tests.AssertEqual(obj.Val15[blitt1], 0.4f, unrealClass, "Val15");
            Tests.AssertEqual(obj.Val15[default(Test_SimpleBlittableStruct)], 0.8f, unrealClass, "Val15");

            obj.Val16.Add(new TSubclassOf <UObject>(Tests.ActorClass), 22u);
            obj.Val16.Add(TSubclassOf <UObject> .Null, 24u);
            Tests.AssertEqual(obj.Val16[new TSubclassOf <UObject>(Tests.ActorClass)], 22u, unrealClass, "Val16");
            Tests.AssertEqual(obj.Val16[TSubclassOf <UObject> .Null], 24u, unrealClass, "Val16");

            obj.Val17.Add(new TLazyObject <UObject>(Tests.ActorClass), 25);
            obj.Val17.Add(TLazyObject <UObject> .Null, 26);
            Tests.AssertEqual(obj.Val17[new TLazyObject <UObject>(Tests.ActorClass)], 25, unrealClass, "Val17");
            Tests.AssertEqual(obj.Val17[TLazyObject <UObject> .Null], 26, unrealClass, "Val17");

            obj.Val19.Add(new TSoftClass <UObject>(Tests.ActorClass), 29);
            obj.Val19.Add(TSoftClass <UObject> .Null, 30);
            Tests.AssertEqual(obj.Val19[new TSoftClass <UObject>(Tests.ActorClass)], 29, unrealClass, "Val19");
            Tests.AssertEqual(obj.Val19[TSoftClass <UObject> .Null], 30, unrealClass, "Val19");

            obj.Val20.Add(new TSoftObject <UObject>(Tests.ActorClass), 31);
            obj.Val20.Add(TSoftObject <UObject> .Null, 32);
            Tests.AssertEqual(obj.Val20[new TSoftObject <UObject>(Tests.ActorClass)], 31, unrealClass, "Val20");
            Tests.AssertEqual(obj.Val20[TSoftObject <UObject> .Null], 32, unrealClass, "Val20");

            obj.Val21.Add("test1", 33);
            obj.Val21.Add("test2", 34);
            Tests.AssertEqual(obj.Val21["test1"], 33, unrealClass, "Val21");
            Tests.AssertEqual(obj.Val21["test2"], 34, unrealClass, "Val21");

            obj.Val22.Add(new FName("test3"), 35);
            obj.Val22.Add(new FName("test4"), 36);
            Tests.AssertEqual(obj.Val22[new FName("test3")], 35, unrealClass, "Val22");
            Tests.AssertEqual(obj.Val22[new FName("test4")], 36, unrealClass, "Val22");
        }
예제 #3
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_SimpleClassTSet>();

            Tests.Assert(unrealClass != null, "Test_SimpleClassTSet");

            Tests.AssertTSetProperty <UInt8Property>(unrealClass, "Val1");
            Tests.AssertTSetProperty <UByteProperty>(unrealClass, "Val2");
            Tests.AssertTSetProperty <UInt16Property>(unrealClass, "Val3");
            Tests.AssertTSetProperty <UUInt16Property>(unrealClass, "Val4");
            Tests.AssertTSetProperty <UIntProperty>(unrealClass, "Val5");
            Tests.AssertTSetProperty <UUInt32Property>(unrealClass, "Val6");
            Tests.AssertTSetProperty <UInt64Property>(unrealClass, "Val7");
            Tests.AssertTSetProperty <UUInt64Property>(unrealClass, "Val8");
            Tests.AssertTSetProperty <UFloatProperty>(unrealClass, "Val9");
            Tests.AssertTSetProperty <UDoubleProperty>(unrealClass, "Val10");
            //Tests.AssertTSetProperty<UDelegateProperty>(unrealClass, "Val11");
            //Tests.AssertTSetProperty<UMulticastDelegateProperty>(unrealClass, "Val12");
            Tests.AssertTSetProperty <UObjectProperty>(unrealClass, "Val13");
            Tests.AssertTSetProperty <UEnumProperty>(unrealClass, "Val14");
            Tests.AssertTSetProperty <UStructProperty>(unrealClass, "Val15");
            Tests.AssertTSetProperty <UClassProperty>(unrealClass, "Val16");
            Tests.AssertTSetProperty <ULazyObjectProperty>(unrealClass, "Val17");
            //Tests.AssertTSetProperty<UWeakObjectProperty>(unrealClass, "Val18");
            Tests.AssertTSetProperty <USoftClassProperty>(unrealClass, "Val19");
            Tests.AssertTSetProperty <USoftObjectProperty>(unrealClass, "Val20");
            Tests.AssertTSetProperty <UStrProperty>(unrealClass, "Val21");
            Tests.AssertTSetProperty <UNameProperty>(unrealClass, "Val22");
            //Tests.AssertTSetProperty<UTextProperty>(unrealClass, "Val23");

            Test_SimpleClassTSet obj = NewObject <Test_SimpleClassTSet>();

            obj.Val1.Add(100);
            Tests.Assert(obj.Val1.Contains(100), unrealClass, "Val1");
            obj.Val1.Add(101);
            Tests.Assert(obj.Val1.Contains(101), unrealClass, "Val1");
            Tests.Assert(!obj.Val1.Add(101), unrealClass, "Val1");
            Tests.AssertEqual(obj.Val1.Count, 2, unrealClass, "Val1");
            obj.Val1.Remove(101);
            Tests.AssertEqual(obj.Val1.Count, 1, unrealClass, "Val1");
            obj.Val1.Clear();
            Tests.AssertEqual(obj.Val1.Count, 0, unrealClass, "Val1");

            obj.Val2.Add(102);
            obj.Val2.Add(103);
            Tests.Assert(obj.Val2.Contains(102), unrealClass, "Val2");
            Tests.Assert(obj.Val2.Contains(102), unrealClass, "Val2");
            Tests.AssertEqual(obj.Val2.Count, 2, unrealClass, "Val2");

            obj.Val3.Add(103);
            obj.Val3.Add(104);
            Tests.Assert(obj.Val3.Contains(103), unrealClass, "Val3");
            Tests.Assert(obj.Val3.Contains(104), unrealClass, "Val3");

            obj.Val4.Add(105);
            obj.Val4.Add(106);
            Tests.Assert(obj.Val4.Contains(105), unrealClass, "Val4");
            Tests.Assert(obj.Val4.Contains(106), unrealClass, "Val4");

            obj.Val5.Add(107);
            obj.Val5.Add(108);
            Tests.Assert(obj.Val5.Contains(107), unrealClass, "Val5");
            Tests.Assert(obj.Val5.Contains(108), unrealClass, "Val5");

            obj.Val6.Add(109);
            obj.Val6.Add(110);
            Tests.Assert(obj.Val6.Contains(109), unrealClass, "Val6");
            Tests.Assert(obj.Val6.Contains(110), unrealClass, "Val6");

            obj.Val7.Add(111);
            obj.Val7.Add(112);
            Tests.Assert(obj.Val7.Contains(111), unrealClass, "Val7");
            Tests.Assert(obj.Val7.Contains(112), unrealClass, "Val7");

            obj.Val8.Add(113);
            obj.Val8.Add(114);
            Tests.Assert(obj.Val8.Contains(113), unrealClass, "Val8");
            Tests.Assert(obj.Val8.Contains(114), unrealClass, "Val8");

            obj.Val9.Add(115.5f);
            obj.Val9.Add(116.5f);
            Tests.Assert(obj.Val9.Contains(115.5f), unrealClass, "Val9");
            Tests.Assert(obj.Val9.Contains(116.5f), unrealClass, "Val9");

            obj.Val10.Add(117.2);
            obj.Val10.Add(118.2);
            Tests.Assert(obj.Val10.Contains(117.2), unrealClass, "Val10");
            Tests.Assert(obj.Val10.Contains(118.2), unrealClass, "Val10");

            Tests.Assert(!obj.Val13.Contains(Tests.ActorClass), unrealClass, "Val13");
            Tests.Assert(!obj.Val13.Contains(null), unrealClass, "Val13");
            obj.Val13.Add(Tests.ActorClass);
            obj.Val13.Add(null);
            Tests.Assert(obj.Val13.Contains(Tests.ActorClass), unrealClass, "Val13");
            Tests.Assert(obj.Val13.Contains(null), unrealClass, "Val13");

            obj.Val14.Add(Test_SimpleEnum.Val3);
            obj.Val14.Add(Test_SimpleEnum.Val2);
            Tests.Assert(obj.Val14.Contains(Test_SimpleEnum.Val3), unrealClass, "Val14");
            Tests.Assert(obj.Val14.Contains(Test_SimpleEnum.Val2), unrealClass, "Val14");

            Test_SimpleBlittableStruct blitt1 = StructDefault <Test_SimpleBlittableStruct> .Value;

            blitt1.Val1 = 10;
            blitt1.Val2 = 11;
            obj.Val15.Add(blitt1);
            obj.Val15.Add(default(Test_SimpleBlittableStruct));
            Tests.Assert(obj.Val15.Contains(blitt1), unrealClass, "Val15");
            Tests.Assert(obj.Val15.Contains(default(Test_SimpleBlittableStruct)), unrealClass, "Val15");

            obj.Val16.Add(new TSubclassOf <UObject>(Tests.ActorClass));
            obj.Val16.Add(TSubclassOf <UObject> .Null);
            Tests.Assert(obj.Val16.Contains(new TSubclassOf <UObject>(Tests.ActorClass)), unrealClass, "Val16");
            Tests.Assert(obj.Val16.Contains(TSubclassOf <UObject> .Null), unrealClass, "Val16");

            obj.Val17.Add(new TLazyObject <UObject>(Tests.ActorClass));
            obj.Val17.Add(TLazyObject <UObject> .Null);
            Tests.Assert(obj.Val17.Contains(new TLazyObject <UObject>(Tests.ActorClass)), unrealClass, "Val17");
            Tests.Assert(obj.Val17.Contains(TLazyObject <UObject> .Null), unrealClass, "Val17");

            obj.Val19.Add(new TSoftClass <UObject>(Tests.ActorClass));
            obj.Val19.Add(TSoftClass <UObject> .Null);
            Tests.Assert(obj.Val19.Contains(new TSoftClass <UObject>(Tests.ActorClass)), unrealClass, "Val19");
            Tests.Assert(obj.Val19.Contains(TSoftClass <UObject> .Null), unrealClass, "Val19");

            obj.Val20.Add(new TSoftObject <UObject>(Tests.ActorClass));
            obj.Val20.Add(TSoftObject <UObject> .Null);
            Tests.Assert(obj.Val20.Contains(new TSoftObject <UObject>(Tests.ActorClass)), unrealClass, "Val20");
            Tests.Assert(obj.Val20.Contains(TSoftObject <UObject> .Null), unrealClass, "Val20");

            obj.Val21.Add("test1");
            obj.Val21.Add("test2");
            Tests.Assert(obj.Val21.Contains("test1"), unrealClass, "Val21");
            Tests.Assert(obj.Val21.Contains("test2"), unrealClass, "Val21");

            obj.Val22.Add(new FName("test3"));
            obj.Val22.Add(new FName("test4"));
            Tests.Assert(obj.Val22.Contains(new FName("test3")), unrealClass, "Val22");
            Tests.Assert(obj.Val22.Contains(new FName("test4")), unrealClass, "Val22");
        }
예제 #4
0
        public static void Run()
        {
            Test_SimpleStructOnClass obj = UObject.NewObject <Test_SimpleStructOnClass>();

            Tests.Assert(obj != null, "Test_SimpleStructOnClass NewObject");

            UClass uclass = obj.GetClass();

            Tests.AssertEqual(uclass, UClass.GetClass(obj.GetType()), "Test_SimpleStructOnClass GetClass/Type");

            // Create another obj of the same type for comparisons of
            Test_SimpleStructOnClass other = UObject.NewObject <Test_SimpleStructOnClass>();

            // Test BlittableStruct default state
            string msg = "BlittableStruct default state";

            Tests.AssertDefault(obj.BlittableStruct.Val1, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val2, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val3, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val4, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val5, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val6, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val7, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val8, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val9, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val10, uclass, msg);
            Tests.AssertDefault(obj.BlittableStruct.Val11, uclass, msg);

            // Test Struct default state
            msg = "Struct default state";
            Tests.AssertDefault(obj.Struct.Val0, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val1, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val2, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val3, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val4, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val5, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val6, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val7, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val8, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val9, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val10, uclass, msg);
            //Tests.AssertDefault(obj.Struct.Val11, uclass, msg);// delegate will be non-null from struct marshaler
            //Tests.AssertDefault(obj.Struct.Val12, uclass, msg);// delegate will be non-null from struct marshaler
            Tests.AssertDefault(obj.Struct.Val13, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val14, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val15, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val16, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val17, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val18, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val19, uclass, msg);
            Tests.AssertDefault(obj.Struct.Val20, uclass, msg);
            //Tests.AssertDefault(obj.Struct.Val21, uclass, msg);// string will be non null from struct marshaler
            Tests.AssertDefault(obj.Struct.Val22, uclass, msg);

            Test_SimpleBlittableStruct blittableStructVal = obj.BlittableStruct;

            blittableStructVal.Val1  = 1;
            blittableStructVal.Val2  = 2;
            blittableStructVal.Val3  = 3;
            blittableStructVal.Val4  = 4;
            blittableStructVal.Val5  = 5;
            blittableStructVal.Val6  = 6;
            blittableStructVal.Val7  = 7;
            blittableStructVal.Val8  = 8;
            blittableStructVal.Val9  = 9;
            blittableStructVal.Val10 = 10;
            blittableStructVal.Val11 = new FName("Hello world");
            obj.BlittableStruct      = blittableStructVal;
            Tests.AssertEqual(obj.BlittableStruct, blittableStructVal, uclass, "modify BlittableStruct");

            Test_SimpleStruct structVal = obj.Struct;

            structVal.Val0  = true;
            structVal.Val1  = 1;
            structVal.Val2  = 2;
            structVal.Val3  = 3;
            structVal.Val4  = 4;
            structVal.Val5  = 5;
            structVal.Val6  = 6;
            structVal.Val7  = 7;
            structVal.Val8  = 8;
            structVal.Val9  = 9;
            structVal.Val10 = 10;
            structVal.Val11.Bind(obj.BindToStructDelegate);
            structVal.Val12.Bind(obj.BindToStructMulticastDelegate1);
            structVal.Val12.Bind(obj.BindToStructMulticastDelegate2);
            structVal.Val12.Bind(obj.BindToStructMulticastDelegate3);
            structVal.Val13 = other;
            structVal.Val14 = Test_SimpleEnum.Val3;
            structVal.Val15 = new Test_SimpleBlittableStruct()
            {
                Val1  = 1,
                Val2  = 2,
                Val3  = 3,
                Val4  = 4,
                Val5  = 5,
                Val6  = 6,
                Val7  = 7,
                Val8  = 8,
                Val9  = 9,
                Val10 = 10,
                Val11 = new FName("Hello world")
            };
            structVal.Val16.SetClass <Test_SimpleStructOnClass>();
            structVal.Val17.Set(other);
            structVal.Val18.Set(obj);
            structVal.Val19.SetClass <Test_SimpleStructOnClass>();
            structVal.Val20.Value = UClass.GetClass <Test_SimpleStructOnClass>();
            structVal.Val21       = "Hello!";
            structVal.Val22       = new FName("Hello FName");

            Tests.Assert(structVal.Val11.IsBound, uclass, ".Val11.IsBound");
            Tests.Assert(structVal.Val12.IsBound, uclass, ".Val12.IsBound");
            obj.Struct = structVal;
            //Tests.AssertEqual(obj.Struct, structVal, uclass, "modify Struct");
            // We can't test equals of struct value due to new instances of delegates created on each struct marshal
            // TODO: Replace delegates with structs so they dont require allocation of new managed classes on marshaling

            Test_SimpleStruct newStructVal = obj.Struct;

            Tests.AssertEqual(newStructVal.Val0, true, uclass, ".Val0");
            Tests.AssertEqual(newStructVal.Val1, 1, uclass, ".Val1");
            Tests.AssertEqual(newStructVal.Val2, 2, uclass, ".Val2");
            Tests.AssertEqual(newStructVal.Val3, 3, uclass, ".Val3");
            Tests.AssertEqual(newStructVal.Val4, 4, uclass, ".Val4");
            Tests.AssertEqual(newStructVal.Val5, 5, uclass, ".Val5");
            Tests.AssertEqual(newStructVal.Val6, 6u, uclass, ".Val6");
            Tests.AssertEqual(newStructVal.Val7, 7, uclass, ".Val7");
            Tests.AssertEqual(newStructVal.Val8, 8u, uclass, ".Val8");
            Tests.AssertEqual(newStructVal.Val9, 9.0f, uclass, ".Val9");
            Tests.AssertEqual(newStructVal.Val10, 10.0, uclass, ".Val10");
            //Tests.AssertEqual(newStructVal.Val11, , uclass, ".Val11");
            //Tests.AssertEqual(newStructVal.Val12, , uclass, ".Val12");
            Tests.AssertEqual(newStructVal.Val13, other, uclass, ".Val13");
            Tests.AssertEqual(newStructVal.Val14, Test_SimpleEnum.Val3, uclass, ".Val14");
            Tests.AssertEqual(newStructVal.Val15, structVal.Val15, uclass, ".Val15");
            Tests.AssertEqual(obj.Struct.Val16.Value, UClass.GetClass <Test_SimpleStructOnClass>(), uclass, ".Val16");
            Tests.AssertEqual(obj.Struct.Val17.Get(), other, uclass, ".Val17");
            Tests.AssertEqual(obj.Struct.Val18.Get(), obj, uclass, ".Val18");
            Tests.AssertEqual(obj.Struct.Val19.Value, UClass.GetClass <Test_SimpleStructOnClass>(), uclass, ".Val19");
            Tests.AssertEqual(obj.Struct.Val20.Value, UClass.GetClass <Test_SimpleStructOnClass>(), uclass, ".Val20");

            // Test the delegates
            double param3 = 44.3;
            string param4;
            TSoftClass <UObject> someClass = structVal.Val11.Invoke(13, "inParam2", ref param3, out param4);

            Tests.AssertEqual(param3, 99.88, uclass, ".BindToStructDelegate.param3");
            Tests.AssertEqual(param4, "outParam4", uclass, ".BindToStructDelegate.param4");
            Tests.AssertEqual(someClass.Value, UClass.GetClass <Test_SimpleStructOnClass>(), uclass, ".BindToStructDelegate." + UFunction.ReturnValuePropName);

            // Test the multicast delegate
            int param3Multicast = 1;

            structVal.Val12.Invoke(3u, "param2", ref param3Multicast);
            Tests.AssertEqual(param3Multicast, 4, ".BindToStructMulticastDelegate.param3");
        }
예제 #5
0
 public static void Run()
 {
     Test_SimpleBlittableStruct.Run();
     Test_SimpleStruct.Run();
     Test_SimpleStructOnClass.Run();
 }