< 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:267_28791001112

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)
 5777610    {
 5777611        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 012        {
 013            throw new ArgumentOutOfRangeException(nameof(tail),
 014                $"Maximum order exceeded.");
 15        }
 16
 5777617        if (head.HasValue && head.Value > MaxOrderHeadTail)
 018        {
 019            throw new ArgumentOutOfRangeException(nameof(head),
 020                $"Maximum order exceeded.");
 21        }
 22
 5777623        var d = 0;
 5777624        if (tail.HasValue)
 239025        {
 239026            d = tail.Value + 1;
 239027        }
 28
 5777629        if (head.HasValue)
 243930        {
 243931            d += (head.Value + 1) * 16;
 243932        }
 33
 5777634        data[(int)i] = (byte)d;
 5777635    }
 36
 37    public static void GetTailHeadOrder(this byte[] data, long i, ref byte? tail, ref byte? head)
 647222438    {
 647222439        tail = null;
 647222440        head = null;
 41
 647222442        var d = data[(int)i];
 647222443        if (d == 0)
 552854744        {
 552854745            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        }
 647222460    }
 61}