# -*- coding: utf-8 -*-
# $Id: testJUnit.py 1635 2013-06-16 19:43:19Z amelung $
#
# Copyright (c) 2007-2011 Otto-von-Guericke-Universität Magdeburg
#
# This file is part of ECSpooler.
import unittest
import re
"""
"""
# -- individual tests -----------------------------------------------------
unitTests = \
"""
@Test public void encodeTestSingleChar()
{
${CLASS} submission = new ${CLASS}();
assertEquals('b', submission.encode('a',1));
}
@Test public void encodeEncode()
{
${CLASS} submission = new ${CLASS}();
assertEquals('a', submission.encode(submission.encode('a',5),-5));
}
@Test public void codeTestSingleString()
{
${CLASS} submission = new ${CLASS}();
String str = "abc";
assertEquals("bcd", submission.code(str,1));
}
@Test public void codeCode()
{
${CLASS} submission = new ${CLASS}();
String str = "Test";
assertEquals(str, submission.code(submission.code(str,4),-4));
}
"""
submission = \
"""
public class Caesar
{
public char encode(char buchstabe, int n)
{
buchstabe += n;
return buchstabe;
}
public String code(String text, int n)
{
String txt = new String("");
for(int i = 0;i < text.length(); i ++)
{
txt += encode(text.charAt(i),n);
}
return txt;
}
}
"""
'submission': submission,
'tests': ['default'],
'unitTests': unitTests,
}
"""_manage_checkSyntax should return False for a syntactical incorrect program"""
"""
public class Caesar
{
public char encode(char buchstabe, int n)
{
buchstabe += n;
return buchstabe;
}
public String code(String text, int n)
{
// Error: ';' expected
String txt = new String("")
for(int i = 0;i < text.length(); i ++)
{
txt += encode(text.charAt(i),n);
}
return txt;
}
}
"""
if result:
else:
"""_manage_checkSyntax should return True for a correct program"""
if result:
else:
"""_manage_checkSemantic should return False for an incorrect program"""
"""
public class Caesar
{
// Error: character moved one to offen!
public char encode(char buchstabe, int n)
{
buchstabe += n+1;
return buchstabe;
}
public String code(String text, int n)
{
String txt = new String("");
for(int i = 0;i < text.length(); i ++)
{
txt += encode(text.charAt(i),n);
}
return txt;
}
}
"""
# 1. we check syntax first to have a compiled class files
if not result:
# 2. lets do the semantic check
if result:
else:
"""_manage_checkSemantic should return True for a correct program"""
# 1. we check syntax first to have a compiled class files
if not result:
# 2. lets do the semantic check
#print job.getId()
if result:
else:
"""
"""
""""handleStudentsImports should return"""
submission = \
"""
package %s;
import org.educomponents.test.TestClassWithPackage;
public class TestHandleStudentsImports
{
public TestHandleStudentsImports()
{
final TestClassWithoutPackage testClassWithoutPackage;
final TestClassWithPackage testClassWithPackage;
}
}
"Import declaration for %s is missing." %
def test_suite():
"""
"""
return suite
# -- main ---------------------------------------------------------------------
if __name__ == '__main__':