< 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:29
Uncovered lines:3
Coverable lines:32
Total lines:64
Line coverage:90.6% (29 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BinaryWriter(...)0%110100%
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
 2212        public BinaryWriter(Stream stream)
 13        {
 2214            this.stream = stream;
 2215        }
 16
 17        public unsafe void WriteInt32(int value)
 18        {
 8419            byte* ptr = (byte*)&value;
 8420            stream.WriteByte(ptr[3]);
 8421            stream.WriteByte(ptr[2]);
 8422            stream.WriteByte(ptr[1]);
 8423            stream.WriteByte(ptr[0]);
 8424        }
 25
 26        public unsafe void WriteSingle(float value)
 27        {
 8028            byte* ptr = (byte*)&value;
 8029            stream.WriteByte(ptr[3]);
 8030            stream.WriteByte(ptr[2]);
 8031            stream.WriteByte(ptr[1]);
 8032            stream.WriteByte(ptr[0]);
 8033        }
 34
 35        public unsafe void WriteInt64(long value)
 36        {
 1637            byte* ptr = (byte*)&value;
 1638            stream.WriteByte(ptr[7]);
 1639            stream.WriteByte(ptr[6]);
 1640            stream.WriteByte(ptr[5]);
 1641            stream.WriteByte(ptr[4]);
 1642            stream.WriteByte(ptr[3]);
 1643            stream.WriteByte(ptr[2]);
 1644            stream.WriteByte(ptr[1]);
 1645            stream.WriteByte(ptr[0]);
 1646        }
 47
 48        public void WriteBytes(byte[] value)
 49        {
 1350            stream.Write(value, 0, value.Length);
 1351        }
 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        {
 1061            stream = null;
 1062        }
 63    }
 64}