def test_create_organize_list_convertor(equation, expected):
    # Set up the ConvertListToOrganizedList

    # create the metadata
    metadata = MetaData(OPERATORS_DICTIONARY)

    # convert the string to list
    convertor_string_to_list = StringToListConverter()
    metadata.equation_list = convertor_string_to_list.convert_string_to_list(
        equation)

    # create main convertor
    convertor = ConvertListToOrganizedList(metadata)
    assert convertor.create_organize_list() == expected, \
        "failed to check item: " + equation
def test_create_postfix_list_convertor(equation, expected):
    # Set up the InfixToPostFixConvertor

    # create the metadata
    metadata = MetaData(OPERATORS_DICTIONARY)

    # convert the string to list
    convertor_string_to_list = StringToListConverter()
    metadata.equation_list = convertor_string_to_list.convert_string_to_list(
        equation)

    # create main convertor
    convertor = InfixToPostfixConvertor(metadata.equation_list,
                                        OPERATORS_DICTIONARY)
    assert convertor.infix_to_postfix() == expected, "failed item: " + equation
예제 #3
0
def test_solve_equation(equation, expected):
    # Set up the solver

    # create the metadata
    metadata = MetaData(OPERATORS_DICTIONARY)

    # clean the white spaces from equation
    equation = remove_white_spaces(equation, LEGAL_WHITE_SPACES)

    # convert the string to list
    convertor_string_to_list = StringToListConverter()
    metadata.equation_list = \
        convertor_string_to_list.convert_string_to_list(equation)

    # create solver
    model = Model()
    assert model.solve_equation(metadata).result == expected, \
        "failed to check item: " + equation