< 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:224_14471318300

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)
 29611    {
 29612        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 013        {
 014            throw new ArgumentOutOfRangeException(nameof(tail),
 015                $"Maximum order exceeded.");
 16        }
 17
 29618        if (head.HasValue && head.Value > MaxOrderHeadTail)
 019        {
 020            throw new ArgumentOutOfRangeException(nameof(head),
 021                $"Maximum order exceeded.");
 22        }
 23
 29624        var d = 0;
 29625        if (tail.HasValue)
 1326        {
 1327            d = tail.Value + 1;
 1328        }
 29
 29630        if (head.HasValue)
 1331        {
 1332            d += (head.Value + 1) * 16;
 1333        }
 34
 29635        data[i] = (byte)d;
 29636    }
 37
 38    public static void GetTailHeadOrder(this ArrayBase<byte> data, long i, ref byte? tail, ref byte? head)
 113239    {
 113240        tail = null;
 113241        head = null;
 42
 113243        var d = data[i];
 113244        if (d == 0)
 104445        {
 104446            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        }
 113261    }
 62}