< Summary

Class:UniGifExtension
Assembly:UniGif
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/UniGif/UniGifExtension.cs
Covered lines:11
Uncovered lines:6
Coverable lines:17
Total lines:56
Line coverage:64.7% (11 of 17)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetNumeral(...)0%3.073080%
ToNumeral(...)0%3.793055.56%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/UniGif/UniGifExtension.cs

#LineLine coverage
 1using UnityEngine;
 2using System.Collections;
 3
 4/// <summary>
 5/// Extension methods class
 6/// </summary>
 7public static class UniGifExtension
 8{
 9    /// <summary>
 10    /// Convert BitArray to int (Specifies the start index and bit length)
 11    /// </summary>
 12    /// <param name="startIndex">Start index</param>
 13    /// <param name="bitLength">Bit length</param>
 14    /// <returns>Converted int</returns>
 15    public static int GetNumeral(this BitArray array, int startIndex, int bitLength)
 16    {
 156307617        var newArray = new BitArray(bitLength);
 18
 3807251219        for (int i = 0; i < bitLength; i++)
 20        {
 1747318021            if (array.Length <= startIndex + i)
 22            {
 023                newArray[i] = false;
 024            }
 25            else
 26            {
 1747318027                bool bit = array.Get(startIndex + i);
 1747318028                newArray[i] = bit;
 29            }
 30        }
 31
 156307632        return newArray.ToNumeral();
 33    }
 34
 35    /// <summary>
 36    /// Convert BitArray to int
 37    /// </summary>
 38    /// <returns>Converted int</returns>
 39    public static int ToNumeral(this BitArray array)
 40    {
 156307641        if (array == null)
 42        {
 043            Debug.LogError("array is nothing.");
 044            return 0;
 45        }
 156307646        if (array.Length > 32)
 47        {
 048            Debug.LogError("must be at most 32 bits long.");
 049            return 0;
 50        }
 51
 156307652        var result = new int[1];
 156307653        array.CopyTo(result, 0);
 156307654        return result[0];
 55    }
 56}