mirror of
https://github.com/LucasVbr/interpreteur-lir.git
synced 2026-07-09 23:18:06 +00:00
Codes sources prototype 1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user