package artificialintelligence.botbuilding.botcleanpartiallyobservable;

import org.junit.Assert;
import org.junit.Test;

import junit.framework.TestCase;

public class MapTest {
    public MapTest() {
    }

    @Test
    public void testClean() {
        Map map = new Map(1);
        map.notifyClean(0, 0);
        Assert.assertTrue(map.isClean(0, 0));
        Assert.assertFalse(map.isDirty(0, 0));
    }

    @Test
    public void testDirty() {
        Map map = new Map(1);
        map.notifyDirty(0, 0);
        Assert.assertTrue(map.isDirty(0, 0));
        Assert.assertFalse(map.isClean(0, 0));
    }

    @Test
    public void testSize() {
        Map map = new Map(5);
        Assert.assertEquals(5, map.size());
        map.isClean(2, 3);
        try {
            map.isClean(6, 6);
            TestCase.fail("Expected exception was not occured.");
        } catch(IndexOutOfBoundsException ignored) {
        }
        try {
            map.isDirty(1, 8);
            TestCase.fail("Expected exception was not occured.");
        } catch(IndexOutOfBoundsException ignored) {
        }
        try {
            map.notifyClean(9, 2);
            TestCase.fail("Expected exception was not occured.");
        } catch(IndexOutOfBoundsException ignored) {
        }
        try {
            map.notifyDirty(9, 8);
            TestCase.fail("Expected exception was not occured.");
        } catch(IndexOutOfBoundsException ignored) {
        }
    }
}
@@ -66,16 +66,49 @@
 vable;%0A%0A
+import junit.framework.TestCase;%0A
 import o
@@ -156,39 +156,24 @@
 import j
-unit.framework.TestCase
+ava.io.*
 ;%0A%0Apubli
@@ -880,32 +880,33 @@
 %0A        %7D catch
+ 
 (IndexOutOfBound
@@ -1055,32 +1055,33 @@
 %0A        %7D catch
+ 
 (IndexOutOfBound
@@ -1234,32 +1234,33 @@
 %0A        %7D catch
+ 
 (IndexOutOfBound
@@ -1421,16 +1421,17 @@
  %7D catch
+ 
 (IndexOu
@@ -1475,10 +1475,829 @@
  %7D%0A    %7D
+%0A%0A    @Test%0A    public void testSerializable() throws IOException, ClassNotFoundException %7B%0A        Map originalMap = new Map(1);%0A        originalMap.notifyClean(0, 0);%0A%0A        String pathname = %22test.ser%22;%0A        FileOutputStream fileOut = new FileOutputStream(pathname);%0A        ObjectOutputStream out = new ObjectOutputStream(fileOut);%0A        out.writeObject(originalMap);%0A        out.close();%0A        fileOut.close();%0A%0A        FileInputStream fileIn = new FileInputStream(pathname);%0A        ObjectInputStream in = new ObjectInputStream(fileIn);%0A        Map readMap = (Map) in.readObject();%0A        in.close();%0A        fileIn.close();%0A%0A        Assert.assertTrue(new File(pathname).delete());%0A%0A        Assert.assertEquals(originalMap.size(), readMap.size());%0A        Assert.assertTrue(readMap.isClean(0, 0));%0A    %7D
 %0A%7D

Add test to ensure that Map is correctly read and written.