예제 #1
0
    def test_set_outrange(self):
        f = Field(5, 5)

        with self.assertRaises(CoordOutOfRange):
            f.set(-1, 2, 'ship')

        with self.assertRaises(CoordOutOfRange):
            f.set(2, 44, 'ship')
예제 #2
0
    def test_set(self):
        f = Field(5, 5)

        f.set(2, 2, 'ship')
        self.assertTrue(f.get(2, 2).is_ship)
        self.assertFalse(f.get(2, 2).is_shooted)

        f.set(2, 2, 'border', True)
        self.assertTrue(f.get(2, 2).is_border)
        self.assertTrue(f.get(2, 2).is_shooted)
예제 #3
0
 def test_set_unkonw_value(self):
     f = Field(5, 5)
     f.set(2, 2, 'ship')
     self.assertTrue(f.get(2, 2).is_ship)
     with self.assertRaises(UnknownCellValue):
         f.set(1, 1, 'unknown')