public void ShouldThrowInvalidOperationExceptionOnAddUtfWhenBufferIsShaped() { using (var buffer = new Buffer()) { buffer.AddUtf8(SimpleText); Font.Shape(buffer); Assert.Throws <InvalidOperationException>(() => { buffer.AddUtf8("A"); }); } }
public void ShouldAddUtfBySpan() { using (var buffer = new Buffer()) { var bytes = Encoding.UTF8.GetBytes("A").AsSpan(); buffer.AddUtf8(bytes); Assert.Equal(1, buffer.Length); var utf16 = "B".AsSpan(); buffer.AddUtf16(utf16); Assert.Equal(2, buffer.Length); bytes = Encoding.UTF32.GetBytes("C"); var utf32 = new int[] { bytes[0] }; buffer.AddUtf32(utf32); Assert.Equal(3, buffer.Length); } }
public void ShouldAddUtfByString() { using (var buffer = new Buffer()) { buffer.AddUtf8("A"); Assert.Equal(1, buffer.Length); buffer.AddUtf8("B"); Assert.Equal(2, buffer.Length); buffer.AddUtf8("C"); Assert.Equal(3, buffer.Length); } }
public void ShouldThrowInvalidOperationExceptionOnDeserializeGlyphsWhenBufferIsNonEmpty() { using (var buffer = new Buffer()) { buffer.AddUtf8("A"); Assert.Throws <InvalidOperationException>(() => { buffer.DeserializeGlyphs(SerializedSimpleText); }); } }
public void ShouldThrowInvalidOperationExceptionOnSerializeGlyphsWhenBufferIsUnShaped() { using (var buffer = new Buffer()) { buffer.AddUtf8("A"); Assert.Throws <InvalidOperationException>(() => { buffer.SerializeGlyphs(); }); } }
public void ShouldAppendBuffer() { using (var buffer = new Buffer()) using (var source = new Buffer()) { source.AddUtf8("123"); buffer.Append(source, 0, source.Length); } }
public void ShouldAppendBuffer() { using (var buffer = new Buffer()) using (var source = new Buffer()) { buffer.ContentType = ContentType.Unicode; source.AddUtf8("123"); buffer.Append(source, 0, source.Length); } }
public void ShouldClearContents() { using (var buffer = new Buffer()) { buffer.AddUtf8(SimpleText); Assert.Equal(SimpleText.Length, buffer.GlyphInfos.Length); buffer.ClearContents(); Assert.Empty(buffer.GlyphInfos); } }
public void ShouldHaveDefaultStateAfterReset() { using (var buffer = new Buffer()) { buffer.AddUtf8(SimpleText); buffer.Reset(); Assert.Equal(ContentType.Invalid, buffer.ContentType); Assert.Equal(0, buffer.Length); } }
public void ShouldReverseClusters() { using (var buffer = new Buffer()) { buffer.AddUtf8("12"); buffer.ReverseClusters(); Assert.Equal(50u, buffer.GlyphInfos[0].Codepoint); Assert.Equal(1u, buffer.GlyphInfos[0].Cluster); Assert.Equal(49u, buffer.GlyphInfos[1].Codepoint); Assert.Equal(0u, buffer.GlyphInfos[1].Cluster); } }
public void ShouldHaveCorrectContentType() { using (var buffer = new Buffer()) { Assert.Equal(ContentType.Invalid, buffer.ContentType); buffer.AddUtf8(SimpleText); Assert.Equal(ContentType.Unicode, buffer.ContentType); Font.Shape(buffer); Assert.Equal(ContentType.Glyphs, buffer.ContentType); } }
public void ShouldAddUtfBySpan() { using (var buffer = new Buffer()) { var utf8 = Encoding.UTF8.GetBytes("A").AsSpan(); buffer.AddUtf8(utf8); Assert.Equal(1, buffer.Length); var utf16 = "B".AsSpan(); buffer.AddUtf16(utf16); Assert.Equal(2, buffer.Length); var utf32 = new[] { char.ConvertToUtf32("C", 0) }; buffer.AddUtf32(utf32); Assert.Equal(3, buffer.Length); } }