< Summary

Class:Itinero.Network.TurnCosts.OrderCoder
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/TurnCosts/OrderCoder.cs
Covered lines:33
Uncovered lines:6
Coverable lines:39
Total lines:61
Line coverage:84.6% (33 of 39)
Covered branches:16
Total branches:18
Branch coverage:88.8% (16 of 18)
Tag:263_26948838820

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
SetTailHeadOrder(...)83.33%1270%
GetTailHeadOrder(...)100%6100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Network/TurnCosts/OrderCoder.cs

#LineLine coverage
 1using System;
 2
 3namespace Itinero.Network.TurnCosts;
 4
 5internal static class OrderCoder
 6{
 7    internal const int MaxOrderHeadTail = 14;
 8
 9    public static void SetTailHeadOrder(this byte[] data, long i, byte? tail, byte? head)
 5766910    {
 5766911        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 012        {
 013            throw new ArgumentOutOfRangeException(nameof(tail),
 014                $"Maximum order exceeded.");
 15        }
 16
 5766917        if (head.HasValue && head.Value > MaxOrderHeadTail)
 018        {
 019            throw new ArgumentOutOfRangeException(nameof(head),
 020                $"Maximum order exceeded.");
 21        }
 22
 5766923        var d = 0;
 5766924        if (tail.HasValue)
 239025        {
 239026            d = tail.Value + 1;
 239027        }
 28
 5766929        if (head.HasValue)
 243930        {
 243931            d += (head.Value + 1) * 16;
 243932        }
 33
 5766934        data[(int)i] = (byte)d;
 5766935    }
 36
 37    public static void GetTailHeadOrder(this byte[] data, long i, ref byte? tail, ref byte? head)
 647121738    {
 647121739        tail = null;
 647121740        head = null;
 41
 647121742        var d = data[(int)i];
 647121743        if (d == 0)
 552754044        {
 552754045            return;
 46        }
 47
 94367748        tail = null;
 94367749        var t = d % 16;
 94367750        if (t > 0)
 50839251        {
 50839252            tail = (byte)(t - 1);
 50839253        }
 54
 94367755        var h = d / 16;
 94367756        if (h > 0)
 50785957        {
 50785958            head = (byte)(h - 1);
 50785959        }
 647121760    }
 61}