add-day2 (#1)

Reviewed-on: #1
Co-authored-by: josh <josh@joshuaschuett.com>
Co-committed-by: josh <josh@joshuaschuett.com>
This commit is contained in:
2026-05-19 21:31:44 +00:00
committed by Josh
parent 9f43fb2262
commit d6bd55ad1b
7 changed files with 145 additions and 0 deletions

26
day2/test_day2.py Normal file
View File

@@ -0,0 +1,26 @@
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()