< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.IntEncoder
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/IntEncoder.cs
Line coverage
86%
Covered lines: 13
Uncovered lines: 2
Coverable lines: 15
Total lines: 42
Line coverage: 86.6%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Encode(...)100%22100%
GetEncodedSize(...)75%4475%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/IntEncoder.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5
 6namespace CoreWCF.Channels
 7{
 8    internal static class IntEncoder
 9    {
 10        public const int MaxEncodedSize = 5;
 11
 12        public static int Encode(int value, byte[] bytes, int offset)
 13        {
 34614            int count = 1;
 37215            while ((value & 0xFFFFFF80) != 0)
 16            {
 2617                bytes[offset++] = (byte)((value & 0x7F) | 0x80);
 2618                count++;
 2619                value >>= 7;
 20            }
 34621            bytes[offset] = (byte)value;
 34622            return count;
 23        }
 24
 25        public static int GetEncodedSize(int value)
 26        {
 61127            if (value < 0)
 28            {
 029                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value),
 030                    SRCommon.ValueMustBeNonNegative));
 31            }
 32
 61133            int count = 1;
 63734            while ((value & 0xFFFFFF80) != 0)
 35            {
 2636                count++;
 2637                value >>= 7;
 38            }
 61139            return count;
 40        }
 41    }
 42}