-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
701 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Run Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
sanity_tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' # Adjust this version as necessary | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m venv .venv | ||
.venv/bin/pip install -r requirements.txt | ||
- name: Run sanity tests | ||
run: | | ||
# Run each test individually | ||
for test_name in test_is_true test_equals test_not_equals test_is_not_true test_greater_than test_greater_than_or_equal_to test_not_one test_less_than test_positive_check test_is_even test_is_odd test_is_not_negative test_is_zero test_absolute_value test_is_non_zero test_sum test_difference test_division test_factorial test_string_equality | ||
do | ||
echo "Running $test_name" | ||
.venv/bin/pytest resources/tests/return_tests.py::"$test_name" -s | ||
done | ||
remaining_tests: | ||
runs-on: ubuntu-latest | ||
needs: sanity_tests # This ensures that this job runs after the sanity tests | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' # Adjust this version as necessary | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m venv .venv | ||
.venv/bin/pip install -r requirements.txt | ||
- name: Run remaining tests | ||
run: | | ||
# Run the remaining test individually | ||
.venv/bin/pytest resources/tests/return_remaining_tests.py::test_remaining_return -s |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
python-3.13 | ||
pytest |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import random | ||
|
||
import pytest | ||
import itertools | ||
|
||
import src.main | ||
|
||
def test_remaining_return(): | ||
zero_params = [] | ||
for i in range(48): | ||
zero_params.append(0) | ||
zero_params = tuple(zero_params) | ||
|
||
|
||
# Define the range of values | ||
values = range(-127, 128) # from -127 to 127, inclusive | ||
|
||
sample_size = 1000000 # Adjust this to any reasonable number for sampling | ||
|
||
for _ in range(sample_size): | ||
# Generate a random combination of 8 parameters | ||
combination = tuple(random.randint(-127, 127) for _ in range(8)) | ||
|
||
result = src.main.robot(*combination, *zero_params) | ||
result = list(result) | ||
for i in range(len(result)): | ||
if i > 7: | ||
result.pop(8) | ||
result = tuple(result) | ||
|
||
|
||
# Check if the expected condition holds true for the specific spot | ||
# For example, let's check if the first value in the result is equal to 0 | ||
if combination[0] == 0: | ||
assert result[0] == 0 # Adjust this condition as needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import pytest | ||
|
||
def test_is_true(): | ||
assert True | ||
|
||
def test_equals(): | ||
for i in [-3, -2, -1, 0, 1, 2, 3]: | ||
assert equal(i) | ||
|
||
def test_not_equals(): | ||
for i in [-3, -2, -1, 0, 1, 2, 3]: | ||
assert not_equal(i, i+1) | ||
|
||
def not_equal(a, b): | ||
return a != b | ||
|
||
def equal(a): | ||
return a == a | ||
|
||
def test_is_not_true(): | ||
assert not False | ||
|
||
def test_greater_than(): | ||
tuples_list = [(x, y) for x in range(10) for y in range(10) if x > y] | ||
for i in range(len(tuples_list)): | ||
assert greater_than(tuples_list[i][0], tuples_list[i][1]) | ||
|
||
def greater_than(a, b): | ||
return a > b | ||
|
||
def test_greater_than_or_equal_to(): | ||
tuples_list = [(x, y) for x in range(10) for y in range(10) if x >= y] | ||
for i in range(len(tuples_list)): | ||
assert greater_than_or_equal_to(tuples_list[i][0], tuples_list[i][1]) | ||
|
||
def greater_than_or_equal_to(a, b): | ||
return a >= b | ||
|
||
def test_not_one(): | ||
assert not 1 == 0 | ||
|
||
def test_less_than(): | ||
tuples_list = [(x, y) for x in range(10) for y in range(10) if x < y] | ||
for i in range(len(tuples_list)): | ||
assert less_than(tuples_list[i][0], tuples_list[i][1]) | ||
|
||
def less_than(a, b): | ||
return a < b | ||
|
||
def test_positive_check(): | ||
for i in [1, 2, 3, 4, 5]: | ||
assert is_positive(i) | ||
|
||
def is_positive(a): | ||
return a > 0 | ||
|
||
def test_is_even(): | ||
for i in [0, 2, 4, 6, 8]: | ||
assert is_even(i) | ||
|
||
def is_even(a): | ||
return a % 2 == 0 | ||
|
||
def test_is_odd(): | ||
for i in [1, 3, 5, 7, 9]: | ||
assert is_odd(i) | ||
|
||
def is_odd(a): | ||
return a % 2 != 0 | ||
|
||
def test_is_not_negative(): | ||
for i in [0, 1, 2, 3, 4]: | ||
assert not_negative(i) | ||
|
||
def not_negative(a): | ||
return a >= 0 | ||
|
||
def test_is_zero(): | ||
assert is_zero(0) | ||
|
||
def is_zero(a): | ||
return a == 0 | ||
|
||
def test_absolute_value(): | ||
for i in [-1, -2, -3]: | ||
assert abs(i) == -i | ||
|
||
def test_is_non_zero(): | ||
for i in [1, -1, 2, -2, 3]: | ||
assert is_non_zero(i) | ||
|
||
def is_non_zero(a): | ||
return a != 0 | ||
|
||
def test_sum(): | ||
assert sum_two(2, 3) == 5 | ||
|
||
def sum_two(a, b): | ||
return a + b | ||
|
||
def test_difference(): | ||
assert difference(5, 3) == 2 | ||
|
||
def difference(a, b): | ||
return a - b | ||
|
||
def test_division(): | ||
assert divide(6, 3) == 2 | ||
assert divide(5, 2) == 2.5 | ||
|
||
def divide(a, b): | ||
return a / b if b != 0 else None | ||
|
||
def test_factorial(): | ||
assert factorial(0) == 1 | ||
assert factorial(1) == 1 | ||
assert factorial(2) == 2 | ||
assert factorial(3) == 6 | ||
assert factorial(4) == 24 | ||
assert factorial(5) == 120 | ||
|
||
def factorial(n): | ||
if n == 0: | ||
return 1 | ||
result = 1 | ||
for i in range(1, n + 1): | ||
result *= i | ||
return result | ||
|
||
def test_string_equality(): | ||
assert string_equal("hello", "hello") | ||
assert not string_equal("hello", "world") | ||
|
||
def string_equal(a, b): | ||
return a == b |
File renamed without changes.
Oops, something went wrong.