< Summary

Class:KernelCommunication.ByteUtils
Assembly:KernelCommunication.BinaryReader
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/KernelCommunication/BinaryMessage/BinaryReader/ByteUtils.cs
Covered lines:11
Uncovered lines:4
Coverable lines:15
Total lines:44
Line coverage:73.3% (11 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PointerToInt32(...)0%110100%
PointerToInt64(...)0%110100%
ReadInt32(...)0%3.333066.67%
ReadInt64(...)0%3.333066.67%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/KernelCommunication/BinaryMessage/BinaryReader/ByteUtils.cs

#LineLine coverage
 1using System;
 2
 3namespace KernelCommunication
 4{
 5    public static class ByteUtils
 6    {
 7        public static unsafe int PointerToInt32(byte* ptr)
 8        {
 949            return (int)*ptr << 24 | (int)ptr[1] << 16 | (int)ptr[2] << 8 | (int)ptr[3];
 10        }
 11
 12        public static unsafe long PointerToInt64(byte* ptr)
 13        {
 1814            int num = (int)*ptr << 24 | (int)ptr[1] << 16 | (int)ptr[2] << 8 | (int)ptr[3];
 1815            return (long)((uint)((int)ptr[4] << 24 | (int)ptr[5] << 16 | (int)ptr[6] << 8) | (uint)ptr[7]) | (long)num <
 16        }
 17
 18        public static unsafe int ReadInt32(ReadOnlySpan<byte> span, int position)
 19        {
 8820            if ((long)(uint)position >= (long)span.Length)
 021                throw new IndexOutOfRangeException("offset is bigger than bytes array lenght");
 8822            if (position > span.Length - 4)
 023                throw new IndexOutOfRangeException("bytes.Length is not large enough to contain a valid Int32");
 24
 8825            fixed (byte* numPtr = &span[position])
 26            {
 8827                return PointerToInt32(numPtr);
 28            }
 29        }
 30
 31        public static unsafe long ReadInt64(ReadOnlySpan<byte> span, int position)
 32        {
 1833            if ((long)(uint)position >= (long)span.Length)
 034                throw new IndexOutOfRangeException("offset is bigger than bytes array lenght");
 1835            if (position > span.Length - 8)
 036                throw new IndexOutOfRangeException("bytes.Length is not large enough to contain a valid Int64");
 37
 1838            fixed (byte* numPtr = &span[position])
 39            {
 1840                return PointerToInt64(numPtr);
 41            }
 42        }
 43    }
 44}