Beispiel #1
0
def test_cpp_layf_get_features_returns_correct_set_of_features():
     cpp_layf = CppLayoutFeatures([SOURCE_CODE_10], [])

     features, _ = cpp_layf.get_features()

     assert features == [[math.log(2. / len(SOURCE_CODE_10)), math.log(2. / len(SOURCE_CODE_10)),
                        4. / 9, False, True]]
Beispiel #2
0
def test_cpp_layf_tabs_lead_line_with_greater_number_of_spaces_at_beginning_return_false():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_12], [])

    tabs_lead_lines = cpp_layf.tabs_lead_lines(SOURCE_CODE_12)

    assert not tabs_lead_lines
Beispiel #3
0
def test_cpp_layf_tabs_lead_line_with_greater_number_of_tabs_at_beginning_return_true():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_11], [])

    tabs_lead_lines = cpp_layf.tabs_lead_lines(SOURCE_CODE_11)

    assert tabs_lead_lines
Beispiel #4
0
def test_cpp_layf_new_line_before_braces_with_greater_number_of_close_paranthesis_lines_before_braces_returns_false():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_12], [])

    new_line_before_braces = cpp_layf.new_line_before_open_brace(SOURCE_CODE_12)

    assert not new_line_before_braces
Beispiel #5
0
def test_cpp_layf_new_line_before_braces_with_greater_number_of_new_lines_before_braces_returns_true():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_11], [])

    new_line_before_braces = cpp_layf.new_line_before_open_brace(SOURCE_CODE_11)

    assert new_line_before_braces
Beispiel #6
0
def test_cpp_layf_whitespace_ratio_returns_correct_ratio():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_10], [])

    ratio = cpp_layf.whitespace_ratio(SOURCE_CODE_10)

    assert ratio == 4. / 9
Beispiel #7
0
def test_cpp_layf_spaces_count_return_correct_number_of_spaces():
    cpp_layf = CppLayoutFeatures([SOURCE_CODE_10], [])

    spaces_count = cpp_layf.spaces(SOURCE_CODE_10)

    assert spaces_count == math.log(2. / len(SOURCE_CODE_10))