Codes sources prototype 1

This commit is contained in:
SylvanCourtiol
2021-05-09 17:42:30 +02:00
parent 14d39af284
commit a1161d0399
16 changed files with 1144 additions and 73 deletions
@@ -38,7 +38,7 @@ public class Chaine extends Litteral {
* @param uneValeur
*/
public Chaine(String uneValeur) {
uneValeur = uneValeur.trim();
if (!uneValeur.startsWith("\"") || !uneValeur.endsWith("\"")) {
throw new InterpreteurException(ERREUR_INVALIDE
+ uneValeur);
@@ -61,7 +61,7 @@ public class Chaine extends Litteral {
*/
public static Chaine concatener(Chaine a, Chaine b) {
return null;
return new Chaine("\"" + a.valeur + b.valeur + "\"");
}
/* non javadoc
@@ -7,6 +7,8 @@ package interpreteurlir.donnees.litteraux.tests;
import interpreteurlir.InterpreteurException;
import interpreteurlir.donnees.litteraux.Chaine;
import static info1.outils.glg.Assertions.*;
/**
* Tests unitaires de Chaine
* @author Nicolas Caminade
@@ -111,6 +113,32 @@ public class TestChaine {
System.out.println("==>test terminé\n");
}
/**
* Tests unitaires de concaténer
*/
public void testConcatener() {
final Chaine[] ATTENDU = {
new Chaine(),
new Chaine("\"Bonjour le monde ! \""),
new Chaine("\" \""),
new Chaine("\"3,1415\""),
};
final Chaine[][] A_CONCATENER = {
{new Chaine(), new Chaine("\"\"")},
{new Chaine("\"Bonjour \""), new Chaine("\"le monde ! \"")},
{new Chaine("\"\""), new Chaine("\" \"")},
{new Chaine("\"3,\""), new Chaine("\"1415\"")},
};
System.out.println("\tExécution du test de concaténer");
for (int numTest = 0 ; numTest < ATTENDU.length ; numTest++ ) {
assertTrue(ATTENDU[numTest].compareTo(Chaine.concatener(
A_CONCATENER[numTest][0], A_CONCATENER[numTest][1]))
== 0);
}
}
/**
* Lancement des tests
* @param args non utilisés