Ejemplo n.º 1
0
 public void InsertTest2()
 {
     using ValueStringBuilder sb = ValueStringBuilder.CreateFrom("Hello".AsSpan());
     sb.Insert(5, " World".AsSpan());
     Assert.AreEqual(11, sb.Length);
     Assert.AreEqual("Hello World", sb.ToString());
 }
Ejemplo n.º 2
0
        public void ToStringAndDisposeTest()
        {
            ValueStringBuilder sb = ValueStringBuilder.CreateFrom("Hello World".AsSpan());

            Assert.AreEqual("Hello World", sb.ToStringAndDispose());
            Assert.True(sb.IsEmpty);
            Assert.AreEqual(0, sb.Length);
            Assert.AreEqual(0, sb.Capacity);
        }
Ejemplo n.º 3
0
        public void ClearTest()
        {
            using ValueStringBuilder sb = ValueStringBuilder.CreateFrom("Hello World".AsSpan());
            Assert.AreEqual("Hello World", sb.ToString());

            sb.Clear();

            Assert.AreEqual(0, sb.Length);
            Assert.AreEqual(string.Empty, sb.ToString());
        }
Ejemplo n.º 4
0
        public void GetEnumeratorTest()
        {
            using ValueStringBuilder sb = ValueStringBuilder.CreateFrom("Hello".AsSpan());

            var enumerator = sb.GetEnumerator();

            Assert.True(enumerator.MoveNext());
            Assert.AreEqual('H', enumerator.Current);

            Assert.True(enumerator.MoveNext());
            Assert.AreEqual('e', enumerator.Current);

            Assert.True(enumerator.MoveNext());
            Assert.AreEqual('l', enumerator.Current);

            Assert.True(enumerator.MoveNext());
            Assert.AreEqual('l', enumerator.Current);

            Assert.True(enumerator.MoveNext());
            Assert.AreEqual('o', enumerator.Current);

            Assert.False(enumerator.MoveNext());
        }