< Summary

Class:KernelCommunication.BinaryWriter
Assembly:KernelCommunication.BinaryWriter
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/KernelCommunication/BinaryMessage/BinaryWriter/BinaryWriter.cs
Covered lines:26
Uncovered lines:6
Coverable lines:32
Total lines:64
Line coverage:81.2% (26 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BinaryWriter(...)0%2100%
WriteInt32(...)0%110100%
WriteSingle(...)0%110100%
WriteInt64(...)0%110100%
WriteBytes(...)0%110100%
WriteString(...)0%2100%
Dispose()0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Text;
 4
 5namespace KernelCommunication
 6{
 7    // Write BigEndian binary to stream
 8    public class BinaryWriter : IDisposable
 9    {
 10        private Stream stream;
 11
 012        public BinaryWriter(Stream stream)
 13        {
 014            this.stream = stream;
 015        }
 16
 17        public unsafe void WriteInt32(int value)
 18        {
 5319            byte* ptr = (byte*)&value;
 5320            stream.WriteByte(ptr[3]);
 5321            stream.WriteByte(ptr[2]);
 5322            stream.WriteByte(ptr[1]);
 5323            stream.WriteByte(ptr[0]);
 5324        }
 25
 26        public unsafe void WriteSingle(float value)
 27        {
 2028            byte* ptr = (byte*)&value;
 2029            stream.WriteByte(ptr[3]);
 2030            stream.WriteByte(ptr[2]);
 2031            stream.WriteByte(ptr[1]);
 2032            stream.WriteByte(ptr[0]);
 2033        }
 34
 35        public unsafe void WriteInt64(long value)
 36        {
 1137            byte* ptr = (byte*)&value;
 1138            stream.WriteByte(ptr[7]);
 1139            stream.WriteByte(ptr[6]);
 1140            stream.WriteByte(ptr[5]);
 1141            stream.WriteByte(ptr[4]);
 1142            stream.WriteByte(ptr[3]);
 1143            stream.WriteByte(ptr[2]);
 1144            stream.WriteByte(ptr[1]);
 1145            stream.WriteByte(ptr[0]);
 1146        }
 47
 48        public void WriteBytes(byte[] value)
 49        {
 850            stream.Write(value, 0, value.Length);
 851        }
 52
 53        public void WriteString(string value)
 54        {
 055            var bytes = Encoding.UTF8.GetBytes(value);
 056            stream.Write(bytes, 0, bytes.Length);
 057        }
 58
 59        public void Dispose()
 60        {
 161            stream = null;
 162        }
 63    }
 64}