Ejemplo n.º 1
0
        public void MatrixSortLenOperationExeptionInterface()
        {
            const int xSize = 10;

            int[][] matrix = new int[xSize][];
            Random  random = new Random();

            for (int i = 0; i < xSize; i++)
            {
                int ySize = random.Next(1, 11);
                if (i == 4)
                {
                    continue;
                }
                matrix[i] = new int[ySize];
                for (int j = 0; j < ySize; j++)
                {
                    matrix[i][j] = random.Next(-1000, 1000);
                }
            }

            ArrayLenComparer comparer = new ArrayLenComparer();

            MatrixSort.Sort(matrix, comparer);
        }
Ejemplo n.º 2
0
        public void MatrixSortLenInterface()
        {
            const int xSize = 10;

            int[][] matrix = new int[xSize][];
            Random  random = new Random();

            for (int i = 0; i < xSize; i++)
            {
                int ySize = random.Next(1, 11);
                matrix[i] = new int[ySize];
                for (int j = 0; j < ySize; j++)
                {
                    matrix[i][j] = random.Next(-1000, 1000);
                }
            }

            ArrayLenComparer comparer = new ArrayLenComparer();

            MatrixSort.Sort(matrix, comparer);

            for (int i = 1; i < matrix.Length; i++)
            {
                if (matrix[i].Length < matrix[i - 1].Length)
                {
                    Assert.Fail("Error arrary[" + i + "] length < " + "arrary[" + (i - 1) + "] length");
                }
            }
        }