Package intellijcoder.model

Examples of intellijcoder.model.Problem


        workspaceManager.createProblemWorkspace(problem);
    }

    @Test
    public void usesCodeBuilderToGetTestClassTemplate() throws Exception {
        final Problem problem = make(a(Problem));
        context.checking(new Expectations(){{
            allowing(testBuilder).build(problem); will(returnValue("test class template"));
            oneOf(ide).createModule(with(any(String.class)), with(any(String.class)), with(equal("test class template")));
            ignoring(solutionBuilder);
        }});
View Full Code Here


    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 = {
                "import org.junit.Test;",
View Full Code Here

    @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", "}",
                "public void test1()", "{", "input2", "output2", "}",
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

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

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesInexactAssertWhenReturnTypeIsDouble() throws Exception {
        Problem problem = make(a(Problem, with(returnType, "double"),
                with(testCases, new TestCase[]{ make(a(TestCase)) })));
        final String[] expectedTemplate = {
                "public void test0()", "{", "assertEquals(", ", 1e-9)" , "}"
        };
        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
View Full Code Here

        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
    }

    @Test
    public void usesInexactArrayAssertWhenReturnTypeIsArrayOfDoubles() throws Exception {
        Problem problem = make(a(Problem, with(returnType, "double[]"),
                with(testCases, new TestCase[]{ make(a(TestCase)) })));
        final String[] expectedTemplate = {
                "public void test0()", "{", "assertArrayEquals(", ", 1e-9)" , "}"
        };
        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
View Full Code Here

    }

    @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

    }

    @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}", ")" , "}"
        };
        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
View Full Code Here

    }

    @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", ")" , "}"
        };
        verifyGeneratedTestClassTemplate(problem, expectedTemplate);
View Full Code Here

    }

    @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

TOP

Related Classes of intellijcoder.model.Problem

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.