| 1 |
- import org.junit.Assert;
import org.junit.Test;
public class MyMapTest<K,V> {
MySet<V> set = new MySet<>();
MyMap<K,V> map = new MyMap<>();
@Test
public void testSize() {
map.put(1,"Chai");
int expected = 1;
int actual = map.getSize();
Assert.assertEquals(expected,actual);
}
@Test
public void testPut() {
map.put(2,"Chai");
int expected = 1;
int actual = map.getSize();
Assert.assertEquals(expected,actual);
}
@Test
public void testContainsKey() {
map.put(2,"Chai");
boolean expected = true;
boolean actual = map.containsKey(2);
Assert.assertEquals(expected,actual);
}
@Test
public void testContainsValues() {
map.put(2,"Chai");
boolean expected = false;
boolean actual = map.containsValues("Chai");
Assert.assertEquals(expected,actual);
}
@Test
public void testGet() {
map.put(2,"Chai");
String expected = "Chai";
String actual = (String) map.get(2);
Assert.assertEquals(expected,actual);
}
@Test
public void testClear() {
map.clear();
int expected = 0;
int actual = map.getSize();
Assert.assertEquals(expected,actual);
}
@Test
public void testIsEmpty() {
map.clear();
boolean expected = true;
boolean actual = map.isEmpty();
Assert.assertEquals(expected,actual);
}
@Test
public void testRemove() {
map.put(1,"x");
String expected = "x";
String actual = (String) map.remove(1);
Assert.assertEquals(expected,actual);
}
}
|