2023-12-09 13:43:29 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
from benchmark.gcd import gcd
|
|
|
|
|
|
|
|
|
2023-12-21 22:54:39 +00:00
|
|
|
class Test_gcd(TestCase):
|
2023-12-25 21:24:01 +00:00
|
|
|
# distances_true = {1: [6], 2: [3], 3: [3], 4: [4], 5: [0, 0, 0, 1]}
|
|
|
|
# distances_false = {1: [0], 2: [0], 3: [0], 4: [0], 5: [4, 3, 1, 0]}
|
2023-12-21 22:54:39 +00:00
|
|
|
def test_gcd_1(self):
|
2023-12-25 21:24:01 +00:00
|
|
|
assert gcd(a=7, b=4) == 1
|
2023-12-21 22:54:39 +00:00
|
|
|
|
2023-12-25 21:24:01 +00:00
|
|
|
# distances_true = {1: [3], 2: [5], 3: [2], 4: [0], 5: [0, 0, 1]}
|
|
|
|
# distances_false = {1: [0], 2: [0], 3: [0], 4: [2], 5: [4, 2, 0]}
|
2023-12-21 22:54:39 +00:00
|
|
|
def test_gcd_2(self):
|
2023-12-25 21:24:01 +00:00
|
|
|
assert gcd(a=4, b=6) == 2
|
2023-12-21 22:54:39 +00:00
|
|
|
|
2023-12-25 21:24:01 +00:00
|
|
|
# distances_true = {1: [1], 2: [0]}
|
|
|
|
# distances_false = {1: [0], 2: [1]}
|
2023-12-21 22:54:39 +00:00
|
|
|
def test_gcd_3(self):
|
2023-12-25 21:24:01 +00:00
|
|
|
assert gcd(a=2, b=1) == 1
|
2023-12-21 22:54:39 +00:00
|
|
|
|
2023-12-25 21:24:01 +00:00
|
|
|
# distances_true = {1: [6], 2: [6], 3: [0]}
|
|
|
|
# distances_false = {1: [0], 2: [0], 3: [1]}
|
2023-12-21 22:54:39 +00:00
|
|
|
def test_gcd_4(self):
|
2023-12-25 21:24:01 +00:00
|
|
|
assert gcd(a=7, b=7) == 7
|
|
|
|
|
|
|
|
# distances_true = {1: [0]}
|
|
|
|
# distances_false = {1: [1]}
|
|
|
|
def test_gcd_5(self):
|
|
|
|
assert gcd(a=1, b=2) == 1
|