No elements should have been added to the recycler.
immutable filename = fileId("recycle").fullpath; filename.forceRemove; BlockFile.create(filename, "recycle.unittest", SMALL_BLOCK_SIZE); auto blockfile = BlockFile(filename); scope (exit) { blockfile.close; } auto recycler = Recycler(blockfile); RecycleSegment*[] dispose_segments = [ new RecycleSegment(Index(1UL), 5), new RecycleSegment(Index(10UL), 5), new RecycleSegment(Index(17UL), 5), new RecycleSegment(Index(25UL), 5), ]; recycler.insert(dispose_segments[]); assert(recycler.indices.length == 4); assert(recycler.segments.length == 4); auto remove_segment = new RecycleSegment(Index(17UL), 5); recycler.remove(remove_segment); assert(recycler.indices.length == 3); assert(recycler.segments.length == 3); RecycleSegment*[] segs = [ new RecycleSegment(Index(1UL), 5), new RecycleSegment(Index(10UL), 5), // new RecycleSegment(Index(17UL), 5, Type.NONE), // This is the one that should be removed new RecycleSegment(Index(25UL), 5), ]; // recycler.indices[].array // .sort!((a, b) => a < b) // .each!writeln; // recycler.segments[].array // .sort!((a, b) => a < b) // .each!writeln; assert(equal(recycler.indices[].array.sort!((a, b) => a < b), recycler.segments[].array.sort!((a, b) => a < b)));