diff --git a/.github/workflows/check.yaml b/.github/workflows/main.yaml similarity index 67% rename from .github/workflows/check.yaml rename to .github/workflows/main.yaml index 5e9ea05..a8a514e 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/main.yaml @@ -1,9 +1,9 @@ -name: Lint and Test +name: Check and Release on: [push, pull_request] jobs: - build: + check: runs-on: ubuntu-latest steps: @@ -38,3 +38,20 @@ jobs: name: pytest-results path: junit/test-results.xml if: ${{ always() }} + + create_release: + needs: check + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + steps: + - uses: actions/checkout@v4 + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.run_number }} + release_name: Release ${{ github.run_number }} + draft: false + prerelease: false diff --git a/tests/test_modular_arithmetics.py b/tests/test_modular_arithmetics.py index 7eb7cc5..8c68a73 100644 --- a/tests/test_modular_arithmetics.py +++ b/tests/test_modular_arithmetics.py @@ -5,17 +5,33 @@ from algorithms.number_theory.modular_arithmetics import Modular -class TestNaive(TestCase): - """Class to test the modular arithmetics implementation.""" +class TestModularAdd(TestCase): + """Class to test the 'add' method of modular arithmetic implementation.""" def setUp(self): self.modular = Modular(10) def test_add(self): - """Test the `add` method.""" - self.assertEqual(self.modular.add(3, 4), 7) - self.assertEqual(self.modular.add(5, 5), 0) - self.assertEqual(self.modular.add(8, 5), 3) + """Test the `add` method with various inputs.""" + test_cases = [ + (3, 4, 7), # Simple addition + (5, 5, 0), # Addition resulting in modulus + (8, 5, 3), # Addition wrapping around modulus + (0, 0, 0), # Edge case: adding zeros + (-1, 2, 1), # Negative numbers + (10, 10, 0), # Inputs equal to modulus + ] + + for a, b, expected in test_cases: + with self.subTest(a=a, b=b, expected=expected): + self.assertEqual(self.modular.add(a, b), expected) + + +class TestNaive(TestCase): + """Class to test the modular arithmetics implementation.""" + + def setUp(self): + self.modular = Modular(10) def test_sub(self): """Test the `sub` method."""