From 6867f06b48a1187410cb8d120f2dd592daa5a4ed Mon Sep 17 00:00:00 2001 From: hzhang Date: Sat, 30 Nov 2024 20:12:13 +0000 Subject: [PATCH] Amend --- tests/BaseTest.cs | 17 +++++++++++++++++ tests/GlobalSetUp.cs | 15 +++++++++++++++ tests/RandomFixTest.cs | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/BaseTest.cs create mode 100644 tests/GlobalSetUp.cs create mode 100644 tests/RandomFixTest.cs diff --git a/tests/BaseTest.cs b/tests/BaseTest.cs new file mode 100644 index 0000000..49f399b --- /dev/null +++ b/tests/BaseTest.cs @@ -0,0 +1,17 @@ +using System; +using Skeleton.Algebra; + +namespace Skeleton.Test; + +public class BaseTest +{ + protected static int Seed = 517515; + + protected static class Theory + { + public static readonly Action.OnField.FMatrix> OnFail + = x => Console.WriteLine(x.CSharpRepresentation); + } + + //protected static Action TheoryOnFail() = x => Console.WriteLine(); +} \ No newline at end of file diff --git a/tests/GlobalSetUp.cs b/tests/GlobalSetUp.cs new file mode 100644 index 0000000..4cb35df --- /dev/null +++ b/tests/GlobalSetUp.cs @@ -0,0 +1,15 @@ +using Skeleton.Utils.RandomEngines; + +namespace Skeleton.Test; +[SetUpFixture] +public class GlobalSetUp +{ + private const int RandomSeed = 33659722; + + /*[SetUp] + public void SetUp() + { + RandomSource.SetSeed(RandomSeed); + }*/ + +} \ No newline at end of file diff --git a/tests/RandomFixTest.cs b/tests/RandomFixTest.cs new file mode 100644 index 0000000..cad019d --- /dev/null +++ b/tests/RandomFixTest.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Skeleton.Samples; +using Skeleton.Utils.Helpers; +using Skeleton.Utils.RandomEngines; + +namespace Skeleton.Test; + +public class RandomFixTest : BaseTest +{ + [DatapointSource] private static readonly IEnumerable x = + 40.WithSeed(771202).ScaleSamples(-1, 1).LieSU3LogSU3Samples().ToArray(); + [Test] + public static void DatapointTest() + { + Assert.AreEqual(x.Count(), 36); + + } + + [Test] + public static void Test(){ + Console.WriteLine(RandomSource.Rnd.Value.NextDouble()); + Console.WriteLine(RandomSource.Rnd.Value.NextDouble()); + Console.WriteLine(RandomSource.Rnd.Value.NextDouble()); + } + + [Test] + public static void SampleTest() + { + RandomSource.SetSeed(22222); + LieSU3[] a = 40.ScaleSamples(-1, 1).LieSU3LogSU3Samples().ToArray(); + RandomSource.SetSeed(22222); + LieSU3[] b = 40.ScaleSamples(-1, 1).LieSU3LogSU3Samples().ToArray(); + Assert.AreEqual(a.Length, b.Length); + Console.WriteLine(a.Length); + } +} \ No newline at end of file