65 lines
1.6 KiB
Java
65 lines
1.6 KiB
Java
package de.joethei.hs.java2.tests;
|
|
|
|
import de.joethei.hs.java2.praktikum.praktikum2.CharCollection;
|
|
import org.junit.Test;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
public class CharCollectionTest {
|
|
|
|
@Test
|
|
public void constructors() {
|
|
assertEquals(new CharCollection("Hallo"), new CharCollection('H', 'a', 'l', 'l', 'o'));
|
|
}
|
|
|
|
@Test
|
|
public void size() {
|
|
assertEquals(5, new CharCollection("Hallo").size());
|
|
}
|
|
|
|
|
|
@Test
|
|
public void count() {
|
|
assertEquals(2, new CharCollection("Hallo").count('l'));
|
|
assertEquals(1, new CharCollection("Hallo").count('a'));
|
|
}
|
|
|
|
@Test
|
|
public void different() {
|
|
assertEquals(4, new CharCollection("Hallo").different());
|
|
}
|
|
|
|
|
|
@Test
|
|
public void top() {
|
|
assertEquals('l', new CharCollection("Hallo").top());
|
|
}
|
|
|
|
@Test
|
|
public void toStringTest() {
|
|
assertEquals("(H, a, l, l, o, W, e, l, t)", new CharCollection("HalloWelt").toString());
|
|
}
|
|
|
|
|
|
@Test
|
|
public void moreThan() {
|
|
assertEquals(new CharCollection("lll"), new CharCollection("Hallol").moreThan(2));
|
|
}
|
|
|
|
@Test
|
|
public void equals() {
|
|
assertEquals(new CharCollection("llo"), new CharCollection("lol"));
|
|
assertNotEquals(new CharCollection("Hallo"), "Hallo");
|
|
}
|
|
|
|
@Test
|
|
public void except() {
|
|
assertEquals(new CharCollection("Halo"), new CharCollection("Hallo").except(new CharCollection("l")));
|
|
}
|
|
|
|
@Test
|
|
public void isSubsect() {
|
|
assertTrue(new CharCollection("Hallo").isSubset(new CharCollection("Hao")));
|
|
}
|
|
|
|
} |