diff options
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index 211b324..c98a938 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -97,7 +97,7 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): def test_array_input(self): self.test_case_data = [{'expected_output': '561', - 'expected_input': '5,6,1'}] + 'expected_input': '5\n6\n1'}] user_answer = dedent(""" import java.util.Scanner; class Test @@ -186,5 +186,25 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): self.assertEquals(result.get('error'), "Correct Answer") self.assertTrue(result.get('success')) + def test_string_input(self): + self.test_case_data = [{'expected_output': 'HelloWorld', + 'expected_input': 'Hello\nWorld'}] + user_answer = dedent(""" + import java.util.Scanner; + class Test + {public static void main(String[] args){ + Scanner s = new Scanner(System.in); + String a = s.nextLine(); + String b = s.nextLine(); + System.out.print(a+b); + }}""") + get_class = JavaStdioEvaluator() + kwargs = {'user_answer': user_answer, + 'test_case_data': self.test_case_data + } + result = get_class.evaluate(**kwargs) + self.assertEquals(result.get('error'), "Correct Answer") + self.assertTrue(result.get('success')) + if __name__ == '__main__': unittest.main() |