Exemplo n.º 1
0
        public void Test(int rootNumber, string exprString)
        {
            Entity expr = exprString;
            var    vars = expr.Vars.ToArray();
            var    res  = MathS.SolveBooleanTable(expr, vars);

            if (res is null && rootNumber == 0)
            {
                return; // success
            }
            // null case should explicitly quit the scope
            if (res is null)
            {
                Assert.True(false, $"0 roots instead of {rootNumber}");
                return;
            }

            Assert.Equal(rootNumber, res.RowCount);

            var dict  = new Dictionary <Variable, Entity>();
            var count = vars.Length;

            for (int i = 0; i < res.RowCount; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    dict[vars[j]] = res[i, j];
                }
                Assert.True(expr.Substitute(dict).EvalBoolean());
            }
        }
Exemplo n.º 2
0
 [Fact] public void InvalidNumberOfArguments1() =>
 Assert.Throws <WrongNumberOfArgumentsException>(() =>
                                                 MathS.SolveBooleanTable("a + b", "a"));