using RynthCore.Engine.Compatibility; namespace VendorRateTests; /// VendorTrade's profile rate check (VendorRatePolicy). See the csproj. internal static class Program { private static int _checks, _failed; private static int Main() { // A free storage vendor: BuyPrice 0, SellPrice 0. This is the case that used to turn trading off. Check(VendorRatePolicy.LooksSane(0f), "rate 0 (free storage vendor)"); Check(VendorRatePolicy.LooksSane(-0f), "rate -0 (compares equal to 0)"); // Ordinary vendors and promissory-note rates. foreach (float r in new[] { 0.001f, 0.1f, 0.5f, 0.75f, 1f, 1.15f, 2.5f, 10f, 999.9f }) Check(VendorRatePolicy.LooksSane(r), $"rate {r}"); // Misreads stay rejected. foreach (float r in new[] { -0.001f, -1f, float.NaN, float.PositiveInfinity, float.NegativeInfinity, VendorRatePolicy.MaxRate, 1e6f, float.MaxValue, float.MinValue }) Check(!VendorRatePolicy.LooksSane(r), $"rate {r} rejected"); Console.WriteLine(_failed == 0 ? $"PASS ({_checks} checks)" : $"FAIL ({_failed} of {_checks} checks failed)"); return _failed == 0 ? 0 : 1; } private static void Check(bool ok, string what) { _checks++; if (ok) { Console.WriteLine("ok " + what); return; } _failed++; Console.WriteLine("FAIL " + what); } }