package homework1;
import org.junit.*;
import static org.junit.Assert.*;
public class TestHW {
@Test
public void test01() {
Point p1 = new Point(2, 5);
Point p2 = new Point(5, 2);
assertEquals("(2,5) is to be equal to (2,5).", p1, new Point(2, 5));
assertFalse("(2,5) is not to be equal to (5,2).", p1.equals(p2));
assertFalse("(5,2) is not to be equal to (2,5).", p2.equals(p1));
Canvas c = new HashCanvas("CC");
c.put(new Point(2, 5), 1);
c.put(new Point(5, 2), 2);
c.put(new Point(8, 2), 5);
c.put(new Point(1, 3), 9);
c.put(new Point(1, 4), 2);
c.put(new Point(2, 8), 5);
c.put(new Point(3, 5), 3);
c.put(new Point(2, 2), 2);
assertEquals("Name of canvas is to be CC.", "CC", c.getName());
assertTrue("Canvas should contain (2, 8).", c.contains(new Point(2, 8)));
assertFalse("Canvas should not contain (2, 7).", c.contains(new Point(2, 7)));
assertEquals("Colour of (3,5) is to be 3.", 3, c.get(new Point(3,5)));
}
@Test
public void test02() {
MyCanvas c = new MyHashCanvas("BB", 10);
c.put(new Point(2, 5), 1);
c.put(new Point(5, 2), 2);
c.put(new Point(8, 2), 5);
c.put(new Point(1, 3), 9);
c.put(new Point(1, 4), 2);
c.put(new Point(2, 8), 5);
c.put(new Point(3, 5), 3);
c.put(new Point(2, 2), 2);
assertEquals("Name of canvas is to be BB.", "BB", c.getName());
assertEquals("Number of colour 2 is to be 3.", 3, c.numOfColour(2));
c.remove(new Point(1, 4));
assertEquals("Number of colour 2 is to be 2.", 2, c.numOfColour(2));
}
}