< Summary

Class:GDX.Developer.Reports.Resource.LongDiff
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/LongDiff.cs
Covered lines:34
Uncovered lines:5
Coverable lines:39
Total lines:89
Line coverage:87.1% (34 of 39)
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
LongDiff(...)0%220100%
GetSizeOutput(...)0%10.378066.67%
GetBeforeAndAfterOutput()0%110100%
OptionalPercentageOutput()0%4.014091.67%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/Reports/Resource/LongDiff.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
 5#if !UNITY_DOTSRUNTIME
 6
 7using UnityEngine;
 8
 9namespace GDX.Developer.Reports.Resource
 10{
 11    [HideFromDocFX]
 12    public readonly struct LongDiff
 13    {
 14        public readonly float Percentage;
 15        public readonly long Change;
 16        public readonly long LeftHandSide;
 17        public readonly long RightHandSide;
 18
 19        public LongDiff(long lhs, long rhs)
 1820        {
 1821            LeftHandSide = lhs;
 1822            RightHandSide = rhs;
 23
 1824            Change = rhs - lhs;
 1825            if (lhs == 0)
 226            {
 227                Percentage = Change;
 228            }
 29            else
 1630            {
 1631                Percentage = 100f * ((float)Change / lhs);
 1632            }
 1833        }
 34
 35
 36        public string GetSizeOutput(ResourceReportContext context, bool fileSize = true, bool fullWidth = false)
 1837        {
 1838            if (Change == 0)
 639            {
 640                return GetBeforeAndAfterOutput();
 41            }
 42
 43            // We dont have an idea of the width
 1244            if (!fullWidth && context != null)
 1245            {
 1246                return fileSize
 47                    ? $"{GetBeforeAndAfterOutput().PadRight(context.KeyValuePairInfoWidth)} {ResourceReport.PositiveSign
 48                    : $"{GetBeforeAndAfterOutput().PadRight(context.KeyValuePairInfoWidth)} {ResourceReport.PositiveSign
 49            }
 50
 051            if (fileSize)
 052            {
 053                return LeftHandSide == 0
 54                    ? $"{GetBeforeAndAfterOutput()} = {ResourceReport.PositiveSign(Change)}{Localization.GetHumanReadabl
 55                    : $"{GetBeforeAndAfterOutput()} = {ResourceReport.PositiveSign(Change)}{Localization.GetHumanReadabl
 56            }
 57
 058            return LeftHandSide == 0
 59                ? $"{GetBeforeAndAfterOutput()} = {ResourceReport.PositiveSign(Change)}{Change.ToString()}"
 60                : $"{GetBeforeAndAfterOutput()} = {ResourceReport.PositiveSign(Change)}{Change.ToString(),-12} {Optional
 1861        }
 62
 63        string GetBeforeAndAfterOutput()
 1864        {
 1865            return $"{LeftHandSide.ToString()} => {RightHandSide.ToString()}";
 1866        }
 67
 68        string OptionalPercentageOutput()
 1269        {
 1270            if (LeftHandSide == 0)
 171            {
 172                return null;
 73            }
 74
 1175            if (Percentage > 0)
 176            {
 177                return $" +{Mathf.RoundToInt(Percentage).ToString()}%";
 78            }
 79
 1080            if (Percentage < 0)
 1081            {
 1082                return $" {Mathf.RoundToInt(Percentage).ToString()}%";
 83            }
 84
 085            return null;
 1286        }
 87    }
 88}
 89#endif // !UNITY_DOTSRUNTIME