2023-11-16 15:18:51 +00:00
|
|
|
from .naloga import *
|
|
|
|
|
2023-10-27 10:49:52 +00:00
|
|
|
import unittest
|
2023-11-16 15:18:51 +00:00
|
|
|
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def test_dolzina_ovir(self):
|
|
|
|
self.assertEqual(3, dolzina_ovir("...###..."))
|
|
|
|
self.assertEqual(1, dolzina_ovir("...#..."))
|
|
|
|
self.assertEqual(2, dolzina_ovir("...#..#."))
|
|
|
|
self.assertEqual(7, dolzina_ovir("#...#####..#."))
|
|
|
|
self.assertEqual(8, dolzina_ovir("...#####.##...#"))
|
|
|
|
self.assertEqual(9, dolzina_ovir("#...#####.##...#"))
|
|
|
|
self.assertEqual(6, dolzina_ovir("##...#.#...##"))
|
|
|
|
self.assertEqual(0, dolzina_ovir("..."))
|
|
|
|
self.assertEqual(0, dolzina_ovir("."))
|
|
|
|
|
|
|
|
def test_stevilo_ovir(self):
|
|
|
|
self.assertEqual(1, stevilo_ovir("...###..."))
|
|
|
|
self.assertEqual(1, stevilo_ovir("...#..."))
|
|
|
|
self.assertEqual(2, stevilo_ovir("...#..#."))
|
|
|
|
self.assertEqual(3, stevilo_ovir("#...#####..#."))
|
|
|
|
self.assertEqual(3, stevilo_ovir("...#####.##...#"))
|
|
|
|
self.assertEqual(4, stevilo_ovir("#...#####.##...#"))
|
|
|
|
self.assertEqual(4, stevilo_ovir("##...#.#...##"))
|
|
|
|
self.assertEqual(0, stevilo_ovir("..."))
|
|
|
|
self.assertEqual(0, stevilo_ovir("."))
|
|
|
|
|
|
|
|
def test_najsirsa_ovira(self):
|
|
|
|
self.assertEqual(3, najsirsa_ovira("...###..."))
|
|
|
|
self.assertEqual(1, najsirsa_ovira("...#..."))
|
|
|
|
self.assertEqual(1, najsirsa_ovira("...#..#."))
|
|
|
|
self.assertEqual(5, najsirsa_ovira("#...#####..#."))
|
|
|
|
self.assertEqual(5, najsirsa_ovira("...#####.##...#"))
|
|
|
|
self.assertEqual(5, najsirsa_ovira("#...#####.##...#"))
|
|
|
|
self.assertEqual(6, najsirsa_ovira("######...#####.##...#"))
|
|
|
|
self.assertEqual(6, najsirsa_ovira("...#####.##...######"))
|
|
|
|
|
|
|
|
def test_pretvori_vrstico(self):
|
|
|
|
self.assertEqual([(3, 5)], pretvori_vrstico("..###."))
|
|
|
|
self.assertEqual([(3, 5), (7, 7)], pretvori_vrstico("..###.#."))
|
|
|
|
self.assertEqual([(1, 2), (5, 7), (9, 9)], pretvori_vrstico("##..###.#."))
|
|
|
|
self.assertEqual([(1, 1), (4, 6), (8, 8)], pretvori_vrstico("#..###.#."))
|
|
|
|
self.assertEqual([(1, 1), (4, 6), (8, 8)], pretvori_vrstico("#..###.#"))
|
|
|
|
self.assertEqual([], pretvori_vrstico("..."))
|
|
|
|
self.assertEqual([], pretvori_vrstico(".."))
|
|
|
|
self.assertEqual([], pretvori_vrstico("."))
|
|
|
|
|
|
|
|
def test_pretvori_zemljevid(self):
|
|
|
|
zemljevid = [
|
|
|
|
"......",
|
|
|
|
"..##..",
|
|
|
|
".##.#.",
|
|
|
|
"...###",
|
|
|
|
"###.##",
|
|
|
|
]
|
2023-11-16 15:18:51 +00:00
|
|
|
self.assertEqual(
|
|
|
|
[(3, 4, 2), (2, 3, 3), (5, 5, 3), (4, 6, 4), (1, 3, 5), (5, 6, 5)],
|
|
|
|
pretvori_zemljevid(zemljevid),
|
|
|
|
)
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
zemljevid = [
|
|
|
|
"..............##...",
|
|
|
|
"..###.....###....##",
|
|
|
|
"...###...###...#...",
|
|
|
|
"...........#.....##",
|
|
|
|
"...................",
|
2023-11-16 15:18:51 +00:00
|
|
|
"###.....#####...###",
|
2023-10-27 10:49:52 +00:00
|
|
|
]
|
2023-11-16 15:18:51 +00:00
|
|
|
self.assertEqual(
|
|
|
|
[
|
|
|
|
(15, 16, 1),
|
|
|
|
(3, 5, 2),
|
|
|
|
(11, 13, 2),
|
|
|
|
(18, 19, 2),
|
|
|
|
(4, 6, 3),
|
|
|
|
(10, 12, 3),
|
|
|
|
(16, 16, 3),
|
|
|
|
(12, 12, 4),
|
|
|
|
(18, 19, 4),
|
|
|
|
(1, 3, 6),
|
|
|
|
(9, 13, 6),
|
|
|
|
(17, 19, 6),
|
|
|
|
],
|
|
|
|
pretvori_zemljevid(zemljevid),
|
|
|
|
)
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
def test_izboljsave(self):
|
|
|
|
prej = [
|
|
|
|
"..............##...",
|
|
|
|
"..###.....###....##",
|
|
|
|
"...###...###...#...",
|
|
|
|
"...........#.....##",
|
|
|
|
"...................",
|
2023-11-16 15:18:51 +00:00
|
|
|
"###.....#####...###",
|
2023-10-27 10:49:52 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
potem = [
|
|
|
|
"...##.........##...",
|
|
|
|
"..###.....###....##",
|
|
|
|
"#..###...###...#...",
|
|
|
|
"...###.....#.....##",
|
|
|
|
"................###",
|
2023-11-16 15:18:51 +00:00
|
|
|
"###.....#####...###",
|
2023-10-27 10:49:52 +00:00
|
|
|
]
|
|
|
|
|
2023-11-16 15:18:51 +00:00
|
|
|
self.assertEqual(
|
|
|
|
[(4, 5, 1), (1, 1, 3), (4, 6, 4), (17, 19, 5)], izboljsave(prej, potem)
|
|
|
|
)
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
self.assertEqual([], izboljsave(prej, prej))
|
|
|
|
|
|
|
|
def test_huligani(self):
|
|
|
|
prej = [
|
|
|
|
"..............##...",
|
|
|
|
"..###.....###....##",
|
|
|
|
"...###...###...#...",
|
|
|
|
"...........#.....##",
|
|
|
|
"...................",
|
2023-11-16 15:18:51 +00:00
|
|
|
"###.....#####...###",
|
2023-10-27 10:49:52 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
potem = [
|
|
|
|
"...##..............",
|
|
|
|
"..........###....##",
|
|
|
|
"#..###...###...#...",
|
|
|
|
"...###.....#.....##",
|
|
|
|
"................###",
|
2023-11-16 15:18:51 +00:00
|
|
|
"###.....##.##...###",
|
2023-10-27 10:49:52 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
dodane, odstranjene = huligani(prej, potem)
|
2023-11-16 15:18:51 +00:00
|
|
|
self.assertEqual(
|
|
|
|
[(4, 5, 1), (1, 1, 3), (4, 6, 4), (17, 19, 5), (9, 10, 6), (12, 13, 6)],
|
|
|
|
dodane,
|
|
|
|
"Napaka v seznamu dodanih",
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
[(15, 16, 1), (3, 5, 2), (9, 13, 6)],
|
|
|
|
odstranjene,
|
|
|
|
"Napaka v seznamu odstranjenih",
|
|
|
|
)
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
dodane, odstranjene = huligani(potem, prej) # Pazi, obrnjeno!
|
2023-11-16 15:18:51 +00:00
|
|
|
self.assertEqual(
|
|
|
|
[(15, 16, 1), (3, 5, 2), (9, 13, 6)], dodane, "Napaka v seznamu dodanih"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
[(4, 5, 1), (1, 1, 3), (4, 6, 4), (17, 19, 5), (9, 10, 6), (12, 13, 6)],
|
|
|
|
odstranjene,
|
|
|
|
"Napaka v seznamu odstranjenih",
|
|
|
|
)
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
self.assertEqual(([], []), huligani(prej, prej))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|