Exemple #1
0
        public void ItemConditionInfo_getColIndex()
        {
            ItemConditionInfo conditionInfo = new ItemConditionInfo();

            conditionInfo.SetIndexInfo(0, 1, 1);

            Assert.AreEqual(1, conditionInfo.getColIndex());
        }
Exemple #2
0
        public void ItemConditionInfo_isExistArroundIsland()
        {
            ItemConditionInfo conditionInfo1 = new ItemConditionInfo();
            ItemConditionInfo conditionInfo2 = new ItemConditionInfo();

            conditionInfo1.SetAroundItemExist(false, true, false, false);
            conditionInfo2.SetAroundItemExist(false, false, false, false);

            Assert.AreEqual(true, conditionInfo1.isExistArroundIsland());
            Assert.AreEqual(false, conditionInfo2.isExistArroundIsland());
        }
Exemple #3
0
        public void ItemConditionInfo_deleteFrom()
        {
            ItemConditionInfo conditionInfo = new ItemConditionInfo();

            conditionInfo.SetIndexInfo(0, 1, 1);
            conditionInfo.SetAroundItemExist(true, true, true, true);

            string from = "L";

            conditionInfo.DeleteFrom(from);
            Assert.AreEqual(false, conditionInfo.isExistLeftIsland());
        }
Exemple #4
0
        public void ItemConditionInfo_deleteDirection()
        {
            ItemConditionInfo conditionInfo = new ItemConditionInfo();

            conditionInfo.SetIndexInfo(0, 1, 1);
            conditionInfo.SetAroundItemExist(true, true, true, true);

            Assert.AreEqual(true, conditionInfo.isExistLeftIsland());
            Assert.AreEqual(true, conditionInfo.isExistRightIsland());
            Assert.AreEqual(true, conditionInfo.isExistTopIsland());
            Assert.AreEqual(true, conditionInfo.isExistBottomIsland());

            conditionInfo.DeleteLeft();
            Assert.AreEqual(false, conditionInfo.isExistLeftIsland());
            conditionInfo.DeleteRight();
            Assert.AreEqual(false, conditionInfo.isExistRightIsland());
            conditionInfo.DeleteTop();
            Assert.AreEqual(false, conditionInfo.isExistTopIsland());
            conditionInfo.DeleteBottom();
            Assert.AreEqual(false, conditionInfo.isExistBottomIsland());
        }
Exemple #5
0
        public void create_itemConditionMap()
        {
            /*
             *  {0,1,0}
             *  {1,1,1}
             *  {0,1,0}
             *
             *  000  | 010B     | 020
             *  101R | 111LRTB  | 121L
             *  200  | 211T     | 220
             */

            int[][] input = new int[3][]
            {
                new int[] { 0, 1, 0 },
                new int[] { 1, 1, 1 },
                new int[] { 0, 1, 0 }
            };

            ItemConditionInfo[,] expected = new ItemConditionInfo[input.GetLength(0), input[0].GetLength(0)];

            for (int i = 0; i < input.GetLength(0); i++)
            {
                for (int j = 0; j < input[0].GetLength(0); j++)
                {
                    expected[i, j] = new ItemConditionInfo();
                }
            }

            expected[0, 0].SetIndexInfo(0, 0, 0);
            expected[0, 1].SetIndexInfo(0, 1, 1);
            expected[0, 2].SetIndexInfo(0, 2, 0);

            expected[1, 0].SetIndexInfo(1, 0, 1);
            expected[1, 1].SetIndexInfo(1, 1, 1);
            expected[1, 2].SetIndexInfo(1, 2, 1);

            expected[2, 0].SetIndexInfo(2, 0, 0);
            expected[2, 1].SetIndexInfo(2, 1, 1);
            expected[2, 2].SetIndexInfo(2, 2, 0);

            expected[0, 1].SetAroundItemExist(false, false, false, true);
            expected[1, 0].SetAroundItemExist(false, true, false, false);
            expected[1, 1].SetAroundItemExist(true, true, true, true);
            expected[1, 2].SetAroundItemExist(true, false, false, false);
            expected[2, 1].SetAroundItemExist(false, false, true, false);

            ItemConditionInfo[,] actual;

            maxArea.CreateConditionMap(input, out actual);

            Assert.AreEqual(expected.Length, actual.Length);

            Assert.AreEqual(expected.GetLength(0), actual.GetLength(0));
            Assert.AreEqual(expected.GetLength(1), actual.GetLength(1));

            Assert.AreEqual(expected[0, 0].info.Count, actual[0, 0].info.Count);
            Assert.AreEqual(expected[0, 1].info.Count, actual[0, 1].info.Count);
            Assert.AreEqual(expected[0, 2].info.Count, actual[0, 2].info.Count);
            Assert.AreEqual(expected[1, 0].info.Count, actual[1, 0].info.Count);
            Assert.AreEqual(expected[1, 1].info.Count, actual[1, 1].info.Count);
            Assert.AreEqual(expected[1, 2].info.Count, actual[1, 2].info.Count);
            Assert.AreEqual(expected[2, 0].info.Count, actual[2, 0].info.Count);
            Assert.AreEqual(expected[2, 1].info.Count, actual[2, 1].info.Count);
            Assert.AreEqual(expected[2, 2].info.Count, actual[2, 2].info.Count);
        }