def test_boundaries_edge_cases():
    """test treatment of invalid data"""
    grid = UnitGrid([3, 3])
    bcs = grid.get_boundary_conditions("auto_periodic_neumann")
    with pytest.raises(BCDataError):
        Boundaries([])
    with pytest.raises(BCDataError):
        Boundaries([bcs[0]])
    with pytest.raises(BCDataError):
        Boundaries([bcs[0], bcs[0]])

    assert bcs == Boundaries([bcs[0], bcs[1]])
    bc0 = get_boundary_axis(grid.copy(), 0, "auto_periodic_neumann")
    assert bcs == Boundaries([bc0, bcs[1]])
    bc0 = get_boundary_axis(UnitGrid([4, 3]), 0, "auto_periodic_neumann")
    with pytest.raises(BCDataError):
        Boundaries([bc0, bcs[1]])
    bc0 = get_boundary_axis(UnitGrid([3, 3], periodic=True), 0, "auto_periodic_neumann")
    with pytest.raises(BCDataError):
        Boundaries([bc0, bcs[1]])