Skip to content

Commit ec93cb3

Browse files
committed
Add some span-array overload comparison tests
1 parent 98cf75c commit ec93cb3

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

tests/Tests/SkiaSharp/SKColorTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,29 @@ public void CanUnPreultiplyArrays()
268268

269269
Assert.Equal(colors, upm);
270270
}
271+
272+
[SkippableFact]
273+
public void PreMultiplySpanMatchesArray()
274+
{
275+
var colors = new SKColor[] { 0x33008200, 0x33008200, 0x33008200, 0x33008200, 0x33008200 };
276+
277+
var pm1 = SKPMColor.PreMultiply(colors);
278+
var pm2 = new SKPMColor[colors.Length];
279+
SKPMColor.PreMultiply(pm2, colors);
280+
281+
Assert.Equal(pm1, pm2);
282+
}
283+
284+
[SkippableFact]
285+
public void UnPreMultiplySpanMatchesArray()
286+
{
287+
var pmcolors = new SKPMColor[] { 0x33001A00, 0x33001A00, 0x33001A00, 0x33001A00, 0x33001A00 };
288+
289+
var upm1 = SKPMColor.UnPreMultiply(pmcolors);
290+
var upm2 = new SKColor[pmcolors.Length];
291+
SKPMColor.UnPreMultiply(upm2, pmcolors);
292+
293+
Assert.Equal(upm1, upm2);
294+
}
271295
}
272296
}

tests/Tests/SkiaSharp/SKPathTest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,21 @@ public void OvalPathIsOval()
397397
}
398398
}
399399

400+
[SkippableFact]
401+
public void TryGetLineMatchesGetLine()
402+
{
403+
using (var path = new SKPath())
404+
{
405+
path.LineTo(new SKPoint(100, 100));
406+
407+
var getLine = path.GetLine();
408+
var tryGetLine = new SKPoint[2];
409+
path.TryGetLine(tryGetLine);
410+
411+
Assert.Equal(getLine, tryGetLine);
412+
}
413+
}
414+
400415
[SkippableFact]
401416
public void TrimPathEffectWorksInverted()
402417
{

tests/Tests/SkiaSharp/SKTypefaceTest.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public unsafe void FromFamilyReturnsSameObject()
495495
public unsafe void FontStyleIsNotTheSame()
496496
{
497497
var tf = SKTypeface.FromFamilyName(DefaultFontFamily);
498-
498+
499499
var fs1 = tf.FontStyle;
500500
var fs2 = tf.FontStyle;
501501

@@ -556,5 +556,19 @@ static IntPtr DoWork()
556556
return tf1.Handle;
557557
}
558558
}
559+
560+
[SkippableFact]
561+
public void GetKerningPairAdjustmentsSpanMatchesArray()
562+
{
563+
using var tf = SKTypeface.FromFamilyName(DefaultFontFamily);
564+
565+
var glyphs = new ushort[] { 54, 78, 76, 68, 54, 75, 68, 85, 83 };
566+
567+
var adjustments1 = tf.GetKerningPairAdjustments(glyphs);
568+
var adjustments2 = new int[glyphs.Length];
569+
tf.GetKerningPairAdjustments(adjustments2, glyphs);
570+
571+
Assert.Equal(adjustments1, adjustments2);
572+
}
559573
}
560574
}

0 commit comments

Comments
 (0)