Add prototype of swapTwoLast, add unitary test swapTwoLastTest and add some JavaDoc
This commit is contained in:
parent
092d080cdf
commit
50e9e5e219
3 changed files with 25 additions and 0 deletions
|
@ -3,3 +3,4 @@
|
|||
|
||||
## Exercice 1
|
||||
* Création de la classe principale `CVDATPJUnit` et de sa classe de test `CVDATPJUnitTest` tous deux vides
|
||||
* Prototype de la méthode `swapTwoLast`, elle est statique car elle n’as pas besoin d’attributs de la classe. Ajout des test unitaires `swapTwoLastTest` et de la documentation dans la classe principale.
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package cvdatpjunit;
|
||||
|
||||
/**
|
||||
* This class contain various functions tested by JUnit
|
||||
* @author Florian Charlaix
|
||||
*/
|
||||
public class CVDATPJUnit {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function swap the two last characters
|
||||
* @param in The string to swap
|
||||
* @return The swapped string
|
||||
*/
|
||||
public static String swapTwoLast(String in) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
package cvdatpjunit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
class CVDATPJUnitTest {
|
||||
|
||||
@Test
|
||||
void swapTwoLastTest() {
|
||||
Assertions.assertEquals("BA", CVDATPJUnit.swapTwoLast("AB"));
|
||||
Assertions.assertEquals("RANI", CVDATPJUnit.swapTwoLast("RAIN"));
|
||||
Assertions.assertEquals("TENRANI", CVDATPJUnit.swapTwoLast("TENRAIN"));
|
||||
Assertions.assertEquals("A", CVDATPJUnit.swapTwoLast("A"));
|
||||
Assertions.assertEquals("", CVDATPJUnit.swapTwoLast(""));
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue