tests
This commit is contained in:
43
Tests/Cabrito/ConsoleTests.cs
Normal file
43
Tests/Cabrito/ConsoleTests.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using NUnit.Framework;
|
||||
using Cabrito;
|
||||
using Console = Cabrito.Console;
|
||||
|
||||
namespace GoakeTests.ConsoleTests
|
||||
{
|
||||
public class ConsoleTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Console.Init();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void CleanUp()
|
||||
{
|
||||
Console.Destroy();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test1()
|
||||
{
|
||||
string testPrint = "Hello world!";
|
||||
|
||||
Console.OnPrint += delegate(string s) { Assert.True(s == testPrint); };
|
||||
|
||||
Console.Print(testPrint);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test2()
|
||||
{
|
||||
string testPrint = "Hello world2!";
|
||||
|
||||
Console.OnPrint += delegate(string s) { Assert.True(s == testPrint); };
|
||||
|
||||
Console.Print(testPrint);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
20
Tests/GoakeTests.csproj
Normal file
20
Tests/GoakeTests.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<TargetFrameworks>net452;net462;net472;net48;net5.0;net5.0-windows;net6.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="NUnit" Version="3.13.1" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Source\Game.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
74
Tests/MapParser/MapParserTests.cs
Normal file
74
Tests/MapParser/MapParserTests.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using Cabrito;
|
||||
using FlaxEngine;
|
||||
using Game;
|
||||
|
||||
namespace GoakeTests.MapParser
|
||||
{
|
||||
public class MapParserTests
|
||||
{
|
||||
private byte[] aerowalkBytes;
|
||||
private MapEntity aerowalkRoot;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
aerowalkBytes = File.ReadAllBytes(@"C:\dev\Goake\maps\aerowalk\aerowalk.map");
|
||||
aerowalkRoot = Game.MapParser.Parse(aerowalkBytes);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void CleanUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Perf_LoadAerowalk()
|
||||
{
|
||||
List<Game.MapEntity> mapEntities = new List<Game.MapEntity>(100);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var root = Game.MapParser.Parse(aerowalkBytes);
|
||||
mapEntities.Add(root);
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
||||
var elapsedMs = sw.Elapsed.TotalMilliseconds;
|
||||
TestContext.Out.WriteLine("Map parsing time: " + elapsedMs/100 + "ms");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Perf_TriangulateAerowalk()
|
||||
{
|
||||
// warmup?
|
||||
//var roott = Game.MapParser.Parse(aerowalkBytes);
|
||||
|
||||
List<Game.MapEntity> mapEntities = new List<Game.MapEntity>(100);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
foreach (var ent in aerowalkRoot.entities)
|
||||
foreach (var brush in ent.brushes)
|
||||
{
|
||||
Q3MapImporter.TriangulateBrush3(brush, out Vector3[] verts);
|
||||
Assert.IsTrue(verts.Length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
||||
var elapsedMs = sw.Elapsed.TotalMilliseconds;
|
||||
TestContext.Out.WriteLine("Triangulation time: " + elapsedMs + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user