< Summary

Line coverage
71%
Covered lines: 28
Uncovered lines: 11
Coverable lines: 39
Total lines: 115
Line coverage: 71.7%
Branch coverage
50%
Covered branches: 6
Total branches: 12
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Vertex()100%11100%
set_Vertex(...)100%11100%
get_Texture()100%11100%
set_Texture(...)100%11100%
get_Normal()100%11100%
set_Normal(...)100%11100%
Equals(...)0%620%
Equals(...)0%2040%
GetHashCode()100%210%
ToString()100%66100%
op_Equality(...)100%210%
op_Inequality(...)100%210%

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/dbbfcd213b7c54f49194f82fcd56e790cca193c3/JeremyAnsel.Media.WavefrontObj/JeremyAnsel.Media.WavefrontObj/ObjTriplet.cs

#LineLine coverage
 1// <copyright file="ObjTriplet.cs" company="Jérémy Ansel">
 2// Copyright (c) 2017, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8using System.Globalization;
 9
 10namespace JeremyAnsel.Media.WavefrontObj
 11{
 12    [System.Diagnostics.DebuggerDisplay("Vertex:{vertex} Texture:{texture} Normal:{normal}")]
 13    public struct ObjTriplet : IEquatable<ObjTriplet>
 14    {
 15        private int vertex;
 16
 17        private int texture;
 18
 19        private int normal;
 20
 21        public ObjTriplet(int vertexIndex, int textureIndex, int normalIndex)
 22        {
 35423            this.vertex = vertexIndex;
 35424            this.texture = textureIndex;
 35425            this.normal = normalIndex;
 35426        }
 27
 28        public int Vertex
 29        {
 25530            readonly get { return this.vertex; }
 631            set { this.vertex = value; }
 32        }
 33
 34        public int Texture
 35        {
 15336            readonly get { return this.texture; }
 637            set { this.texture = value; }
 38        }
 39
 40        public int Normal
 41        {
 15342            readonly get { return this.normal; }
 643            set { this.normal = value; }
 44        }
 45
 46        public readonly override bool Equals(object? obj)
 47        {
 048            return obj is ObjTriplet triplet && Equals(triplet);
 49        }
 50
 51        public readonly bool Equals(ObjTriplet other)
 52        {
 053            return vertex == other.vertex &&
 054                   texture == other.texture &&
 055                   normal == other.normal;
 56        }
 57
 58        public readonly override int GetHashCode()
 59        {
 060            var hashCode = -683219715;
 061            hashCode = hashCode * -1521134295 + vertex.GetHashCode();
 062            hashCode = hashCode * -1521134295 + texture.GetHashCode();
 063            hashCode = hashCode * -1521134295 + normal.GetHashCode();
 064            return hashCode;
 65        }
 66
 67        public readonly override string ToString()
 68        {
 12969            if (this.Normal == 0)
 70            {
 12371                if (this.Texture == 0)
 72                {
 12073                    return this.Vertex.ToString(CultureInfo.InvariantCulture);
 74                }
 75                else
 76                {
 377                    return string.Concat(
 378                        this.Vertex.ToString(CultureInfo.InvariantCulture),
 379                        "/",
 380                        this.Texture.ToString(CultureInfo.InvariantCulture));
 81                }
 82            }
 83            else
 84            {
 685                if (this.Texture == 0)
 86                {
 387                    return string.Concat(
 388                        this.Vertex.ToString(CultureInfo.InvariantCulture),
 389                        "//",
 390                        this.Normal.ToString(CultureInfo.InvariantCulture));
 91                }
 92                else
 93                {
 394                    return string.Concat(
 395                        this.Vertex.ToString(CultureInfo.InvariantCulture),
 396                        "/",
 397                        this.Texture.ToString(CultureInfo.InvariantCulture),
 398                        "/",
 399                        this.Normal.ToString(CultureInfo.InvariantCulture));
 100                }
 101            }
 102        }
 103
 104        public static bool operator ==(ObjTriplet left, ObjTriplet right)
 105        {
 0106            return left.Equals(right);
 107        }
 108
 109        public static bool operator !=(ObjTriplet left, ObjTriplet right)
 110        {
 0111            return !(left == right);
 112        }
 113    }
 114}
 115