Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted tests into doctests #10572

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions boolean_algebra/and_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,7 @@ def and_gate(input_1: int, input_2: int) -> int:
return int((input_1, input_2).count(0) == 0)


def test_and_gate() -> None:
"""
Tests the and_gate function
"""
assert and_gate(0, 0) == 0
assert and_gate(0, 1) == 0
assert and_gate(1, 0) == 0
assert and_gate(1, 1) == 1


if __name__ == "__main__":
test_and_gate()
print(and_gate(1, 0))
print(and_gate(0, 0))
print(and_gate(0, 1))
print(and_gate(1, 1))
import doctest

doctest.testmod()
7 changes: 3 additions & 4 deletions boolean_algebra/imply_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def imply_gate(input_1: int, input_2: int) -> int:


if __name__ == "__main__":
print(imply_gate(0, 0))
print(imply_gate(0, 1))
print(imply_gate(1, 0))
print(imply_gate(1, 1))
import doctest

doctest.testmod()
17 changes: 3 additions & 14 deletions boolean_algebra/nand_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,7 @@ def nand_gate(input_1: int, input_2: int) -> int:
return int((input_1, input_2).count(0) != 0)


def test_nand_gate() -> None:
"""
Tests the nand_gate function
"""
assert nand_gate(0, 0) == 1
assert nand_gate(0, 1) == 1
assert nand_gate(1, 0) == 1
assert nand_gate(1, 1) == 0


if __name__ == "__main__":
print(nand_gate(0, 0))
print(nand_gate(0, 1))
print(nand_gate(1, 0))
print(nand_gate(1, 1))
import doctest

doctest.testmod()
7 changes: 3 additions & 4 deletions boolean_algebra/nimply_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def nimply_gate(input_1: int, input_2: int) -> int:


if __name__ == "__main__":
print(nimply_gate(0, 0))
print(nimply_gate(0, 1))
print(nimply_gate(1, 0))
print(nimply_gate(1, 1))
import doctest

doctest.testmod()
13 changes: 3 additions & 10 deletions boolean_algebra/not_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ def not_gate(input_1: int) -> int:
return 1 if input_1 == 0 else 0


def test_not_gate() -> None:
"""
Tests the not_gate function
"""
assert not_gate(0) == 1
assert not_gate(1) == 0


if __name__ == "__main__":
print(not_gate(0))
print(not_gate(1))
import doctest

doctest.testmod()
17 changes: 3 additions & 14 deletions boolean_algebra/or_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ def or_gate(input_1: int, input_2: int) -> int:
return int((input_1, input_2).count(1) != 0)


def test_or_gate() -> None:
"""
Tests the or_gate function
"""
assert or_gate(0, 0) == 0
assert or_gate(0, 1) == 1
assert or_gate(1, 0) == 1
assert or_gate(1, 1) == 1


if __name__ == "__main__":
print(or_gate(0, 1))
print(or_gate(1, 0))
print(or_gate(0, 0))
print(or_gate(1, 1))
import doctest

doctest.testmod()
17 changes: 3 additions & 14 deletions boolean_algebra/xnor_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,7 @@ def xnor_gate(input_1: int, input_2: int) -> int:
return 1 if input_1 == input_2 else 0


def test_xnor_gate() -> None:
"""
Tests the xnor_gate function
"""
assert xnor_gate(0, 0) == 1
assert xnor_gate(0, 1) == 0
assert xnor_gate(1, 0) == 0
assert xnor_gate(1, 1) == 1


if __name__ == "__main__":
print(xnor_gate(0, 0))
print(xnor_gate(0, 1))
print(xnor_gate(1, 0))
print(xnor_gate(1, 1))
import doctest

doctest.testmod()
15 changes: 3 additions & 12 deletions boolean_algebra/xor_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ def xor_gate(input_1: int, input_2: int) -> int:
return (input_1, input_2).count(0) % 2


def test_xor_gate() -> None:
"""
Tests the xor_gate function
"""
assert xor_gate(0, 0) == 0
assert xor_gate(0, 1) == 1
assert xor_gate(1, 0) == 1
assert xor_gate(1, 1) == 0


if __name__ == "__main__":
print(xor_gate(0, 0))
print(xor_gate(0, 1))
import doctest

doctest.testmod()