import static org.junit.Assert.assertEquals;

import org.junit.jupiter.api.Test;

public class FourTest
{
    @Test
    public void testPartAAgainstExamples()
    {
        GridPath gp = new GridPath();
        gp.grid = new int[][] {
            {12, 3, 4, 13, 5},
            {11, 21, 2, 14, 16},
            {7, 8, 9, 15, 0},
            {10 ,17, 20, 19, 1},
            {18, 22, 30, 25, 6}
        };
        
        assertEquals(new Location(0, 1), gp.getNextLoc(0, 0));
        assertEquals(new Location(2, 3), gp.getNextLoc(1, 3));
        assertEquals(new Location(3, 4), gp.getNextLoc(2, 4));
        assertEquals(new Location(4, 4), gp.getNextLoc(4, 3));
    }
    
    @Test
    public void testPartAAgainstAdditionalExamples()
    {
        GridPath gp = new GridPath();
        gp.grid = new int[][] {
            {12, 3, 4, 13, 5},
            {11, 21, 2, 14, 16},
            {7, 8, 9, 15, Integer.MAX_VALUE},
            {10 ,17, 20, 19, 1},
            {18, 22, Integer.MAX_VALUE, 25, 6}
        };
        
        assertEquals(new Location(2, 4), gp.getNextLoc(1, 4));
        assertEquals(new Location(4, 2), gp.getNextLoc(4, 1));
    }
    
    @Test
    public void testPartBAgainstExample()
    {
        GridPath gp = new GridPath();
        gp.grid = new int[][] {
            {12, 30, 40, 25, 5},
            {11, 3, 22, 15, 43},
            {7, 2, 9, 4, 0},
            {8, 33, 18, 6, 1}
        };
        
        assertEquals(19, gp.sumPath(1, 1));
    }
}
