< Summary

Class:GDX.Collections.BitArray16
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Collections/BitArray16.cs
Covered lines:7
Uncovered lines:6
Coverable lines:13
Total lines:63
Line coverage:53.8% (7 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
BitArray16(...)0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Collections/BitArray16.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 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 16-bit array.
 12    /// </summary>
 13    /// <example>
 14    ///     Useful for packing a bunch of data with known indices tightly.
 15    ///     <code>
 16    ///         if(myBitArray16[1])
 17    ///         {
 18    ///             BeAwesome();
 19    ///         }
 20    ///     </code>
 21    /// </example>
 22    [Serializable]
 23    public struct BitArray16
 24    {
 25        /// <summary>
 26        ///     First reserved <see cref="ushort" /> memory block (16-bits).
 27        /// </summary>
 28        /// <remarks>Indices 0-15</remarks>
 29        public ushort Bits0;
 30
 31        /// <summary>
 32        ///     Create a new <see cref="BitArray16" /> 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="BitArray16" /><
 35        public BitArray16(ushort 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)]
 38247            get => (Bits0 & (1 << index)) != 0;
 48
 49            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 50            set
 451            {
 452                if (value)
 453                {
 454                    Bits0 = (ushort)(Bits0 | (1 << index));
 455                }
 56                else
 057                {
 058                    Bits0 = (ushort)(Bits0 & ~(1 << index));
 059                }
 460            }
 61        }
 62    }
 63}

Coverage by test methods
















Methods/Properties

BitArray16(System.UInt16)
Item(System.Byte)
Item(System.Byte, System.Boolean)