< 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:5
Uncovered lines:9
Coverable lines:14
Total lines:45
Line coverage:35.7% (5 of 14)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:4
Method coverage:50% (2 of 4)

Metrics

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

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        {
 1099            return *(int*)ptr;
 10        }
 11
 12        public static unsafe long PointerToInt64(byte* ptr)
 13        {
 014            return *(long*)ptr;
 15        }
 16
 17        public static unsafe int ReadInt32(ReadOnlySpan<byte> span, int position)
 18        {
 10319            if ((long)(uint)position >= (long)span.Length)
 020                throw new IndexOutOfRangeException("offset is bigger than bytes array lenght");
 21
 10322            if (position > span.Length - 4)
 023                throw new IndexOutOfRangeException("bytes.Length is not large enough to contain a valid Int32");
 24
 10325            fixed (byte* numPtr = &span[position])
 26            {
 10327                return PointerToInt32(numPtr);
 28            }
 29        }
 30
 31        public static unsafe long ReadInt64(ReadOnlySpan<byte> span, int position)
 32        {
 033            if ((long)(uint)position >= (long)span.Length)
 034                throw new IndexOutOfRangeException("offset is bigger than bytes array lenght");
 35
 036            if (position > span.Length - 8)
 037                throw new IndexOutOfRangeException("bytes.Length is not large enough to contain a valid Int64");
 38
 039            fixed (byte* numPtr = &span[position])
 40            {
 041                return PointerToInt64(numPtr);
 42            }
 43        }
 44    }
 45}