mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Extensions: ArraySegment.ToHexString for convenience
This commit is contained in:
parent
9525a4649d
commit
27398721a2
@ -6,6 +6,9 @@ namespace Mirror
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string ToHexString(this ArraySegment<byte> segment) =>
|
||||
BitConverter.ToString(segment.Array, segment.Offset, segment.Count);
|
||||
|
||||
// string.GetHashCode is not guaranteed to be the same on all machines, but
|
||||
// we need one that is the same on all machines. simple and stupid:
|
||||
public static int GetStableHashCode(this string text)
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -17,10 +18,17 @@ public void GetStableHashHode()
|
||||
[Test]
|
||||
public void CopyToList()
|
||||
{
|
||||
List<int> source = new List<int>{1, 2, 3};
|
||||
List<int> source = new List<int> {1, 2, 3};
|
||||
List<int> destination = new List<int>();
|
||||
source.CopyTo(destination);
|
||||
Assert.That(destination.SequenceEqual(source), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArraySegment_ToHexString()
|
||||
{
|
||||
ArraySegment<byte> segment = new ArraySegment<byte>(new byte[] {0xAA, 0xBB, 0xCC});
|
||||
Assert.That(segment.ToHexString(), Is.EqualTo("AA-BB-CC"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user