Ejemplo n.º 1
0
        public void file_size_should_be_greater_or_equal_after_adding_midpoints(byte version, int minDepth)
        {
            for (long numIndexEntries = 0; numIndexEntries < MAX_INDEX_ENTRIES; numIndexEntries += getIncrement(numIndexEntries))
            {
                string testCase      = $"numIndexEntries: {numIndexEntries}, minDepth: {minDepth}, version: {version}";
                var    midpointCount = PTable.GetRequiredMidpointCountCached(numIndexEntries, version, minDepth);
                if (version < PTableVersions.IndexV4)
                {
                    Assert.AreEqual(0, midpointCount, testCase);
                }
                else
                {
                    Assert.GreaterOrEqual(midpointCount, Math.Min(1 << Math.Min(MAX_DEPTH, minDepth), numIndexEntries), testCase);
                    Assert.LessOrEqual(midpointCount, Math.Max(2, numIndexEntries), testCase);
                }

                long fileSizeUpToIndexEntries    = PTable.GetFileSizeUpToIndexEntries(numIndexEntries, version);
                long fileSizeUpToMidpointEntries =
                    PTable.GetFileSizeUpToMidpointEntries(fileSizeUpToIndexEntries, midpointCount, version);

                if (version < PTableVersions.IndexV4)
                {
                    Assert.AreEqual(fileSizeUpToIndexEntries, fileSizeUpToMidpointEntries, testCase);
                }
                else
                {
                    Assert.GreaterOrEqual(fileSizeUpToMidpointEntries, fileSizeUpToIndexEntries, testCase);
                }
            }
        }