< 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:232_15462506344

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)
 31411    {
 31412        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 013        {
 014            throw new ArgumentOutOfRangeException(nameof(tail),
 015                $"Maximum order exceeded.");
 16        }
 17
 31418        if (head.HasValue && head.Value > MaxOrderHeadTail)
 019        {
 020            throw new ArgumentOutOfRangeException(nameof(head),
 021                $"Maximum order exceeded.");
 22        }
 23
 31424        var d = 0;
 31425        if (tail.HasValue)
 1326        {
 1327            d = tail.Value + 1;
 1328        }
 29
 31430        if (head.HasValue)
 1331        {
 1332            d += (head.Value + 1) * 16;
 1333        }
 34
 31435        data[i] = (byte)d;
 31436    }
 37
 38    public static void GetTailHeadOrder(this ArrayBase<byte> data, long i, ref byte? tail, ref byte? head)
 123139    {
 123140        tail = null;
 123141        head = null;
 42
 123143        var d = data[i];
 123144        if (d == 0)
 114345        {
 114346            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        }
 123161    }
 62}