コード例 #1
0
def test_triangle_counts():
    for row_count in range(1, 15):
        triangle = single_panel_grid(row_count)
        assert triangle.row_count == row_count

        expected_cell_count = Geometry.triangular_number(row_count)
        assert len(triangle) == len(triangle.cells) == expected_cell_count,\
            f'cell count {len(triangle.cells)} != expected {expected_cell_count} with rows {row_count}'

        # Each edge has the same number of elements are the number or total rows.
        assert row_count == len(bottom_edge(triangle)) == len(
            left_edge(triangle)) == len(right_edge(triangle))
コード例 #2
0
def test_triangle_number():
    for (n, number) in [(1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36)]:
        assert Geometry.triangular_number(n) == number