Пример #1
0
 def test_multiple_steps(self):
     operators = [AddOperator(1), MultiplyOperator(20), DivideOperator(3)]
     problem = Problem(start_number=2,
                       end_number=1,
                       move_count=2,
                       operators=operators)
     solution = random_solve(problem)
     self.assertEqual(solution, [AddOperator(1), DivideOperator(3)])
Пример #2
0
 def test_only_option(self):
     operators = [AddOperator(3)]
     problem = Problem(start_number=2,
                       end_number=5,
                       move_count=1,
                       operators=operators)
     solution = random_solve(problem)
     self.assertEqual(solution, [AddOperator(3)])
Пример #3
0
 def test_str_negative(self):
     string = str(AddOperator(-5))
     self.assertEqual(string, "[ - 5 ]")
Пример #4
0
 def test_str_positive(self):
     string = str(AddOperator(3))
     self.assertEqual(string, "[ + 3 ]")
Пример #5
0
 def test_add_negative(self):
     state = State(current_number=5)
     state.apply(AddOperator(-8))
     self.assertEqual(state.current_number, -3)
Пример #6
0
 def test_add_positive(self):
     state = State(current_number=10)
     state.apply(AddOperator(5))
     self.assertEqual(state.current_number, 15)
Пример #7
0
 def test_add_zero(self):
     state = State(current_number=2)
     state.apply(AddOperator(0))
     self.assertEqual(state.current_number, 2)