Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
48
Task/Test-a-function/Java/test-a-function-1.java
Normal file
48
Task/Test-a-function/Java/test-a-function-1.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import static ExampleClass.pali; // or from wherever it is defined
|
||||
import static ExampleClass.rPali; // or from wherever it is defined
|
||||
import org.junit.*;
|
||||
public class PalindromeTest extends junit.framework.TestCase {
|
||||
@Before
|
||||
public void setUp(){
|
||||
//runs before each test
|
||||
//set up instance variables, network connections, etc. needed for all tests
|
||||
}
|
||||
@After
|
||||
public void tearDown(){
|
||||
//runs after each test
|
||||
//clean up instance variables (close files, network connections, etc.).
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the pali(...) method.
|
||||
*/
|
||||
@Test
|
||||
public void testNonrecursivePali() throws Exception {
|
||||
assertTrue(pali("abcba"));
|
||||
assertTrue(pali("aa"));
|
||||
assertTrue(pali("a"));
|
||||
assertTrue(pali(""));
|
||||
assertFalse(pali("ab"));
|
||||
assertFalse(pali("abcdba"));
|
||||
}
|
||||
/**
|
||||
* Test the rPali(...) method.
|
||||
*/
|
||||
@Test
|
||||
public void testRecursivePali() throws Exception {
|
||||
assertTrue(rPali("abcba"));
|
||||
assertTrue(rPali("aa"));
|
||||
assertTrue(rPali("a"));
|
||||
assertTrue(rPali(""));
|
||||
assertFalse(rPali("ab"));
|
||||
assertFalse(rPali("abcdba"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect a WhateverExcpetion
|
||||
*/
|
||||
@Test(expected=WhateverException.class)
|
||||
public void except(){
|
||||
//some code that should throw a WhateverException
|
||||
}
|
||||
}
|
||||
5
Task/Test-a-function/Java/test-a-function-2.java
Normal file
5
Task/Test-a-function/Java/test-a-function-2.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public class RunTests{
|
||||
public static main(String[] args){
|
||||
org.junit.runner.JUnitCore.runClasses(PalindromeTest.class/*, other classes here if you have more*/);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue