Esempio n. 1
0
        public void CanReadAttribute_Array()
        {
            TestUtils.RunForAllVersions(version =>
            {
                // Arrange
                var filePath = TestUtils.PrepareTestFile(version, fileId => TestUtils.AddArray(fileId, ContainerType.Attribute));

                // Act
                using var root = H5File.OpenReadCore(filePath, deleteOnClose: true);
                var attribute  = root.Group("array").Attribute("array");
                var actual     = attribute
                                 .Read <int>()
                                 .ToArray4D(2, 3, 4, 5);

                var expected_casted = TestData.ArrayData.Cast <int>().ToArray();
                var actual_casted   = actual.Cast <int>().ToArray();

                // Assert
                Assert.True(actual_casted.SequenceEqual(expected_casted));
            });
        }
Esempio n. 2
0
        public void CanReadDataset_Array()
        {
            TestUtils.RunForAllVersions(version =>
            {
                // Arrange
                var filePath = TestUtils.PrepareTestFile(version, (Action <long>)(fileId => TestUtils.AddArray(fileId, ContainerType.Dataset)));

                // Act
                using var root = H5File.OpenReadCore(filePath, deleteOnClose: true);
                var dataset    = root.Group("array").Dataset("array");
                var actual     = dataset
                                 .Read <int>()
                                 .ToArray4D(2, 3, 4, 5);

                var expected_casted = TestData.ArrayData.Cast <int>().ToArray();
                var actual_casted   = actual.Cast <int>().ToArray();

                var b = MemoryMarshal.AsBytes(expected_casted.AsSpan());
                var c = MemoryMarshal.AsBytes(actual_casted.AsSpan());

                // Assert
                Assert.True(actual_casted.SequenceEqual(expected_casted));
            });
        }
Esempio n. 3
0
        public void CanReadDataset_Array()
        {
            TestUtils.RunForAllVersions((Action <H5F.libver_t>)(version =>
            {
                // Arrange
                var filePath = TestUtils.PrepareTestFile(version, (Action <long>)(fileId => TestUtils.AddArray((long)fileId, ContainerType.Dataset)));

                // Act
                using var root = H5File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, deleteOnClose: true);
                var dataset    = root.Group("array").Dataset("array");
                var actual     = dataset
                                 .Read <int>()
                                 .ToArray4D(2, 3, 4, 5);

                var expected_casted = TestData.ArrayData.Cast <int>().ToArray();
                var actual_casted   = actual.Cast <int>().ToArray();

                // Assert
                Assert.True(actual_casted.SequenceEqual(expected_casted));
            }));
        }