< Summary

Class:GDX.EnumExtensions
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/EnumExtensions.cs
Covered lines:14
Uncovered lines:0
Coverable lines:14
Total lines:54
Line coverage:100% (14 of 14)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HasFlags[T](...)0%330100%
HasFlags[T](...)0%110100%

File(s)

./Packages/com.dotbunny.gdx/GDX/EnumExtensions.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
 9{
 10    /// <summary>
 11    ///     Enumeration Based Extension Methods
 12    /// </summary>
 13    [VisualScriptingCompatible(2)]
 14    public static class EnumExtensions
 15    {
 16        /// <summary>
 17        ///     Determine if the provide flags (<paramref name="needles" />) are found in the <paramref name="haystack" 
 18        /// </summary>
 19        /// <param name="haystack">A predefined flag based enumeration.</param>
 20        /// <param name="needles">A set of flags to search for in the predefined enumeration.</param>
 21        /// <typeparam name="T">The enumeration's type.</typeparam>
 22        /// <returns>true if the needles are found in the haystack, otherwise false.</returns>
 23        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 24        static unsafe bool HasFlags<T>(T* haystack, T* needles) where T : unmanaged, Enum
 16025        {
 16026            byte* flags = (byte*)haystack;
 16027            byte* query = (byte*)needles;
 28
 45629            for (int i = 0; i < sizeof(T); i++)
 19430            {
 19431                if ((flags[i] & query[i]) != query[i])
 12632                {
 12633                    return false;
 34                }
 6835            }
 36
 3437            return true;
 16038        }
 39
 40        /// <summary>
 41        ///     Determine if the provide flags (<paramref name="needles" />) are found in the <paramref name="haystack"