Пример #1
0
        public void Construct_4()
        {
            var solution = new _0427_ConstructQuadTree();
            var result   = solution.Construct(new int[][] {
                new int[] { 0 },
            });

            Assert.IsFalse(result.val);
            Assert.IsTrue(result.isLeaf);
            Assert.IsNull(result.topLeft);
            Assert.IsNull(result.topRight);
            Assert.IsNull(result.bottomLeft);
            Assert.IsNull(result.bottomRight);
        }
Пример #2
0
        public void Construct_5()
        {
            var solution = new _0427_ConstructQuadTree();
            var result   = solution.Construct(new int[][] {
                new int[] { 1, 1, 0, 0 },
                new int[] { 1, 1, 0, 0 },
                new int[] { 0, 0, 1, 1 },
                new int[] { 0, 0, 1, 1 },
            });

            Assert.IsFalse(result.val);
            Assert.IsFalse(result.isLeaf);

            var topLeft = result.topLeft;

            Assert.IsTrue(topLeft.val);
            Assert.IsTrue(topLeft.isLeaf);
            Assert.IsNull(topLeft.topLeft);
            Assert.IsNull(topLeft.topRight);
            Assert.IsNull(topLeft.bottomLeft);
            Assert.IsNull(topLeft.bottomRight);

            var topRight = result.topRight;

            Assert.IsFalse(topRight.val);
            Assert.IsTrue(topRight.isLeaf);
            Assert.IsNull(topRight.topLeft);
            Assert.IsNull(topRight.topRight);
            Assert.IsNull(topRight.bottomLeft);
            Assert.IsNull(topRight.bottomRight);

            var bottomLeft = result.bottomLeft;

            Assert.IsFalse(bottomLeft.val);
            Assert.IsTrue(bottomLeft.isLeaf);
            Assert.IsNull(bottomLeft.topLeft);
            Assert.IsNull(bottomLeft.topRight);
            Assert.IsNull(bottomLeft.bottomLeft);
            Assert.IsNull(bottomLeft.bottomRight);

            var bottomRight = result.bottomRight;

            Assert.IsTrue(bottomRight.val);
            Assert.IsTrue(bottomRight.isLeaf);
            Assert.IsNull(bottomRight.topLeft);
            Assert.IsNull(bottomRight.topRight);
            Assert.IsNull(bottomRight.bottomLeft);
            Assert.IsNull(bottomRight.bottomRight);
        }