Ejemplo n.º 1
0
        public void Test_ComplexKey()
        {
            var value = new Complex(-100500e-10, 100500e10);

            var key = FitsKey.Create("TEST", value, type: KeyType.Free);
            var str = key.ToString();

            var buff = Encoding.ASCII.GetBytes(str);

            var compKey1 = FitsKey.ParseRawData(buff);

            key  = FitsKey.Create("TEST", value);
            str  = key.ToString();
            buff = Encoding.ASCII.GetBytes(str);

            var compKey2 = FitsKey.ParseRawData(buff);

            Assert.That(compKey1.Equals(compKey2));
        }
Ejemplo n.º 2
0
        public void TestThroughBlocks <T>(object?__ = null) where T : unmanaged, IComparable <T>, IEquatable <T>
        {
            const int n    = 248;
            const int m    = 496;
            var       data = ArrayPool <T> .Shared.Rent(n *m);

            var converter = ConverterProvider.GetImageConverter <T>();

            try
            {
                for (var i = 0; i < n; i++)
                {
                    for (var j = 0; j < m; j++)
                    {
                        data[m * i + j] = Internal.UnsafeNumerics.MathOps.DangerousCast <double, T>(Math.Sqrt(
                                                                                                        (i - 50) * (i - 50) * (1 + Math.Pow(Math.Sin(Math.PI * (i + 23) * 10 / n), 2))
                                                                                                        + (j / 2.0 - 100) * (j / 2.0 - 100) * (1.1 + Math.Sin(Math.PI * j * 10 / m))));
                    }
                }

                data[247 * 496 + 495] = default;
                var src = Image.Create <T>(data.AsSpan(..(n * m)), n, m);

                var key   = FitsKey.Create("DEBUG", "Debug key", "With a comment");
                var block = converter.ConvertToBlock(src, key);

                var rec = converter.ConvertFromBlock(block, out var keys);

                Assert.AreEqual(src, rec);
                Assert.AreEqual(data[247 * 496 + 495], src[247, 495]);
                Assert.AreEqual(data[247 * 496 + 495], rec[247, 495]);
                Assert.That(keys, Has.One.Items);
                Assert.That(keys, Contains.Item(key));
            }
            finally
            {
                ArrayPool <T> .Shared.Return(data);
            }
        }