Match src param name of BrotliEncoder.GetMaxCompressedLength to ref param name (dotne...
authorCarlos Sanchez Lopez <1175054+carlossanlop@users.noreply.github.com>
Thu, 5 Sep 2019 12:49:13 +0000 (05:49 -0700)
committerStephen Toub <stoub@microsoft.com>
Thu, 5 Sep 2019 12:49:13 +0000 (08:49 -0400)
* Make the name of the parameter in the BrotliEncoder.GetMaxCompressedLength src match the name of the parameter in the ref.

* Update unit test validating parameter name.

Commit migrated from https://github.com/dotnet/corefx/commit/c668e96cb0886d13a051d8021a3c3147e7daa15c

src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/enc/BrotliEncoder.cs
src/libraries/System.IO.Compression.Brotli/tests/BrotliEncoderTests.cs

index b127f4f..babb14a 100644 (file)
@@ -92,19 +92,19 @@ namespace System.IO.Compression
             }
         }
 
-        public static int GetMaxCompressedLength(int length)
+        public static int GetMaxCompressedLength(int inputSize)
         {
-            if (length < 0 || length > BrotliUtils.MaxInputSize)
+            if (inputSize < 0 || inputSize > BrotliUtils.MaxInputSize)
             {
-                throw new ArgumentOutOfRangeException(nameof(length));
+                throw new ArgumentOutOfRangeException(nameof(inputSize));
             }
-            if (length == 0)
+            if (inputSize == 0)
                 return 1;
-            int numLargeBlocks = length >> 24;
-            int tail = length & 0xFFFFFF;
+            int numLargeBlocks = inputSize >> 24;
+            int tail = inputSize & 0xFFFFFF;
             int tailOverhead = (tail > (1 << 20)) ? 4 : 3;
             int overhead = 2 + (4 * numLargeBlocks) + tailOverhead + 1;
-            int result = length + overhead;
+            int result = inputSize + overhead;
             return result;
         }
 
index ae708bb..7193419 100644 (file)
@@ -36,8 +36,8 @@ namespace System.IO.Compression.Tests
         [Fact]
         public void GetMaxCompressedSize_Basic()
         {
-            Assert.Throws<ArgumentOutOfRangeException>("length", () => BrotliEncoder.GetMaxCompressedLength(-1));
-            Assert.Throws<ArgumentOutOfRangeException>("length", () => BrotliEncoder.GetMaxCompressedLength(2147483133));
+            Assert.Throws<ArgumentOutOfRangeException>("inputSize", () => BrotliEncoder.GetMaxCompressedLength(-1));
+            Assert.Throws<ArgumentOutOfRangeException>("inputSize", () => BrotliEncoder.GetMaxCompressedLength(2147483133));
             Assert.InRange(BrotliEncoder.GetMaxCompressedLength(2147483132), 0, int.MaxValue);
             Assert.Equal(1, BrotliEncoder.GetMaxCompressedLength(0));
         }