< 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:62
Line coverage:84.6% (33 of 39)
Covered branches:16
Total branches:18
Branch coverage:88.8% (16 of 18)
Tag:238_19435726042

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;
 2using Reminiscence.Arrays;
 3
 4namespace Itinero.Network.TurnCosts;
 5
 6internal static class OrderCoder
 7{
 8    internal const int MaxOrderHeadTail = 14;
 9
 10    public static void SetTailHeadOrder(this ArrayBase<byte> data, long i, byte? tail, byte? head)
 33211    {
 33212        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 013        {
 014            throw new ArgumentOutOfRangeException(nameof(tail),
 015                $"Maximum order exceeded.");
 16        }
 17
 33218        if (head.HasValue && head.Value > MaxOrderHeadTail)
 019        {
 020            throw new ArgumentOutOfRangeException(nameof(head),
 021                $"Maximum order exceeded.");
 22        }
 23
 33224        var d = 0;
 33225        if (tail.HasValue)
 1326        {
 1327            d = tail.Value + 1;
 1328        }
 29
 33230        if (head.HasValue)
 1331        {
 1332            d += (head.Value + 1) * 16;
 1333        }
 34
 33235        data[i] = (byte)d;
 33236    }
 37
 38    public static void GetTailHeadOrder(this ArrayBase<byte> data, long i, ref byte? tail, ref byte? head)
 137439    {
 137440        tail = null;
 137441        head = null;
 42
 137443        var d = data[i];
 137444        if (d == 0)
 128645        {
 128646            return;
 47        }
 48
 8849        tail = null;
 8850        var t = d % 16;
 8851        if (t > 0)
 4352        {
 4353            tail = (byte)(t - 1);
 4354        }
 55
 8856        var h = d / 16;
 8857        if (h > 0)
 4758        {
 4759            head = (byte)(h - 1);
 4760        }
 137461    }
 62}