From 535d4e3ba6d45541bb64c1e9150f04645bc7a065 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 14 Nov 2023 01:42:38 -0500 Subject: [PATCH] Add some span-array overload comparison tests --- tests/Tests/SkiaSharp/SKColorTest.cs | 24 ++++++++++++++++++++++++ tests/Tests/SkiaSharp/SKPathTest.cs | 15 +++++++++++++++ tests/Tests/SkiaSharp/SKTypefaceTest.cs | 16 +++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/Tests/SkiaSharp/SKColorTest.cs b/tests/Tests/SkiaSharp/SKColorTest.cs index e738a3161f..40b1f6b3f5 100644 --- a/tests/Tests/SkiaSharp/SKColorTest.cs +++ b/tests/Tests/SkiaSharp/SKColorTest.cs @@ -268,5 +268,29 @@ public void CanUnPreultiplyArrays() Assert.Equal(colors, upm); } + + [SkippableFact] + public void PreMultiplySpanMatchesArray() + { + var colors = new SKColor[] { 0x33008200, 0x33008200, 0x33008200, 0x33008200, 0x33008200 }; + + var pm1 = SKPMColor.PreMultiply(colors); + var pm2 = new SKPMColor[colors.Length]; + SKPMColor.PreMultiply(pm2, colors); + + Assert.Equal(pm1, pm2); + } + + [SkippableFact] + public void UnPreMultiplySpanMatchesArray() + { + var pmcolors = new SKPMColor[] { 0x33001A00, 0x33001A00, 0x33001A00, 0x33001A00, 0x33001A00 }; + + var upm1 = SKPMColor.UnPreMultiply(pmcolors); + var upm2 = new SKColor[pmcolors.Length]; + SKPMColor.UnPreMultiply(upm2, pmcolors); + + Assert.Equal(upm1, upm2); + } } } diff --git a/tests/Tests/SkiaSharp/SKPathTest.cs b/tests/Tests/SkiaSharp/SKPathTest.cs index 8b0fee109c..5dbcea47b1 100644 --- a/tests/Tests/SkiaSharp/SKPathTest.cs +++ b/tests/Tests/SkiaSharp/SKPathTest.cs @@ -397,6 +397,21 @@ public void OvalPathIsOval() } } + [SkippableFact] + public void TryGetLineMatchesGetLine() + { + using (var path = new SKPath()) + { + path.LineTo(new SKPoint(100, 100)); + + var getLine = path.GetLine(); + var tryGetLine = new SKPoint[2]; + path.TryGetLine(tryGetLine); + + Assert.Equal(getLine, tryGetLine); + } + } + [SkippableFact] public void TrimPathEffectWorksInverted() { diff --git a/tests/Tests/SkiaSharp/SKTypefaceTest.cs b/tests/Tests/SkiaSharp/SKTypefaceTest.cs index 18978e0a10..b322e6511e 100644 --- a/tests/Tests/SkiaSharp/SKTypefaceTest.cs +++ b/tests/Tests/SkiaSharp/SKTypefaceTest.cs @@ -495,7 +495,7 @@ public unsafe void FromFamilyReturnsSameObject() public unsafe void FontStyleIsNotTheSame() { var tf = SKTypeface.FromFamilyName(DefaultFontFamily); - + var fs1 = tf.FontStyle; var fs2 = tf.FontStyle; @@ -556,5 +556,19 @@ static IntPtr DoWork() return tf1.Handle; } } + + [SkippableFact] + public void GetKerningPairAdjustmentsSpanMatchesArray() + { + using var tf = SKTypeface.FromFamilyName(DefaultFontFamily); + + var glyphs = new ushort[] { 54, 78, 76, 68, 54, 75, 68, 85, 83 }; + + var adjustments1 = tf.GetKerningPairAdjustments(glyphs); + var adjustments2 = new int[glyphs.Length]; + tf.GetKerningPairAdjustments(adjustments2, glyphs); + + Assert.Equal(adjustments1, adjustments2); + } } }