< 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:19
Uncovered lines:13
Coverable lines:32
Total lines:64
Line coverage:59.3% (19 of 32)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:7
Method coverage:71.4% (5 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BinaryWriter(...)0%110100%
WriteInt32(...)0%110100%
WriteSingle(...)0%110100%
WriteInt64(...)0%2100%
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 LittleEndian binary to stream
 8    public class BinaryWriter : IDisposable
 9    {
 10        private Stream stream;
 11
 2712        public BinaryWriter(Stream stream)
 13        {
 2714            this.stream = stream;
 2715        }
 16
 17        public unsafe void WriteInt32(int value)
 18        {
 10219            byte* ptr = (byte*)&value;
 10220            stream.WriteByte(ptr[0]);
 10221            stream.WriteByte(ptr[1]);
 10222            stream.WriteByte(ptr[2]);
 10223            stream.WriteByte(ptr[3]);
 10224        }
 25
 26        public unsafe void WriteSingle(float value)
 27        {
 2028            byte* ptr = (byte*)&value;
 2029            stream.WriteByte(ptr[0]);
 2030            stream.WriteByte(ptr[1]);
 2031            stream.WriteByte(ptr[2]);
 2032            stream.WriteByte(ptr[3]);
 2033        }
 34
 35        public unsafe void WriteInt64(long value)
 36        {
 037            byte* ptr = (byte*)&value;
 038            stream.WriteByte(ptr[0]);
 039            stream.WriteByte(ptr[1]);
 040            stream.WriteByte(ptr[2]);
 041            stream.WriteByte(ptr[3]);
 042            stream.WriteByte(ptr[4]);
 043            stream.WriteByte(ptr[5]);
 044            stream.WriteByte(ptr[6]);
 045            stream.WriteByte(ptr[7]);
 046        }
 47
 48        public void WriteBytes(byte[] value)
 49        {
 1450            stream.Write(value, 0, value.Length);
 1451        }
 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        {
 961            stream = null;
 962        }
 63    }
 64}