public void UnionSet_SetsWithVaryingNumberOfElementIndices_(Set left, Set right, Set expected)
        {
            IInterpreterSet parent           = Substitute.For <IInterpreterSet>();
            SetHelper       setHelper        = SetUpHelper(parent);
            SetExpression   leftExpr         = new SetExpression(null, null, null, 0, 0);
            SetExpression   rightExpr        = new SetExpression(null, null, null, 0, 0);
            UnionExpression intersectionExpr = new UnionExpression(leftExpr, rightExpr, 0, 0);

            parent.DispatchSet(leftExpr, Arg.Any <List <object> >()).Returns(left);
            parent.DispatchSet(rightExpr, Arg.Any <List <object> >()).Returns(right);

            Set result = setHelper.UnionSet(intersectionExpr, new List <object>());

            result.Should().BeEquivalentTo(expected);
        }
        public void SubtractionSet_f_f(int[,] left, int[,] right, int[,] expected)
        {
            IInterpreterSet       parent    = Substitute.For <IInterpreterSet>();
            SetHelper             setHelper = SetUpHelper(parent);
            SetExpression         lhsExpr   = new SetExpression(null, null, null, 1, 1);
            SetExpression         rhsExpr   = new SetExpression(null, null, null, 1, 1);
            SubtractionExpression expr      = new SubtractionExpression(lhsExpr, rhsExpr, 0, 0);

            parent.DispatchSet(lhsExpr, Arg.Any <List <object> >()).Returns(getSetFrom2dArray(left));
            parent.DispatchSet(rhsExpr, Arg.Any <List <object> >()).Returns(getSetFrom2dArray(right));

            Set res = setHelper.SubtractionSet(expr, new List <object>());

            res.Should().BeEquivalentTo(getSetFrom2dArray(expected));
        }
        public void IntersectionSet_ValidInput_ReturnsCorrectSet(Set left, Set right, Set exp)
        {
            IInterpreterSet        parent           = Substitute.For <IInterpreterSet>();
            SetHelper              setHelper        = SetUpHelper(parent);
            SetExpression          leftExpr         = new SetExpression(null, null, null, 0, 0);
            SetExpression          rightExpr        = new SetExpression(null, null, null, 0, 0);
            IntersectionExpression intersectionExpr = new IntersectionExpression(leftExpr, rightExpr, 0, 0);

            parent.DispatchSet(leftExpr, Arg.Any <List <object> >()).Returns(left);
            parent.DispatchSet(rightExpr, Arg.Any <List <object> >()).Returns(right);

            Set result = setHelper.IntersectionSet(intersectionExpr, new List <object>());

            result.Should().BeEquivalentTo(exp);
        }
Exemplo n.º 4
0
        public Set SubtractionSet(SubtractionExpression node, List <Object> parameters)
        {
            Set leftSet  = _interpreter.DispatchSet(node.Children[0], parameters);
            Set rightSet = _interpreter.DispatchSet(node.Children[1], parameters);

            HashSet <Element> set = leftSet.SetCopy;

            set.ExceptWith(rightSet.Elements);
            return(new Set(set));
        }