public unsafe void ExpandAfterShrinkPool_AllocatesDefault() { LazyUTF8String.ResetPool(new MockTracer(), DefaultIndexEntryCount); string fileAndFolderNames = "folderSDKfile.txtDKfolders"; UseASCIIBytePointer( fileAndFolderNames, bufferPtr => { int initialBytePoolSize = LazyUTF8String.BytePoolSize(); int initialStringPoolSize = LazyUTF8String.StringPoolSize(); LazyUTF8String.FromByteArray(bufferPtr + 6, 3); LazyUTF8String.FromByteArray(bufferPtr + 17, 2); LazyUTF8String.ShrinkPool(); CheckPoolSizes(expectedBytePoolSize: 6, expectedStringPoolSize: 2); LazyUTF8String.FreePool(); CheckPoolSizes(expectedBytePoolSize: 6, expectedStringPoolSize: 2); LazyUTF8String.ShrinkPool(); CheckPoolSizes(expectedBytePoolSize: 0, expectedStringPoolSize: 0); LazyUTF8String.FromByteArray(bufferPtr + 6, 3); CheckPoolSizes(expectedBytePoolSize: initialBytePoolSize, expectedStringPoolSize: initialStringPoolSize); LazyUTF8String.ShrinkPool(); CheckPoolSizes(expectedBytePoolSize: 3, expectedStringPoolSize: 1); }); }
public void MinimumPoolSize() { LazyUTF8String.ResetPool(new MockTracer(), 0); LazyUTF8String.FreePool(); LazyUTF8String.BytePoolSize().ShouldBeAtLeast(1); LazyUTF8String.InitializePools(new MockTracer(), 0); LazyUTF8String.BytePoolSize().ShouldBeAtLeast(1); }
public unsafe void FreePool_KeepsPoolSize() { UseASCIIBytePointer( "folderSDKfile.txtDKfolders", bufferPtr => { LazyUTF8String firstFolder = LazyUTF8String.FromByteArray(bufferPtr + 6, 3); LazyUTF8String secondFolder = LazyUTF8String.FromByteArray(bufferPtr + 17, 2); int bytePoolSizeBeforeFreePool = LazyUTF8String.BytePoolSize(); int stringPoolSizeBeforeFreePool = LazyUTF8String.StringPoolSize(); LazyUTF8String.FreePool(); CheckPoolSizes(bytePoolSizeBeforeFreePool, stringPoolSizeBeforeFreePool); }); }