< 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:251_23667616543

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)
 5295110    {
 5295111        if (tail.HasValue && tail.Value > MaxOrderHeadTail)
 012        {
 013            throw new ArgumentOutOfRangeException(nameof(tail),
 014                $"Maximum order exceeded.");
 15        }
 16
 5295117        if (head.HasValue && head.Value > MaxOrderHeadTail)
 018        {
 019            throw new ArgumentOutOfRangeException(nameof(head),
 020                $"Maximum order exceeded.");
 21        }
 22
 5295123        var d = 0;
 5295124        if (tail.HasValue)
 53525        {
 53526            d = tail.Value + 1;
 53527        }
 28
 5295129        if (head.HasValue)
 52030        {
 52031            d += (head.Value + 1) * 16;
 52032        }
 33
 5295134        data[(int)i] = (byte)d;
 5295135    }
 36
 37    public static void GetTailHeadOrder(this byte[] data, long i, ref byte? tail, ref byte? head)
 654302438    {
 654302439        tail = null;
 654302440        head = null;
 41
 654302442        var d = data[(int)i];
 654302443        if (d == 0)
 645182044        {
 645182045            return;
 46        }
 47
 9120448        tail = null;
 9120449        var t = d % 16;
 9120450        if (t > 0)
 4604951        {
 4604952            tail = (byte)(t - 1);
 4604953        }
 54
 9120455        var h = d / 16;
 9120456        if (h > 0)
 4545657        {
 4545658            head = (byte)(h - 1);
 4545659        }
 654302460    }
 61}