From 50e9e5e219f6808b8b07d4283958638afd3ea743 Mon Sep 17 00:00:00 2001 From: CHARLAIX FLORIAN p1905458 Date: Tue, 14 Apr 2020 11:41:13 +0200 Subject: [PATCH] Add prototype of swapTwoLast, add unitary test swapTwoLastTest and add some JavaDoc --- README.md | 1 + src/cvdatpjunit/CVDATPJUnit.java | 13 +++++++++++++ test/cvdatpjunit/CVDATPJUnitTest.java | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/README.md b/README.md index fbf7517..1f11745 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/cvdatpjunit/CVDATPJUnit.java b/src/cvdatpjunit/CVDATPJUnit.java index adeb8e5..0b4b72f 100644 --- a/src/cvdatpjunit/CVDATPJUnit.java +++ b/src/cvdatpjunit/CVDATPJUnit.java @@ -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; + } } diff --git a/test/cvdatpjunit/CVDATPJUnitTest.java b/test/cvdatpjunit/CVDATPJUnitTest.java index 0d0c55f..b0cf3bb 100644 --- a/test/cvdatpjunit/CVDATPJUnitTest.java +++ b/test/cvdatpjunit/CVDATPJUnitTest.java @@ -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("")); + } }