def test_chunk_internals(): blocks = BlockArray([0] * 4096, 4, [0]) # Accumulate blocks added = [] for i in range(300): block, meta = divmod(i, 16) blocks[i] = block, meta added.append((block, meta)) assert blocks[:i + 1] == added if i < 256: assert len(blocks.palette) == i + 1 if i < 16: assert blocks.bits == 4 elif i < 32: assert blocks.bits == 5 elif i < 64: assert blocks.bits == 6 elif i < 128: assert blocks.bits == 7 else: assert blocks.bits == 8 else: assert blocks.palette is None assert blocks.bits == 13 # Zero the first 100 blocks for i in range(100): blocks[i] = (0, 0) blocks.repack() assert len(blocks.palette) == 201 assert blocks.bits == 8 # Zero blocks 100-199 for i in range(100, 200): blocks[i] = (0, 0) blocks.repack() assert len(blocks.palette) == 101 assert blocks.bits == 7 # Zero blocks 205 - 300 for i in range(205, 300): blocks[i] = (0, 0) blocks.repack() assert len(blocks.palette) == 6 assert blocks.bits == 4 # Check value for i in range(4096): if 200 <= i < 205: assert blocks[i] == divmod(i, 16) else: assert blocks[i] == (0, 0)
def test_chunk_internals(): blocks = BlockArray(OpaqueBlockMap(13), [0] * 4096, 4, [0]) # Accumulate blocks added = [] for i in range(300): blocks[i] = i added.append(i) assert blocks[:i + 1] == added if i < 256: assert len(blocks.palette) == i + 1 if i < 16: assert blocks.bits == 4 elif i < 32: assert blocks.bits == 5 elif i < 64: assert blocks.bits == 6 elif i < 128: assert blocks.bits == 7 else: assert blocks.bits == 8 else: assert blocks.palette == [] assert blocks.bits == 13 # Zero the first 100 blocks for i in range(100): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 201 assert blocks.bits == 8 # Zero blocks 100-199 for i in range(100, 200): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 101 assert blocks.bits == 7 # Zero blocks 205 - 300 for i in range(205, 300): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 6 assert blocks.bits == 4 # Check value for i in range(4096): if 200 <= i < 205: assert blocks[i] == i else: assert blocks[i] == 0
def test_chunk_internals(): blocks = BlockArray(OpaqueRegistry(13), [0]*4096, 4, [0]) # Accumulate blocks added = [] for i in range(300): blocks[i] = i added.append(i) assert blocks[:i+1] == added if i < 256: assert len(blocks.palette) == i + 1 if i < 16: assert blocks.bits == 4 elif i < 32: assert blocks.bits == 5 elif i < 64: assert blocks.bits == 6 elif i < 128: assert blocks.bits == 7 else: assert blocks.bits == 8 else: assert blocks.palette == [] assert blocks.bits == 13 # Zero the first 100 blocks for i in range(100): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 201 assert blocks.bits == 8 # Zero blocks 100-199 for i in range(100, 200): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 101 assert blocks.bits == 7 # Zero blocks 205 - 300 for i in range (205, 300): blocks[i] = 0 blocks.repack() assert len(blocks.palette) == 6 assert blocks.bits == 4 # Check value for i in range(4096): if 200 <= i < 205: assert blocks[i] == i else: assert blocks[i] == 0