コード例 #1
0
        public void TestResultSet()
        {
            List<MyPoint> set1 = new List<MyPoint>();
            set1.Add(new MyPoint(0, 0));
            set1.Add(new MyPoint(1, 1));
            set1.Add(new MyPoint(2, 2));
            set1.Add(new MyPoint(5, 0));
            set1.Add(new MyPoint(6, 1));
            set1.Add(new MyPoint(7, 2));

            ItemSet iSet1 = new ItemSet();
            ItemSet iSet2 = new ItemSet();

            iSet1.Add(0);
            iSet1.Add(2);
            iSet1.Add(4);

            iSet2.Add(1);
            iSet2.Add(3);
            iSet2.Add(5);

            Results2 r2 = new Results2();
            r2.AddResult(iSet1.GetIndices());

            Results2 r3 = r2.Clone();
            r3.AddResult(iSet2.GetIndices());

            Assert.AreEqual(2, r3.Count);
            Assert.AreEqual(1, r2.Count);

            ItemSet iSet3 = iSet1.Clone();
            iSet3.Add(1);
            iSet3.Add(3);
            iSet3.Add(5);

            Assert.AreEqual(3, iSet1.Count);
            Assert.AreEqual(6, iSet3.Count);
        }
コード例 #2
0
        public void TestPointSet()
        {
            ItemSet pSet = new ItemSet();
            uint expected = 0;
            for (int i = 0; i < 16; i++)
            {
                expected += (uint)Math.Pow(2.0, i);
                pSet.Add(i);
                Assert.True(expected == pSet.GetIndices());
            }

            pSet.RemoveAt(3);
            expected -= 8;
            Assert.AreEqual(15, pSet.CountBits(), "Array size 1");
            Assert.True(expected == pSet.GetIndices());

            MyList<MyPoint> set1 = new MyList<MyPoint>();
            set1.Add(new MyPoint(0, 0));
            set1.Add(new MyPoint(1, 1));
            set1.Add(new MyPoint(2, 2));
            set1.Add(new MyPoint(5, 0));
            set1.Add(new MyPoint(6, 1));
            set1.Add(new MyPoint(7, 2));
            set1.Add(new MyPoint(8, 5));

            pSet.Reset();

            pSet.Add(0);
            pSet.Add(3);
            pSet.Add(4);
            pSet.Add(6);

            Assert.AreEqual(4, pSet.CountBits(), "Array size 2");

            pSet.GetItem(set1, 0);
            pSet.GetItem(set1, 1);
            pSet.GetItem(set1, 2);
            pSet.GetItem(set1, 3);

            Assert.True(set1[0] == pSet.GetItem(set1, 0), "Check 0");
            Assert.True(set1[3] == pSet.GetItem(set1, 1), "Check 1");
            Assert.True(set1[4] == pSet.GetItem(set1, 2), "Check 2");
            Assert.True(set1[6] == pSet.GetItem(set1, 3), "Check 3");
        }