# Copyright 2026 jCloud # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import pytest from src.jcloud_docsgen.utils import fit_row_length @pytest.mark.parametrize( 'expected_length,row,expected', [ (0, (), ()), (1, (), (None,)), (2, (), (None, None)), (2, (1,), (1, None)), (0, (1,), ()), (1, (1, 2), (1,)), (1, (1, 2), (1,)), (0, (1, 2), ()), (0, (1, 2, 3), ()), (1, (1, 2, 3), (1,)), (2, (1, 2, 3), (1, 2)), (1, (1,), (1,)), (2, (1, 1), (1, 1)), (2, (1, 2), (1, 2)), (3, (1, 2, 3), (1, 2, 3)), ], ) def test_fit_row_length(expected_length, row, expected): assert fit_row_length(expected_length, row) == expected @pytest.mark.parametrize( 'row', [ (), (1,), (1, 2), (1, 2, 3), (1, 2, 3, 456), ], ) @pytest.mark.parametrize( 'expected_length,expected_exception', [ (-1, ValueError), (-2, ValueError), (-3, ValueError), (-42, ValueError), ], ) def test_fit_row_length_exceptions(expected_length, row, expected_exception): with pytest.raises(expected_exception) as exc_info: fit_row_length(expected_length, row) assert str(exc_info.value) == 'expected must be larger than or equal 0.'