Пример #1
0
        public void SpanEqualsSpan()
        {
            var span1 = new Utf8ByteSpan("abc");
            var span2 = new Utf8ByteSpan("abc");

            Assert.True(span1.Equals(span2));

            var span3 = new Utf8ByteSpan(Encoding.UTF8.GetBytes("zzabc!"), 2, 3);

            Assert.True(span1.Equals(span3));

            var span4 = new Utf8ByteSpan("abd");

            Assert.False(span1.Equals(span4));
        }
Пример #2
0
        public void SpanEqualsStringWithMultiByteCharacters()
        {
            var s     = "olé";
            var bytes = Encoding.UTF8.GetBytes("zz" + s + "!");

            var span1 = new Utf8ByteSpan(s);

            Assert.True(span1.Equals(s));

            var span2 = new Utf8ByteSpan(bytes, 2, bytes.Length - 3);

            Assert.True(span2.Equals(s));

            var span3 = new Utf8ByteSpan("olè");

            Assert.False(span3.Equals(s));
        }