Package intellijcoder.model

Examples of intellijcoder.model.TestCase


    }

    private Matcher<Problem> hasTestCase(final String[] testInput, final String testOutput) {
        return new BaseMatcher<Problem>() {
            public boolean matches(Object o) {
                TestCase testCase = ((Problem) o).getTestCases()[0];
                return Arrays.equals(testCase.getInput(), testInput)
                        && testCase.getOutput().equals(testOutput);
            }

            public void describeTo(Description description) {
                description.appendText("testInput=" + Arrays.toString(testInput) + ", testOutput=" + testOutput);
            }
View Full Code Here


public class TestCodeBuilderTest {
    private TestCodeBuilder testCodeBuilder = new TestCodeBuilder();

    @Test
    public void basicTestClassTemplateStructure() throws Exception {
        TestCase testCase = make(a(TestCase, with(input, new String[]{"\"00:30:00\""}), with(output, "99")));
        final Problem problem = make(a(Problem, with(className, "ExerciseMachine"),
                with(returnType, "int"), with(methodName, "getPercentages"),
                with(paramTypes, new String[]{"String"}), with(paramNames, new String[] {"time"}),
                with(testCases, new TestCase[]{testCase})));
        final String[] expectedTemplate = {
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void twoTestCases() throws Exception {
        TestCase testCase1 = make(a(TestCase, with(input, new String[] {"input1"}), with(output, "output1")));
        TestCase testCase2 = make(a(TestCase, with(input, new String[] {"input2"}), with(output, "output2")));
        Problem problem = make(a(Problem,
                with(paramTypes, new String[] {someType()}), with(paramNames, new String[]{someName()}),
                with(testCases, new TestCase[]{testCase1, testCase2})));
        final String[] expectedTemplate = {
                "public void test0()", "{", "input1", "output1", "}",
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesArrayCreationSyntaxWhenParamTypeIsArray() throws Exception {
        TestCase testCase = make(a(TestCase, with(input, new String[] {"{1, 2}"})));
        Problem problem = make(a(Problem,
                with(paramTypes, new String[] {"int[]"}), with(paramNames, new String[]{"intervals"}),
                with(testCases, new TestCase[]{ testCase })));
        final String[] expectedTemplate = {
                "public void test0()", "{", "intervals", "=", "new int[]", "{1, 2}" , "}"
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesArrayCreationSyntaxOnOutputWhenReturnTypeIsArray() throws Exception {
        TestCase testCase = make(a(TestCase, with(output, "{1, 2}")));
        Problem problem = make(a(Problem, with(returnType, "int[]"),
                with(testCases, new TestCase[]{ testCase })));
        final String[] expectedTemplate = {
                "public void test0()", "{", "assertArrayEquals(new int[]", "{1, 2}", ")" , "}"
        };
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesLongLiteralForOutputValueOfLongType() throws Exception {
        TestCase testCase = make(a(TestCase, with(output, "9876543210")));
        Problem problem = make(a(Problem, with(returnType, "long"),
                with(testCases, new TestCase[]{ testCase })));
        final String[] expectedTemplate = {
                "public void test0()", "{", "assertEquals(", "9876543210L", ")" , "}"
        };
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesLongLiteralForParamValueOfLongType() throws Exception {
        TestCase testCase = make(a(TestCase, with(input, new String[] {"9876543210"})));
        Problem problem = make(a(Problem,
                with(paramTypes, new String[] {"long"}), with(paramNames, new String[]{"interval"}),
                with(testCases, new TestCase[]{ testCase })));
        final String[] expectedTemplate = {
                "public void test0()", "{""interval", "=", "9876543210L" , "}"
View Full Code Here

            allowing(inputComponentModel).getMethodName();   will(returnValue("multiply"));
            allowing(inputComponentModel).getParamTypes();   will(returnValue(new DataType[0]));
            allowing(inputComponentModel).getParamNames();   will(returnValue(new String[0]));
            allowing(inputComponentModel).getTestCases();    will(returnValue(new com.topcoder.shared.problem.TestCase[] {new com.topcoder.shared.problem.TestCase(1, new String[0], "1", false)}));
        }});
        TestCase testCase = make(a(TestCase, with(input, new String[0]), with(output, "1")));
        Problem expectedProblem = make(a(Problem,
                with(className, "BinaryCode"),
                with(returnType, "int"),
                with(methodName, "multiply"),
                with(testCases, new TestCase[]{testCase})));
View Full Code Here

    }

    private TestCase[] extractTestCases(com.topcoder.shared.problem.TestCase[] testCases) {
        TestCase[] result = new TestCase[testCases.length];
        for (int i = 0; i < testCases.length; i++) {
            result[i] = new TestCase(testCases[i].getInput(), testCases[i].getOutput());
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of intellijcoder.model.TestCase

Copyright © 2018 www.massapicom. 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.