Skip to content

Commit

Permalink
Merge pull request #63 from albexl/dev
Browse files Browse the repository at this point in the history
Update master branch with workflow changes
  • Loading branch information
albexl authored Jul 4, 2024
2 parents 65349d2 + 0467762 commit fae28a7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/check.yaml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Lint and Test
name: Check and Release

on: [push, pull_request]

jobs:
build:
check:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -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
28 changes: 22 additions & 6 deletions tests/test_modular_arithmetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit fae28a7

Please sign in to comment.