Exemple #1
0
        public static void Run()
        {
            Test_SimpleStructTArray.Run();
            Test_SimpleStructTSet.Run();
            Test_SimpleStructTMap.Run();

            Test_SimpleClassTArray.Run();
            Test_SimpleClassTSet.Run();
            Test_SimpleClassTMap.Run();
        }
Exemple #2
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_SimpleClassTArray>();

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

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

            Test_SimpleClassTArray obj = NewObject <Test_SimpleClassTArray>();

            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.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");

            // TODO: Refactor delegates or implement IEquatable so that IndexOf works
            //Test_SimpleDelegate simpleDelegate = new Test_SimpleDelegate();
            //simpleDelegate.Bind(obj.BindSimpleDelegate);
            //obj.Val11.Add(simpleDelegate);
            //int indx = obj.Val11.IndexOf(simpleDelegate);
            //Tests.Assert(indx == 0 && obj.Val11[0].IsBound, unrealClass, "Val13");

            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.Val18.Add(new TWeakObject <UObject>(Tests.ActorClass));
            obj.Val18.Add(TWeakObject <UObject> .Null);
            Tests.Assert(obj.Val18.Contains(new TWeakObject <UObject>(Tests.ActorClass)), unrealClass, "Val18");
            Tests.Assert(obj.Val18.Contains(TWeakObject <UObject> .Null), unrealClass, "Val18");

            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");
        }