Move tests to this repository.
This commit is contained in:
parent
ab1cfe9243
commit
1d9f7d2ae6
72
Quik.StbImage.Tests/LoadFont.cs
Normal file
72
Quik.StbImage.Tests/LoadFont.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Quik.Stb;
|
||||
|
||||
namespace Quik.Stb
|
||||
{
|
||||
[TestClass]
|
||||
[TestCategory("Load Font")]
|
||||
public class LoadFont
|
||||
{
|
||||
StbFont? font;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
using (Stream? str = GetType().Assembly.GetManifestResourceStream("Quik.Stb.Tests.res.Varicka.ttf"))
|
||||
{
|
||||
Assert.IsNotNull(str, "Test font file not packed.");
|
||||
font = StbFont.Load(str);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void Deinitialize()
|
||||
{
|
||||
font?.Dispose();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AscendIsValid()
|
||||
{
|
||||
Assert.AreNotEqual(-1, font!.Ascend);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DescendIsValid()
|
||||
{
|
||||
Assert.AreNotEqual(-1, font!.Descend);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void VLineGapIsValid()
|
||||
{
|
||||
Assert.AreNotEqual(-1, font!.VerticalLineGap);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void BBoxIsValid()
|
||||
{
|
||||
Assert.AreNotEqual(default, font!.BoundingBox);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void KerningTableIsValid()
|
||||
{
|
||||
Assert.IsNotNull(font!.KerningTable);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetGlyphsForAscii()
|
||||
{
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
int glyph = font!.FindGlyphIndex(i);
|
||||
|
||||
Assert.AreNotEqual(-1, glyph);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
Quik.StbImage.Tests/LoadImage.cs
Normal file
45
Quik.StbImage.Tests/LoadImage.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.IO;
|
||||
|
||||
namespace Quik.Stb.Tests
|
||||
{
|
||||
[TestClass]
|
||||
[TestCategory("Load Image")]
|
||||
public class LoadImage
|
||||
{
|
||||
[TestMethod("Set Global Options")]
|
||||
public void SetGlobals()
|
||||
{
|
||||
Quik.Stb.StbImage.FlipVerticallyOnLoad = true;
|
||||
Quik.Stb.StbImage.UnpremultiplyOnLoad = true;
|
||||
}
|
||||
|
||||
private Stream GetImage(string path)
|
||||
{
|
||||
Stream? str = GetType().Assembly.GetManifestResourceStream(path);
|
||||
Assert.IsNotNull(str, $"Could not find test image resource {path}.");
|
||||
return str;
|
||||
}
|
||||
|
||||
private unsafe void TestImage(string path, int width, int height)
|
||||
{
|
||||
StbImage image = StbImage.Load(GetImage(path));
|
||||
|
||||
Assert.IsNotNull(image);
|
||||
|
||||
Assert.AreEqual(width, image.Width, "Width does not match.");
|
||||
Assert.AreEqual(height, image.Height, "Height does not match.");
|
||||
|
||||
image.Dispose();
|
||||
}
|
||||
|
||||
const int WIDTH = 768;
|
||||
const int HEIGHT = 512;
|
||||
|
||||
[TestMethod("Load a single frame GIF")]
|
||||
public unsafe void LoadGif() => TestImage("Quik.Stb.Tests.res.kodim.kodim23.gif", WIDTH, HEIGHT);
|
||||
[TestMethod("Load a JPEG")]
|
||||
public unsafe void LoadJpg() => TestImage("Quik.Stb.Tests.res.kodim.kodim23.jpg", WIDTH, HEIGHT);
|
||||
[TestMethod("Load a PNG")] public unsafe void LoadPng() => TestImage("Quik.Stb.Tests.res.kodim.kodim23.png", WIDTH, HEIGHT);
|
||||
}
|
||||
}
|
32
Quik.StbImage.Tests/Quik.StbImage.Tests.csproj
Normal file
32
Quik.StbImage.Tests/Quik.StbImage.Tests.csproj
Normal file
@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="res/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="LoadFont.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!--<ProjectReference Include="..\..\Quik.StbTrueType\Quik.StbTrueType.csproj" />-->
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
BIN
Quik.StbImage.Tests/res/Varicka.ttf
Normal file
BIN
Quik.StbImage.Tests/res/Varicka.ttf
Normal file
Binary file not shown.
12
Quik.StbImage.Tests/res/Varicka.txt
Normal file
12
Quik.StbImage.Tests/res/Varicka.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Varicka (Truetype and Opentype with no OT features)
|
||||
|
||||
Based on 'Varick', from "Decorative Condensed Alphabets", by Dan Solo, Page 94.
|
||||
|
||||
Letter spacing is set to balance the letterforms themselves; the space between most adjacent letters is identical to the horizontal space inside such letters as 'O' and 'H'. Kerning is supplied as needed for certain letter combinations, particularly those that have a letter with a projection on the left, such as A, E, F, H, K, P, and R.
|
||||
|
||||
Varicka is superficially similar to Red Rooster's Triple Gothic Condensed, but the Solo book's font has different features and some very different letterforms.
|
||||
|
||||
This font is free and available for all use, personal and commercial, with no restrictions.
|
||||
|
||||
Character
|
||||
February 13, 2010
|
3
Quik.StbImage.Tests/res/kodim/LICENSE.md
Normal file
3
Quik.StbImage.Tests/res/kodim/LICENSE.md
Normal file
@ -0,0 +1,3 @@
|
||||
Kodak Image Suite Test Images owned by Kodak. Image 23 was taken by Steve Kelly.
|
||||
The original image file kodim23.png and its derivatives are only included for
|
||||
test purposes only and should not be redistributed with the software.
|
BIN
Quik.StbImage.Tests/res/kodim/kodim23.gif
Normal file
BIN
Quik.StbImage.Tests/res/kodim/kodim23.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 156 KiB |
BIN
Quik.StbImage.Tests/res/kodim/kodim23.jpg
Normal file
BIN
Quik.StbImage.Tests/res/kodim/kodim23.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
BIN
Quik.StbImage.Tests/res/kodim/kodim23.png
Normal file
BIN
Quik.StbImage.Tests/res/kodim/kodim23.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 544 KiB |
BIN
Quik.StbImage.Tests/res/kodim/kodim23.tiff
Normal file
BIN
Quik.StbImage.Tests/res/kodim/kodim23.tiff
Normal file
Binary file not shown.
BIN
Quik.StbImage.Tests/res/kodim/kodim23.webp
Normal file
BIN
Quik.StbImage.Tests/res/kodim/kodim23.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quik.StbImage", "Quik.StbImage.csproj", "{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quik.StbImage.Tests", "Quik.StbImage.Tests\Quik.StbImage.Tests.csproj", "{6FC081AA-93EA-468C-8C23-C1D7AC459321}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6FC081AA-93EA-468C-8C23-C1D7AC459321}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6FC081AA-93EA-468C-8C23-C1D7AC459321}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6FC081AA-93EA-468C-8C23-C1D7AC459321}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6FC081AA-93EA-468C-8C23-C1D7AC459321}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user