Files
Chronos/tests/Chronos.Core.Tests/Motion/PlaneOpsTests.cs
T
Alby96andClaude Opus 5.5 5f27a86406
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
refactor!: rename Titano to Chronos and move CI and releases to Gitea
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout. The release cross-compiles the Windows programs, checks their
  icon, version and DPI manifest, packs installers and zips, publishes the
  Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only
  tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow) and
  pe-check.

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 11:34:48 +02:00

98 lines
3.5 KiB
C#

using Chronos.Core.Motion;
using Chronos.Testing;
namespace Chronos.Core.Tests.Motion;
public sealed class PlaneOpsTests
{
private const int Width = 37;
private const int Height = 23;
[Theory]
[Case(1)]
[Case(2)]
public void MedianFilterMatchesBruteForce(int radius)
{
var source = RandomPlane(seed: radius);
var output = new float[source.Length];
PlaneOps.MedianFilter(source, output, Width, Height, radius);
for (var y = 0; y < Height; y++)
{
for (var x = 0; x < Width; x++)
{
var window = new List<float>();
for (var dy = -radius; dy <= radius; dy++)
for (var dx = -radius; dx <= radius; dx++)
window.Add(source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)]);
window.Sort();
Assert.Equal(window[window.Count / 2], output[y * Width + x]);
}
}
}
[Theory]
[Case(1)]
[Case(3)]
public void BoxFilterMatchesBruteForce(int radius)
{
var source = RandomPlane(seed: 10 + radius);
var output = new float[source.Length];
PlaneOps.BoxFilter(source, output, new float[source.Length], Width, Height, radius);
for (var y = 0; y < Height; y++)
{
for (var x = 0; x < Width; x++)
{
double sum = 0;
for (var dy = -radius; dy <= radius; dy++)
for (var dx = -radius; dx <= radius; dx++)
sum += source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)];
Assert.Approximately(sum / ((2 * radius + 1) * (2 * radius + 1)), output[y * Width + x], 1e-5);
}
}
}
[Test]
public void BinomialBlurKeepsConstantsAndMean()
{
var flat = new float[Width * Height];
flat.AsSpan().Fill(0.7f);
PlaneOps.Binomial5(flat, flat, new float[flat.Length], Width, Height);
Assert.True(flat.All(v => double.Abs(v - 0.7) < 1e-6));
var impulse = new float[Width * Height];
impulse[11 * Width + 17] = 1;
var blurred = new float[impulse.Length];
PlaneOps.Binomial5(impulse, blurred, new float[impulse.Length], Width, Height);
Assert.Approximately(1, blurred.Sum(v => (double)v), 1e-6);
Assert.Approximately(36.0 / 256, blurred[11 * Width + 17], 1e-7);
}
[Test]
public void SelectionAndMedian()
{
var values = new float[] { 5, 1, 4, 2, 3 };
Assert.Equal(3f, PlaneOps.Median(values));
Assert.Equal(2.5f, PlaneOps.Median(new float[] { 4, 1, 3, 2 }));
Assert.Equal(1f, PlaneOps.Select(new float[] { 3, 1, 2 }, 0));
Assert.Equal(7f, PlaneOps.Median(new float[] { 7 }));
}
[Test]
public void BilinearIsExactAtPixelCentresAndClamps()
{
var plane = RandomPlane(seed: 3);
Assert.Equal(plane[5 * Width + 9], PlaneOps.Bilinear(plane, Width, Height, 9, 5));
Assert.Equal(plane[0], PlaneOps.Bilinear(plane, Width, Height, -3, -8));
var mid = 0.5f * (plane[5 * Width + 9] + plane[5 * Width + 10]);
Assert.Approximately(mid, PlaneOps.Bilinear(plane, Width, Height, 9.5f, 5), 1e-6);
}
private static float[] RandomPlane(int seed)
{
var random = new Random(seed);
var plane = new float[Width * Height];
for (var i = 0; i < plane.Length; i++) plane[i] = (float)random.NextDouble();
return plane;
}
}