Skip to content

Commit

Permalink
Recursive combination
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Mar 17, 2024
1 parent 2f3c2eb commit 5351e41
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/test_msglc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import random
from io import BytesIO
from itertools import cycle

import pytest

Expand Down Expand Up @@ -246,6 +246,32 @@ def test_combine_archives(tmpdir, json_after, target):
combine(target, [FileInfo("combined_aa.msg"), FileInfo("combined_a.msg")])


def test_recursive_combine(tmpdir):
alternate = cycle(["combined.msg", "core.msg", "core.msg", "combined.msg"])

def token():
return random.choice(["a", "b", "c", None])

core = [x for x in range(10)]

with tmpdir.as_cwd():
with LazyWriter("core.msg") as writer:
writer.write(core)

path: list = []

for _ in range(10):
segment = token()
target = next(alternate)
combine(target, [FileInfo(next(alternate), segment)])
if segment is None:
segment = 0
path.append(segment)

with LazyReader(target) as reader:
assert reader.read(list(reversed(path))) == core


def test_configure_with_valid_values():
configure(
small_obj_optimization_threshold=2**14,
Expand Down

0 comments on commit 5351e41

Please sign in to comment.