Package nodebox.util

Source Code of nodebox.util.Assertions

package nodebox.util;

import com.google.common.collect.ImmutableList;
import nodebox.function.*;
import nodebox.node.Node;
import nodebox.node.NodeContext;
import nodebox.node.NodeLibrary;
import nodebox.node.NodeRepository;

import static org.junit.Assert.assertEquals;

public final class Assertions {

    static private final FunctionRepository functionRepository =
            FunctionRepository.of(TestFunctions.LIBRARY, MathFunctions.LIBRARY, ColorFunctions.LIBRARY, ListFunctions.LIBRARY, StringFunctions.LIBRARY, SideEffects.LIBRARY, CoreVectorFunctions.LIBRARY);
    static private final NodeLibrary testLibrary = NodeLibrary.create("test", Node.ROOT, NodeRepository.of(), functionRepository);

    public static void assertResultsEqual(Iterable<?> result, Object... args) {
        assertEquals(ImmutableList.copyOf(args), ImmutableList.copyOf(result));
    }

    public static void assertResultsEqual(Node network, Node child, Object... args) {
        NodeContext context = new NodeContext(testLibrary);
        Iterable<?> values = context.renderChild(network, child);
        assertResultsEqual(values, args);
    }

    public static void assertNoResults(Node network, Node child) {
        assertResultsEqual(network, child);
    }

    public static void assertResultsEqual(Node node, Object... args) {
        NodeContext context = new NodeContext(testLibrary);
        Iterable<?> values = context.renderNode(node);
        assertResultsEqual(values, args);
    }


}
TOP

Related Classes of nodebox.util.Assertions

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.