示例#1
0
        private void Test_Squeeze()
        {
            int errorCode = 0;

            try {
                ILDimension dim    = new ILDimension(0, 1, 1, 2);
                ILDimension result = dim.Squeeze();
                if (result.NonSingletonDimensions != 1)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result.NumberOfDimensions != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[0] != 0)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[1] != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                dim    = new ILDimension(1, 0, 2, 1);
                result = dim.Squeeze();
                if (result.NumberOfDimensions != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[0] != 0)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[1] != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                dim    = new ILDimension(2, 1, 2, 1, 2, 3, 3, 1);
                result = dim.Squeeze();
                if (result.NumberOfDimensions != 5)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[0] != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[1] != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[2] != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[3] != 3)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[4] != 3)
                {
                    throw new Exception("Squeeze failed");
                }
                dim    = new ILDimension(0);
                result = dim.Squeeze();
                if (result.NumberOfDimensions != 2)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[0] != 0)
                {
                    throw new Exception("Squeeze failed");
                }
                if (result[1] != 1)
                {
                    throw new Exception("Squeeze failed");
                }
                Success();
            } catch (Exception e) {
                Error(errorCode, e.Message);
            }
        }