27 lines
739 B
Python
27 lines
739 B
Python
import os
|
|
import unittest
|
|
|
|
from day2_sample import count_safe_in_file
|
|
|
|
|
|
class TestDay2(unittest.TestCase):
|
|
def _case_path(self, filename):
|
|
here = os.path.dirname(__file__)
|
|
return os.path.join(here, "test_cases", filename)
|
|
|
|
def test_sample(self):
|
|
self.assertEqual(count_safe_in_file(self._case_path("sample.txt")), 2)
|
|
|
|
def test_all_safe(self):
|
|
self.assertEqual(count_safe_in_file(self._case_path("all_safe.txt")), 4)
|
|
|
|
def test_all_unsafe(self):
|
|
self.assertEqual(count_safe_in_file(self._case_path("all_unsafe.txt")), 0)
|
|
|
|
def test_edge_cases(self):
|
|
self.assertEqual(count_safe_in_file(self._case_path("edge_cases.txt")), 3)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|