public void TestEntitySystemSystemBit()
        {
            bool int32Used        = typeof(SystemBitManager).GetMethod("GetBitFor").ReturnType == typeof(global::System.Int32);
            var  systemBitManager = new SystemBitManager();

            if (int32Used)
            {
                for (int i = 0; i < 32; i++)
                {
                    Assert.AreEqual(1 << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
                }
            }
            else
            {
                for (int i = 0; i < 32; i++)
                {
#if UNITY5
                    Assert.AreEqual(new BigInteger(1) << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
#else
                    Assert.AreEqual(BigInteger.One << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
#endif
                }
            }

            // If SystemBitManager is compiled with Int32 bit type,
            // next (33rd) EntitySystem instance will get invalid (overflown) SystemBit value.
            // Should get exception instead of silent overflow.

            bool thrown = false;

            try
            {
                systemBitManager.GetBitFor(new TestEntityProcessingSystem());
            }
            catch (InvalidOperationException)
            {
                thrown = true;
            }

            if (int32Used)
            {
                Assert.IsTrue(thrown, "Getting SystemBit for 33rd EntitySystem instance should fail when Int32 bit type is used");
            }
            else
            {
                Assert.IsFalse(thrown, "Getting SystemBit for 33rd EntitySystem instance should not fail when BigInteger bit type is used");
            }
        }
        public void TestEntitySystemSystemBit_Issue_93_More_than_64_Systems()
        {
            bool int32Used        = typeof(SystemBitManager).GetMethod("GetBitFor").ReturnType == typeof(global::System.Int32);
            var  systemBitManager = new SystemBitManager();

            if (int32Used)
            {
                Assert.Inconclusive("Test cannot be run because the Artemis build being tested is compiled with System.Int32 SystemBit type");
            }

            // If SystemBitManager is compiled with BigInteger SystemBit type,
            // virtually any number of EntitySystem instances will get valid SystemBit values.

            for (int i = 0; i < 100; i++)
            {
                Assert.AreEqual(new BigInteger(1) << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()), "i = {0}", i);
            }
        }
Esempio n. 3
0
        public void TestEntitySystemSystemBit()
        {
            bool int32Used = typeof(SystemBitManager).GetMethod("GetBitFor").ReturnType == typeof (global::System.Int32);
            var systemBitManager = new SystemBitManager();

            if (int32Used)
            {
                for (int i = 0; i < 32; i++)
                {
                    Assert.AreEqual(1 << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
                }
            }
            else
            {
                for (int i = 0; i < 32; i++)
                {
#if UNITY5
                    Assert.AreEqual(new BigInteger(1) << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
#else
                    Assert.AreEqual(BigInteger.One << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()));
#endif
                }
            }
            
            // If SystemBitManager is compiled with Int32 bit type,
            // next (33rd) EntitySystem instance will get invalid (overflown) SystemBit value.
            // Should get exception instead of silent overflow.

            bool thrown = false;

            try
            {
                systemBitManager.GetBitFor(new TestEntityProcessingSystem());
            }
            catch (InvalidOperationException)
            {
                thrown = true;
            }

            if (int32Used)
            {
                Assert.IsTrue(thrown, "Getting SystemBit for 33rd EntitySystem instance should fail when Int32 bit type is used");
            }
            else
            {
                Assert.IsFalse(thrown, "Getting SystemBit for 33rd EntitySystem instance should not fail when BigInteger bit type is used");
            }
        }
Esempio n. 4
0
        public void TestEntitySystemSystemBit_Issue_93_More_than_64_Systems()
        {
            bool int32Used = typeof(SystemBitManager).GetMethod("GetBitFor").ReturnType == typeof (global::System.Int32);
            var systemBitManager = new SystemBitManager();

            if (int32Used)
                Assert.Inconclusive("Test cannot be run because the Artemis build being tested is compiled with System.Int32 SystemBit type");

            // If SystemBitManager is compiled with BigInteger SystemBit type,
            // virtually any number of EntitySystem instances will get valid SystemBit values.

            for (int i = 0; i < 100; i++)
            {
                Assert.AreEqual(new BigInteger(1) << i, systemBitManager.GetBitFor(new TestEntityProcessingSystem()), "i = {0}", i);
            }
        }