< Summary

Class:GDX.Mathematics.Range
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Mathematics/Range.cs
Covered lines:12
Uncovered lines:0
Coverable lines:12
Total lines:72
Line coverage:100% (12 of 12)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDouble(...)0%110100%
GetInteger(...)0%110100%
GetSingle(...)0%110100%
GetUnsignedInteger(...)0%110100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Mathematics/Range.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.Runtime.CompilerServices;
 6
 7namespace GDX.Mathematics
 8{
 9    /// <summary>
 10    ///     Some simple logic to pick a value from a range.
 11    /// </summary>
 12    public static class Range
 13    {
 14        /// <summary>
 15        ///     Returns the <see cref="double" /> between <paramref name="minValue" /> and
 16        ///     <paramref name="maxValue" /> range at <paramref name="percent" />.
 17        /// </summary>
 18        /// <param name="percent">The percentage (0-1) used to find a value in the range provided.</param>
 19        /// <param name="minValue">The lowest possible value.</param>
 20        /// <param name="maxValue">The highest possible value.</param>
 21        /// <returns>A <see cref="double" /> value.</returns>
 22        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 23        public static double GetDouble(double percent, double minValue = double.MinValue,
 24            double maxValue = double.MaxValue)
 7125        {
 7126            return maxValue * percent + minValue * (1d - percent);
 7127        }
 28
 29        /// <summary>
 30        ///     Returns the <see cref="int" /> between <paramref name="minValue" /> and
 31        ///     <paramref name="maxValue" /> range at <paramref name="percent" />.
 32        /// </summary>
 33        /// <param name="percent">The percentage (0-1) used to find a value in the range provided.</param>
 34        /// <param name="minValue">The lowest possible value.</param>
 35        /// <param name="maxValue">The highest possible value.</param>
 36        /// <returns>The <see cref="int" /> value.</returns>
 37        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 38        public static int GetInteger(double percent, int minValue = int.MinValue, int maxValue = int.MaxValue)
 17939        {
 17940            return (int)(maxValue * percent + minValue * (1d - percent));
 17941        }
 42
 43        /// <summary>
 44        ///     Returns the <see cref="float" /> between <paramref name="minValue" /> and
 45        ///     <paramref name="maxValue" /> range at <paramref name="percent" />.
 46        /// </summary>
 47        /// <param name="percent">The percentage (0-1) used to find a value in the range provided.</param>
 48        /// <param name="minValue">The lowest possible value.</param>
 49        /// <param name="maxValue">The highest possible value.</param>
 50        /// <returns>A <see cref="float" /> value.</returns>
 51        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 52        public static float GetSingle(double percent, float minValue = float.MinValue, float maxValue = float.MaxValue)
 6953        {
 6954            return (float)(maxValue * percent + minValue * (1d - percent));
 6955        }
 56
 57        /// <summary>
 58        ///     Returns the <see cref="uint" /> between <paramref name="minValue" /> and
 59        ///     <paramref name="maxValue" /> range at <paramref name="percent" />.
 60        /// </summary>
 61        /// <param name="percent">The percentage (0-1) used to find a value in the range provided.</param>
 62        /// <param name="minValue">The lowest possible value.</param>
 63        /// <param name="maxValue">The highest possible value.</param>
 64        /// <returns>A <see cref="uint" /> value.</returns>
 65        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 66        public static uint GetUnsignedInteger(double percent, uint minValue = uint.MinValue,
 67            uint maxValue = uint.MaxValue)
 7268        {
 7269            return (uint)(maxValue * percent + minValue * (1d - percent));
 7270        }
 71    }
 72}

Coverage by test methods

















































Methods/Properties

GetDouble(System.Double, System.Double, System.Double)
GetInteger(System.Double, System.Int32, System.Int32)
GetSingle(System.Double, System.Single, System.Single)
GetUnsignedInteger(System.Double, System.UInt32, System.UInt32)