Beispiel #1
0
 def test_completeness(self, a, b, c):
     solutions = set(base_solution_linear(a, b, c))
     for x in range(c + 1):
         for y in range(c - a * x):
             if a * x + b * y == c:
                 assert (
                     x,
                     y) in solutions, "Missing solution {!r},{!r}".format(
                         x, y)
Beispiel #2
0
 def test_error(self, a, b, c):
     with pytest.raises(ValueError):
         next(base_solution_linear(a, b, c))
Beispiel #3
0
 def test_uniqueness(self, a, b, c):
     solutions = list(base_solution_linear(a, b, c))
     assert is_unique_list(solutions), "Duplicate solution found"
Beispiel #4
0
 def test_correctness(self, a, b, c):
     for x, y in base_solution_linear(a, b, c):
         assert x >= 0
         assert y >= 0
         assert a * x + b * y == c, "Invalid solution {!r},{!r}".format(
             x, y)