Ejemplo n.º 1
0
        public void AddToCellTest()
        {
            Partition p = new Partition();

            p.AddToCell(0, 0);
            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(1, p.NumberOfElements());
            p.AddToCell(0, 1);
            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(2, p.NumberOfElements());
        }
Ejemplo n.º 2
0
        public void FromStringTest2()
        {
            Partition p = Partition.FromString("[0|1,2,3]");

            Assert.AreEqual(2, p.Count);
            Assert.AreEqual(4, p.NumberOfElements());
        }
Ejemplo n.º 3
0
        public void NumberOfElementsTest()
        {
            Partition p = new Partition();

            p.AddCell(0, 1);
            p.AddCell(2, 3);
            Assert.AreEqual(4, p.NumberOfElements());
        }
Ejemplo n.º 4
0
        public void CellDataConstructor()
        {
            int[][]   cellData = new int[][] { new[] { 0, 1 }, new[] { 2, 3, 4 }, new[] { 5, 6 } };
            Partition p        = new Partition(cellData);

            Assert.AreEqual(cellData.Length, p.Count);
            Assert.AreEqual(7, p.NumberOfElements());
        }
Ejemplo n.º 5
0
        public void AddCell_VarArgsTest()
        {
            Partition p = new Partition();

            p.AddCell(0, 1, 2);
            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(3, p.NumberOfElements());
        }
Ejemplo n.º 6
0
        public void AddSingletonCellTest()
        {
            Partition p = new Partition();

            p.AddSingletonCell(0);
            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(1, p.NumberOfElements());
        }
Ejemplo n.º 7
0
        public void AddCell_CollectionTest()
        {
            Partition  p    = new Partition();
            List <int> cell = new List <int>();

            cell.Add(0);
            cell.Add(1);
            cell.Add(2);
            p.AddCell(cell);
            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(3, p.NumberOfElements());
        }
Ejemplo n.º 8
0
        public void SplitAfterTest()
        {
            int[][]   cellData     = new int[][] { new[] { 0, 1 }, new[] { 2, 3, 4 }, new[] { 5, 6 } };
            Partition p            = new Partition(cellData);
            int       cellIndex    = 1;
            int       splitElement = 3;
            Partition q            = p.SplitAfter(cellIndex, splitElement);

            Assert.AreEqual(p.NumberOfElements(), q.NumberOfElements());
            Assert.AreEqual(p.Count + 1, q.Count);
            SortedSet <int> cell = q.GetCell(cellIndex + 1);

            Assert.IsTrue(cell.Count == 1);
            Assert.AreEqual(splitElement, (int)cell.First());
        }