This commit is contained in:
Johannes Theiner 2018-04-06 12:51:21 +02:00
parent 3416cfadda
commit 689253c1fb
2 changed files with 57 additions and 1 deletions

View File

@ -34,7 +34,7 @@ public class CharCollection {
} }
public int different() { public int different() {
Set<Character> set = (Set<Character>) this.list; Set<Character> set = new HashSet<>(list);
return set.size(); return set.size();
} }

View File

@ -0,0 +1,56 @@
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'));
}
@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("HalloWelt", new CharCollection("HalloWelt").toString());
}
@Test
public void moreThan() {
assertEquals(new CharCollection("ll"), new CharCollection("Hallo").moreThan(2));
}
@Test
public void except() {
assertEquals(new CharCollection("Hao"), new CharCollection("Hallo").except("l"));
}
@Test
public void isSubsect() {
assertTrue(new CharCollection("Hallo").isSubset("Hao"));
}
*/
}