TP-metaprogrammation-test/StringBufferTest.java

30 lines
579 B
Java
Raw Normal View History

2021-12-03 14:57:00 +00:00
import org.junit.*;
import static org.junit.Assert.*;
public class StringBufferTest {
private StringBuffer s1;
@Before public void initialiser() {
s1 = new StringBuffer("Le texte");
}
@Test public void testReverse() {
s1.reverse();
assertEquals("etxet eL", s1.toString());
}
@Test public void testDelete() {
s1.delete(2, 7);
assertEquals("Lee", s1.toString());
}
@Test(expected=IndexOutOfBoundsException.class)
public void erreurSurIndice() {
assertEquals('e', s1.charAt(-1));
}
@Test public void initiale() {
assertEquals('L', s1.charAt(1));
}
}