public void Test_MutableSliceComparer_Compare()
        {
            var cmp = MutableSlice.Comparer.Default;

            Assert.That(cmp, Is.Not.Null);

            Assert.That(cmp.Compare(MutableSlice.Nil, MutableSlice.Nil), Is.Zero);
            Assert.That(cmp.Compare(MutableSlice.Empty, MutableSlice.Empty), Is.Zero);
            Assert.That(cmp.Compare(MutableSlice.FromByte(42), MutableSlice.FromByte(42)), Is.Zero);

            //REVIEW: Inconsistency: compare(nil, empty) == 0, but Equals(nil, empty) == false
            Assert.That(cmp.Compare(MutableSlice.Nil, MutableSlice.Empty), Is.Zero, "Nil and Empty are considered similar regarding ordering");
            Assert.That(cmp.Compare(MutableSlice.Empty, MutableSlice.Nil), Is.Zero, "Nil and Empty are considered similar regarding ordering");

            Assert.That(cmp.Compare(MutableSlice.FromByte(42), MutableSlice.FromByte(77)), Is.LessThan(0));
            Assert.That(cmp.Compare(MutableSlice.FromByte(42), MutableSlice.FromByte(21)), Is.GreaterThan(0));
            Assert.That(cmp.Compare(MutableSlice.FromByte(42), MutableSlice.Empty), Is.GreaterThan(0));
            Assert.That(cmp.Compare(MutableSlice.FromByte(42), MutableSlice.Nil), Is.GreaterThan(0));

            Assert.That(cmp.Compare(MutableSlice.FromString("hello"), MutableSlice.FromString("world")), Is.LessThan(0));
            Assert.That(cmp.Compare(MutableSlice.FromString("world"), MutableSlice.FromString("hello")), Is.GreaterThan(0));

            Assert.That(cmp.Compare(MutableSlice.FromString("hell"), MutableSlice.FromString("hello")), Is.LessThan(0));
            Assert.That(cmp.Compare(MutableSlice.FromString("help"), MutableSlice.FromString("hello")), Is.GreaterThan(0));
        }
        public void Test_MutableSliceComparer_Equals()
        {
            var cmp = MutableSlice.Comparer.Default;

            Assert.That(cmp, Is.Not.Null);
            Assert.That(MutableSlice.Comparer.Default, Is.SameAs(cmp));

            Assert.That(cmp.Equals(MutableSlice.Nil, MutableSlice.Nil), Is.True);
            Assert.That(cmp.Equals(MutableSlice.Empty, MutableSlice.Empty), Is.True);
            Assert.That(cmp.Equals(MutableSlice.Nil, MutableSlice.Empty), Is.False);
            Assert.That(cmp.Equals(MutableSlice.Empty, MutableSlice.Nil), Is.False);

            Assert.That(cmp.Equals(MutableSlice.FromByte(42), MutableSlice.FromByte(42)), Is.True);
            Assert.That(cmp.Equals(MutableSlice.FromByte(42), new byte[] { 42 }.AsMutableSlice()), Is.True);
            Assert.That(cmp.Equals(MutableSlice.FromByte(42), MutableSlice.FromByte(77)), Is.False);

            Assert.That(cmp.Equals(new byte[] { 65, 66, 67 }.AsMutableSlice(), MutableSlice.FromString("ABC")), Is.True);
            Assert.That(cmp.Equals(new byte[] { 65, 66, 67, 68 }.AsMutableSlice(), MutableSlice.FromString("ABC")), Is.False);

            var buf1 = Encoding.ASCII.GetBytes("ABBAABA");
            var buf2 = Encoding.ASCII.GetBytes("ABBAABA");

            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 2), buf1.AsMutableSlice(0, 2)), Is.True);
            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 2), buf1.AsMutableSlice(0, 3)), Is.False);
            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 2), buf1.AsMutableSlice(4, 2)), Is.True);
            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 3), buf1.AsMutableSlice(4, 3)), Is.False);
            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 2), buf2.AsMutableSlice(4, 2)), Is.True);
            Assert.That(cmp.Equals(buf1.AsMutableSlice(0, 3), buf2.AsMutableSlice(4, 3)), Is.False);
        }