rkgjsi
This commit is contained in:
parent
3416cfadda
commit
689253c1fb
|
@ -34,7 +34,7 @@ public class CharCollection {
|
|||
}
|
||||
|
||||
public int different() {
|
||||
Set<Character> set = (Set<Character>) this.list;
|
||||
Set<Character> set = new HashSet<>(list);
|
||||
return set.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue