summaryrefslogtreecommitdiff
path: root/src/Q9/RobotTest.java
blob: 921a2de1a355e24b6c6d412f93f4f23beb4a658b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ca.mokhan.test;

import Q9.*;
import java.io.*;
import java.text.*;
import java.util.*;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class RobotTest extends TestCase {
  private Robot subject;

  public RobotTest(String testName) {
    super(testName);
    this.subject = new Robot(0, 0);
  }

  public static Test suite() {
    return new TestSuite(RobotTest.class);
  }

  public void test_printGrid() {
    Robot r1 = new Robot(0, 0);
    Robot r2 = new Robot(9, 9);

    String expected =
        "|1| | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | |2|\n";
    String result = Robot.printGrid(r1, r2);

    System.out.println(expected);
    System.out.println(result);

    assertEquals(expected, result);
  }

  public void test_printGrid_withCollision() {
    Robot r1 = new Robot(5, 5);
    Robot r2 = new Robot(5, 5);

    String expected =
        "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | |X| | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n"
            + "| | | | | | | | | | |\n";
    String result = Robot.printGrid(r1, r2);

    System.out.println(expected);
    System.out.println(result);

    assertEquals(expected, result);
  }
}