Esempio n. 1
0
        private unsafe static void ToStringUInt64()
        {
            int size = Unsafe.SizeOf <Vector256 <UInt64> >() / sizeof(UInt64);

            UInt64[] values = new UInt64[size];

            for (int i = 0; i < size; i++)
            {
                values[i] = TestLibrary.Generator.GetUInt64();
            }

            Vector256 <UInt64> vector = Vector256.Create(values[0], values[1], values[2], values[3]);
            string             actual = vector.ToString();

            string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>';

            bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal);

            if (!succeeded)
            {
                TestLibrary.TestFramework.LogInformation($"Vector256UInt64ToString: Vector256<UInt64>.ToString() returned an unexpected result.");
                TestLibrary.TestFramework.LogInformation($"Expected: {expected}");
                TestLibrary.TestFramework.LogInformation($"Actual: {actual}");
                TestLibrary.TestFramework.LogInformation(string.Empty);

                throw new Exception("One or more scenarios did not complete as expected.");
            }
        }
Esempio n. 2
0
        public void UInt64ArrayTest()
        {
            var array = new UInt64[] { 0, 1 };
            var table = this.fixture.Execute(array);
            var ids   = table.AsEnumerable().Select(x => x.Field <decimal>("Id")).ToArray();

            Assert.Equal(array.Select(x => (decimal)x).ToArray(), ids);
        }
        public void UInt64ArrayTest()
        {
            var array            = new UInt64[] { 0, 1 };
            var arrayXmlToCursor = new ArrayXmlToCursor(array);
            var table            = GetDataTable(arrayXmlToCursor);
            var ids = table.AsEnumerable().Select(x => x.Field <decimal>("Id")).ToArray();

            CollectionAssert.AreEqual(array.Select(x => (decimal)x).ToArray(), ids);
        }
Esempio n. 4
0
        public void FillUInt64Array_ShouldProduceDesiredResults_ForBoundedInvocation()
        {
            // Arrange.
            var arrayLength = 180;
            var floor       = 100000;
            var ceiling     = 300000;
            var array       = new UInt64[arrayLength];

            using (var randomNumberGenerator = RandomNumberGenerator.Create())
            {
                // Act.
                randomNumberGenerator.FillUInt64Array(array, (UInt64)floor, (UInt64)ceiling);

                // Assert.
                array.Length.Should().Be(arrayLength);
                array.Select(value => Convert.ToDouble(value)).Average().Should().BeGreaterOrEqualTo(150000).And.BeLessOrEqualTo(250000);
            }
        }