< Summary

Class:GDX.Developer.ConsoleLog
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleLog.cs
Covered lines:14
Uncovered lines:65
Coverable lines:79
Total lines:142
Line coverage:17.7% (14 of 79)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:21
Method coverage:19% (4 of 21)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ConsoleLog()0%110100%
GetEntryAt(...)0%2100%
GetLastEntry()0%110100%
Finalize()0%2100%
OnMessageReceived(...)0%110100%
GetEnumerator()0%20400%
CopyTo(...)0%2100%
Add(...)0%2100%
Clear()0%2100%
Contains(...)0%20400%
IndexOf(...)0%20400%
Insert(...)0%2100%
Remove(...)0%2100%
RemoveAt(...)0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleLog.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using UnityEngine;
 7using System.Collections;
 8using GDX.Collections.Generic;
 9
 10namespace GDX.Developer
 11{
 12    public class ConsoleLog : IList
 13    {
 1414        public uint Version = 0;
 15
 1416        ConcurrentCircularBuffer<ConsoleLogEntry> m_LogHistory = new ConcurrentCircularBuffer<ConsoleLogEntry>(1000);
 17
 18        public ConsoleLogEntry GetEntryAt(int index)
 019        {
 020            return m_LogHistory[index];
 021        }
 22
 23        public ConsoleLogEntry GetLastEntry()
 224        {
 225            return m_LogHistory[Count - 1];
 226        }
 27
 1428        public ConsoleLog()
 1429        {
 1430            Application.logMessageReceivedThreaded += OnMessageReceived;
 1431        }
 32
 33        ~ConsoleLog()
 034        {
 035            Application.logMessageReceivedThreaded -= OnMessageReceived;
 036        }
 37
 38        void OnMessageReceived(string message, string stacktrace, LogType type)
 1339        {
 1340            m_LogHistory.Add(new ConsoleLogEntry(type, message, stacktrace));
 1341            Version++;
 1342        }
 43
 44        public IEnumerator GetEnumerator()
 045        {
 046            int count = m_LogHistory.Count;
 047            for (int i = 0; i < count; i++)
 048            {
 049                yield return m_LogHistory[i];
 050            }
 051        }
 52
 53        public void CopyTo(Array array, int index)
 054        {
 55            // Immutable
 056        }
 57
 258        public int Count => m_LogHistory.Count;
 59
 060        public bool IsSynchronized => false;
 061        public object SyncRoot => this;
 62
 63        public int Add(object value)
 064        {
 065            return -1;
 066        }
 67
 68        public void Clear()
 069        {
 070            m_LogHistory.Clear();
 071            Version++;
 072        }
 73
 74        public bool Contains(object value)
 075        {
 076            if (value == null)
 077            {
 078                return false;
 79            }
 80
 081            ConsoleLogEntry unboxed = (ConsoleLogEntry)value;
 082            int count = m_LogHistory.Count;
 083            for (int i = 0; i < count; i++)
 084            {
 085                ConsoleLogEntry currentEntry = m_LogHistory[i];
 086                if (currentEntry.CompareTo(unboxed) == 0)
 087                {
 088                    return true;
 89                }
 090            }
 91
 092            return false;
 093        }
 94
 95        public int IndexOf(object value)
 096        {
 097            if (value == null)
 098            {
 099                return -1;
 100            }
 101
 0102            ConsoleLogEntry unboxed = (ConsoleLogEntry)value;
 0103            int count = m_LogHistory.Count;
 0104            for (int i = 0; i < count; i++)
 0105            {
 0106                ConsoleLogEntry currentEntry = m_LogHistory[i];
 0107                if (currentEntry.CompareTo(unboxed) == 0)
 0108                {
 0109                    return i;
 110                }
 0111            }
 112
 0113            return -1;
 0114        }
 115
 116        public void Insert(int index, object value)
 0117        {
 118            // Immutable
 0119        }
 120
 121        public void Remove(object value)
 0122        {
 123            // Immutable
 0124        }
 125
 126        public void RemoveAt(int index)
 0127        {
 128            // Immutable
 0129        }
 130
 0131        public bool IsFixedSize => false;
 0132        public bool IsReadOnly => true;
 133
 134        public object this[int index]
 135        {
 0136            get => m_LogHistory[index];
 137            set
 0138            {
 0139            }
 140        }
 141    }
 142}

Coverage by test methods










Methods/Properties

ConsoleLog()
GetEntryAt(System.Int32)
GetLastEntry()
Finalize()
OnMessageReceived(System.String, System.String, UnityEngine.LogType)
GetEnumerator()
CopyTo(System.Array, System.Int32)
Count()
IsSynchronized()
SyncRoot()
Add(System.Object)
Clear()
Contains(System.Object)
IndexOf(System.Object)
Insert(System.Int32, System.Object)
Remove(System.Object)
RemoveAt(System.Int32)
IsFixedSize()
IsReadOnly()
Item(System.Int32)
Item(System.Int32, System.Object)