Beispiel #1
0
        public void Test_Uuid80_Read_From_Bytes()
        {
            // test buffer with included padding
            byte[] buf      = { 0x55, 0x55, 0x55, 0x55, /* start */ 0x1E, 0x2D, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, /* stop */ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
            var    original = Uuid80.Parse("1E2D-01234567-89ABCDEF");

            (var hi, var lo) = original;
            Assume.That(hi, Is.EqualTo(0x1E2D));
            Assume.That(lo, Is.EqualTo(0x0123456789ABCDEF));

            // Slice
            Assert.That(Uuid80.Read(buf.AsSlice(4, 10)), Is.EqualTo(original));

            // byte[]
            Assert.That(Uuid80.Read(buf.AsSlice(4, 10).GetBytesOrEmpty()), Is.EqualTo(original));

#if ENABLE_SPAN
            // ReadOnlySpan<byte>
            Assert.That(Uuid80.Read(buf.AsSpan(4, 10)), Is.EqualTo(original));

            unsafe
            {
                fixed(byte *ptr = &buf[4])
                {
                    Assert.That(Uuid80.Read(ptr, 10), Is.EqualTo(original));
                    Assert.That(Uuid80.Read(USlice.FromUnmanagedPointer(ptr, 10)), Is.EqualTo(original));
                    Assert.That(Uuid80.Read(new ReadOnlySpan <byte>(ptr, 10)), Is.EqualTo(original));
                }
            }
#endif
        }
Beispiel #2
0
 public void Test_Uuid80_Empty()
 {
     Assert.That(Uuid80.Empty.ToString(), Is.EqualTo("0000-00000000-00000000"));
     Assert.That(Uuid80.Empty, Is.EqualTo(default(Uuid80)));
     Assert.That(Uuid80.Empty, Is.EqualTo(new Uuid80(0, 0UL)));
     Assert.That(Uuid80.Empty, Is.EqualTo(new Uuid80(0, 0U, 0U)));
     Assert.That(Uuid80.Empty, Is.EqualTo(new Uuid80(0, 0L)));
     Assert.That(Uuid80.Empty, Is.EqualTo(new Uuid80(0, 0, 0)));
     Assert.That(Uuid80.Empty, Is.EqualTo(Uuid80.Read(new byte[10])));
 }