src/Kingdom.OrTools.ConstraintSolver.Samples.Tests/BasicTests.cs
/// <summary>
/// Verifies that the Flatten functionality works as expected.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
Verifies that the Flatten functionality works as expected.
Verifies that the Flatten functionality works as expected .
[Theory
         , InlineData(0, 10)
         , InlineData(10, 0)
         , InlineData(10, 10)]
        public void VerifyThatFlattenWorksCorrectly(int x, int y)
        {
            Assert.True(x >= MinimumValue);
            Assert.True(y >= MinimumValue);
            Assert.True(x + y > 0);
            var xMax = Math.Max(x, 1);
            var yMax = Math.Max(y, 1);
            var arr = new IntVar[xMax, yMax];
            Assert.Equal(xMax, arr.GetLength(0));
            Assert.Equal(yMax, arr.GetLength(1));
            var flattened = arr.Flatten();
            Assert.Equal(xMax * yMax, flattened.Length);
        }
[ Theory , InlineData ( 0 , 10 ) , InlineData ( 10 , 0 ) , InlineData ( 10 , 10 ) ] public void VerifyThatFlattenWorksCorrectly ( int x , int y ) { Assert . True ( x >= MinimumValue ) ; Assert . True ( y >= MinimumValue ) ; Assert . True ( x + y > 0 ) ; var xMax = Math . Max ( x , 1 ) ; var yMax = Math . Max ( y , 1 ) ; var arr = new IntVar [ xMax , yMax ] ; Assert . Equal ( xMax , arr . GetLength ( 0 ) ) ; Assert . Equal ( yMax , arr . GetLength ( 1 ) ) ; var flattened = arr . Flatten ( ) ; Assert . Equal ( xMax * yMax , flattened . Length ) ; }
Verifies that the Flatten functionality works as expected.
Verifies that the Flatten functionality works as expected .
// Assumes that at least one dimension actually has dimension.
x
int
None
y
int
None