Skip to content

Commit

Permalink
Add some span-array overload comparison tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Nov 6, 2024
1 parent 47926c8 commit 535d4e3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests/Tests/SkiaSharp/SKColorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
15 changes: 15 additions & 0 deletions tests/Tests/SkiaSharp/SKPathTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
16 changes: 15 additions & 1 deletion tests/Tests/SkiaSharp/SKTypefaceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 535d4e3

Please sign in to comment.