< Summary

Class:GDX.Collections.BitArray8
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Collections/BitArray8.cs
Covered lines:10
Uncovered lines:3
Coverable lines:13
Total lines:63
Line coverage:76.9% (10 of 13)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:3
Method coverage:66.6% (2 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BitArray8(...)0%2100%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Collections/BitArray8.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using System.Runtime.CompilerServices;
 7
 8namespace GDX.Collections
 9{
 10    /// <summary>
 11    ///     A 8-bit array.
 12    /// </summary>
 13    /// <example>
 14    ///     Useful for packing a bunch of data with known indices tightly.
 15    ///     <code>
 16    ///         if(myBitArray8[1])
 17    ///         {
 18    ///             BeAwesome();
 19    ///         }
 20    ///     </code>
 21    /// </example>
 22    [Serializable]
 23    public struct BitArray8
 24    {
 25        /// <summary>
 26        ///     First reserved <see cref="byte" /> memory block (8-bits).
 27        /// </summary>
 28        /// <remarks>Indices 0-7</remarks>
 29        public byte Bits0;
 30
 31        /// <summary>
 32        ///     Create a new <see cref="BitArray8" /> based on provided <paramref name="bits0" />.
 33        /// </summary>
 34        /// <param name="bits0">An existing value to be used to create the backing data for a <see cref="BitArray8" /></
 35        public BitArray8(byte bits0)
 036        {
 037            Bits0 = bits0;
 038        }
 39
 40        /// <summary>
 41        ///     Access bit in array.
 42        /// </summary>
 43        /// <param name="index">Target bit index.</param>
 44        public bool this[byte index]
 45        {
 46            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 3347            get => (Bits0 & (1 << index)) != 0;
 48
 49            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 50            set
 7051            {
 7052                if (value)
 2353                {
 2354                    Bits0 = (byte)(Bits0 | (1 << index));
 2355                }
 56                else
 4757                {
 4758                    Bits0 = (byte)(Bits0 & ~(1 << index));
 4759                }
 7060            }
 61        }
 62    }
 63}